CV2 Python VideoCapture (0) unexpected argument

I have a short python script that will open a webcam and show a live feed on a local website. I am using the PyCharm IDE, which offers corrections and notifies you in case of a syntax error. When I pass the VideoCapture argument, it highlights it and says "unexpected argument."

self.video = cv2.VideoCapture ( 0 )

This is in the class, and the "unexpected argument" is called 0, which is passed to the OpenCV function. Is there any way to fix this?

By the way, it works fine as it is - when you run it, it works as it should. If you delete zero, the error will disappear, but it will no longer initialize the webcam.

+4
source share
2 answers

Instead of breaking the wrong bindings, you can also just turn off the warning in the IDE by adding a noinspection comment.

# noinspection PyArgumentList
cap = cv2.VideoCapture(filename)
+1
source

I think you're right, and the Hector-Inspector from the PyCharm IDE is wrong. Therefore, go to the warning line and suppress the warning for this statement: place the cursor on the instruction, go to the bulb icon, click on the triangle in the right corner, select "Suppress for approval" in the menu.

+1
source

Source: https://habr.com/ru/post/1657123/


All Articles