Capturing webcam stream in Python using OpenCV - Need help


I'm running Python2.7 on Arch Linux. I installed OpenCV via Pacman.

The Python code I'm using is:

import cv

capture = cv.CaptureFromCAM(0)

Very simple. All I'm trying to do, for now, is get Python access to my webcam. But that above code outputs:

[user@host python]$ python2.7 
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument

My webcam works fine with Cheese (linux webcam program). So, presumable, there shouldn't be any driver/module issues...

Any ideas?

1/29/2011 4:23:19 AM

Take a look at this: Displaying a webcam feed using OpenCV and Python

It appears that you're not passing .CaptureFromCAM() the right argument. If there is only one camera, you can do something like this:

    capture = cv.CaptureFromCAM(-1)

The -1 tells it to just grab whatever camera it can find (see this).

5/23/2017 12:04:12 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow