Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake

How to set Camera FPS?

May be cvSetCaptureProperty(cameraCapture, CV_CAP_PROP_FPS, 30); ?

But it's return HIGHGUI ERROR: V4L2: Unable to get property (5) - Invalid argument

Because there is no implementation in highgui/cap_v4l.cpp

static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
                                  int property_id, double value ){
    static int width = 0, height = 0;
    int retval;

    /* initialization */
    retval = 0;

    /* two subsequent calls setting WIDTH and HEIGHT will change
       the video size */
    /* the first one will return an error, though. */

    switch (property_id) {
    case CV_CAP_PROP_FRAME_WIDTH:
        width = cvRound(value);
        if(width !=0 && height != 0) {
            retval = icvSetVideoSize( capture, width, height);
            width = height = 0;
        }
        break;
    case CV_CAP_PROP_FRAME_HEIGHT:
        height = cvRound(value);
        if(width !=0 && height != 0) {
            retval = icvSetVideoSize( capture, width, height);
            width = height = 0;
        }
        break;
    case CV_CAP_PROP_BRIGHTNESS:
    case CV_CAP_PROP_CONTRAST:
    case CV_CAP_PROP_SATURATION:
    case CV_CAP_PROP_HUE:
    case CV_CAP_PROP_GAIN:
    case CV_CAP_PROP_EXPOSURE:
        retval = icvSetControl(capture, property_id, value);
        break;
    default:
        fprintf(stderr,
                "HIGHGUI ERROR: V4L: setting property #%d is not supported\n",
                property_id);
    }

    /* return the the status */
    return retval;
}

How to solve it?

like image 956
victor1234 Avatar asked Aug 12 '11 11:08

victor1234


1 Answers

using the python wrappers for opencv, it worked for me to refer to the variable as:

cap = cv2.VideoCapture(1)
cap.set(cv2.cv.CV_CAP_PROP_FPS, 60)

I am using python 2.7.3 and opencv 2.4.8

The camera is the PS3 Eye

like image 71
elzbth Avatar answered Sep 20 '22 01:09

elzbth