Ask Your Question

VideoCapture parameters CV_CAP_PROP_FOURCC or CV_CAP_PROP_FPS, among others, not working

asked 2012-11-19 13:12:38 -0500

CharlesCV gravatar image


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.


edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2012-11-28 15:41:01 -0500

CharlesCV gravatar image

updated 2012-11-28 15:41:24 -0500

I have checked source files "cap_v4l.cpp" & "cap_libv4l.cpp".

Parameters CV_CAP_PROP_FOURCC and CV_CAP_PROP_FPS are not implemented. That's why they will never work under Linux.

No surprise, since it's libre software: sooner or later you'll have to pay for it somehow.

edit flag offensive delete link more


Same thing with CV_CAP_PROP_FOCUS and many others....

Geppertm gravatar imageGeppertm ( 2012-12-13 04:11:24 -0500 )edit

answered 2013-03-31 19:08:52 -0500

evil0sheep gravatar image

updated 2013-03-31 19:21:45 -0500


I'm looking to implement libv4l2 support for CV_CAP_PROP_POS_MSEC, which is defined somewhat vaguely here as "Film current position in milliseconds or video capture timestamp", is there a clearer definition of how it should behave? Specifically can it return the timestamp of the last frame retrieved and zero if no frames have been retrieved? When should the timestamp count from?

Also is there a better place to ask this question?


edit flag offensive delete link more

Question Tools


Asked: 2012-11-19 13:12:38 -0500

Seen: 11,852 times

Last updated: Mar 31 '13