Skip to content
Advertisement

NameError: name ‘VideoCapture’ is not defined [closed]

I’ve tried to save an image using OpenCV to a specified folder in the past days however i constantly find this error:

JavaScript

My code is below:

JavaScript

Any suggestions or ideas on how to solve my issue? Edit: removed irrelevant information!

Advertisement

Answer

Basically the issue is with your from cv2 import *. I’ll just point you to the internet as to why you shouldn’t us import *.
FE. this medium article has a nice write-up. Be sure to follow the links in that article as well.

There are two easy fixes available. First, import cv2 into its proper namespace.

JavaScript

Option 2, import specific parts from cv2. Note that I would very strongly advise to use option 1 here.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement