OpenCV in python. Getting webcam stream works, but error message is printed

11,287

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.

Share:
11,287
elaRosca
Author by

elaRosca

student

Updated on June 04, 2022

Comments

  • elaRosca
    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 using cv2 instead of cv, 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
    elaRosca about 11 years
    Same 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
    Abhishek Thakur about 11 years
    did you try VideoCapture(0) ??
  • mmgp
    mmgp about 11 years
    This is irrelevant to how you start the capture. It is an issue regarding how OpenCV uses v4l internally, supposing @elaRosca's platform uses v4l.
  • Abhishek Thakur
    Abhishek Thakur about 11 years
    yes. you are correct. i think he should install the v41 drivers again.
  • mmgp
    mmgp about 11 years
    You can reinstall it (V 4 L, not V 4 1) 50 times, if opencv is not using it correctly, there is no point in doing so. If some change in v4l made the warnings go away, then an updated version might solve it.
  • elaRosca
    elaRosca about 11 years
    Just for the record, I am a girl. Thanks a lot @mmgp . I will just hide this from the user.
  • Abhishek Thakur
    Abhishek Thakur about 11 years
    found some information about the error somewhere. added it in the post.
  • mmgp
    mmgp about 11 years
    I'm not seeing how that patch is correct. The flag V4L2_CTRL_FLAG_NEXT_CTRL is set so the call to v4l2_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
    mmgp about 11 years
    Uhm, 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.