OpenCV in python. Getting webcam stream works, but error message is printed
I ran into the same error messages. In my case however they are not fatal, just an indication that python is using v4l2 to probe parameters that happen to be invalid for my camera / os combination.
In my case
>>> cap = cv2.VideoCapture(0)
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
...
But
ret, frame = cap.read()
gives ret=true and a numpy image-array for frame.
In my case the video camera is a Logitech, Inc. HD Webcam C910. And I am running Angstrom on a beagleboneblack.
Comments
-
elaRosca almost 2 years
I am writing something in which I need the webcam stream and do some face detection on it. Everything works fine, but I get an error message printed in the terminal, despite of me using
cv.CaptureFromCAM(-1)
which detects any camera connected to my machine. I also tried usingcv2
instead ofcv
, and I get the same error:VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument VIDIOC_QUERYMENU: Invalid argument
Note that the only code I am running currently is
cv.CaptureFromCAM(-1)
.Oh and I am using python 2.7.import cv cv.CaptureFromCAM(-1)
Can someone tell me how to fix this? Thanks.
-
elaRosca about 11 yearsSame error. Besides, I do not want to show the webcam all the time. I want to detect if someone is sitting in front of a computer, but the user can choose if they want to see the webcam or not.
-
Abhishek Thakur about 11 yearsdid you try VideoCapture(0) ??
-
mmgp about 11 yearsThis is irrelevant to how you start the capture. It is an issue regarding how OpenCV uses
v4l
internally, supposing @elaRosca's platform usesv4l
. -
Abhishek Thakur about 11 yearsyes. you are correct. i think he should install the v41 drivers again.
-
mmgp about 11 yearsYou can reinstall it (
V 4 L
, notV 4 1
) 50 times, if opencv is not using it correctly, there is no point in doing so. If some change inv4l
made the warnings go away, then an updated version might solve it. -
elaRosca about 11 yearsJust for the record, I am a girl. Thanks a lot @mmgp . I will just hide this from the user.
-
Abhishek Thakur about 11 yearsfound some information about the error somewhere. added it in the post.
-
mmgp about 11 yearsI'm not seeing how that patch is correct. The flag
V4L2_CTRL_FLAG_NEXT_CTRL
is set so the call tov4l2_queryctrl
returns the next control. In addition, before returning the next control, the /flag is cleared/. But, if the driver does not support the flag, EINVAL is returned -- this is very likely to be the case, as per an earlier comment: "it is trying to do something unsupported with your camera". So a correct patch should check whether the camera's driver support the flag or not, and then set the flag or not accordingly. -
mmgp about 11 yearsUhm, now seeing OpenCV's code I see the flag is being ORed again too early. This should be reported to the bug tracker. But please, do not apply this patch anywhere, it shouldn't clear that flag because it will stop querying for controls.