Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

VideoCapture parameters CV_CAP_PROP_FOURCC or CV_CAP_PROP_FPS, among others, not working


I'm writing a code wich uses an USB webcam. Enviroment: Ubuntu 12.04 + OpenCV 2.4.2. All the development libraries are installed and updated (FFMPEG, V4L and so on).

Since CPU usage and bandwitdh are critical, I need to set some parameters, such as the frame size:

VideoCapture MyWebCamVariable;;
MyWebCamVariable.set(CV_CAP_PROP_FRAME_WIDTH, 320)
MyWebCamVariable.set(CV_CAP_PROP_FRAME_HEIGHT, 240)

Ok, everything works flawlessly, camera is shown properly. Troubles appear when dealing with parameters such as CV_CAP_PROP_FOURCC or CV_CAP_PROP_FPS (all of them are documented in the OpenCV reference manual).

For example:

char MyWebCamCodec;
MyWebCamCodec = MyWebCamVariable.get(CV_CAP_PROP_FOURCC);

gives the following message when executed:

HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(6) - Invalid Argument

Notice that I used get instruction, so no chances to mistake with a bad value. The rest of the code works well. Variable MyWebCamCodec is given an unrecognised character: �

In a Linux terminal I used v4l2-ctl --list-formats-ext and I checked that lots of capture modes (resolutions, FPS, YUV and MJPEG) are avaiable.