I am using the following code to access a webcam using openCV + python ...
import cv
cv.NamedWindow('webcam_feed', cv.CV_WINDOW_AUTOSIZE)
cam = cv.CaptureFromCAM(-1)
Then I get the following error in the console ...
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
I originally used
cv.CaptureFromCAM(0)
to access the same and have the same problem and use -1, because it is assumed that it picks up any webcam.
I also tested if Ubuntu recognizes a webcam, and it does. I am using v4l2 for webcam.
{EDIT}
I am using the following code to display a video stream, it seems to display only one image captured by a webcam, instead of a continuous video stream ...
import cv
cv.NamedWindow('webcam_feed', cv.CV_WINDOW_AUTOSIZE)
cam = cv.CaptureFromCAM(-1)
feed = cv.QueryFrame(cam)
cv.ShowImage("webcam_feed", feed)
cv.WaitKey(-1)
source
share