an issue with cvGetCaptureProperty on opencv-Collection of common programming errors

I have a working opencv code that takes feed from my webcam and displays it. (The code is modified from the one here

The only issue is that when I try to print the frames-per-second value, as

int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
printf ("Frames per Second: %d\n",fps);

-1 gets printed.

Another (side) issue is that there appears to be some run time errors/warnings

VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
select timeout
HIGHGUI ERROR: V4L2: Unable to get property (5) - Invalid argument
HIGHGUI ERROR: V4L: Property (2) not supported by device
HIGHGUI ERROR: V4L2: Unable to get property (1) - Invalid argument
HIGHGUI ERROR: V4L: Property (2) not supported by device

But the code does what it’s supposed to do, ie, display video from the webcam.

Any ideas how to sort out the problems? I am using opencv on Eclipse with CDT on Ubuntu 11.10

Thanks in advance.

  1. Judging from the error messages, this sounds like a problem your webcam driver. The error messages are from Video4Linux (V4L or V4L2 in the error messages), which is the part of the Linux kernel that contains webcam drivers. Getting a select() failure and the “not supported by device” error message probably means that your webcam didn’t implement this part of the V4L2 API.

    You can verify that this is the problem by testing your code with a camera that has a known-good driver. Unfortunately, this is very common in the webcam drivers included in the kernel. Many of them are reverse engineered, so it’s quite a feat just access the video stream.

  2. Try this for the HIGHGUI ERROR errors:

    export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so
    

Originally posted 2013-11-06 03:16:32.