如何在 OpenCV 中设置相机 FPS?CV_CAP_PROP_FPS 是假的 [英] How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake
本文介绍了如何在 OpenCV 中设置相机 FPS?CV_CAP_PROP_FPS 是假的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置相机帧率?
可能是cvSetCaptureProperty(cameraCapture, CV_CAP_PROP_FPS, 30);?
May be cvSetCaptureProperty(cameraCapture, CV_CAP_PROP_FPS, 30); ?
但它的回报HIGHGUI ERROR: V4L2: Unable to get property (5) - Invalid argument
But it's return HIGHGUI ERROR: V4L2: Unable to get property (5) - Invalid argument
因为highgui/cap_v4l.cpp中没有实现
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
",
property_id);
}
/* return the the status */
return retval;
}
如何解决?
推荐答案
使用 opencv 的 python 包装器,我可以将变量引用为:
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)
我正在使用 python 2.7.3 和 opencv 2.4.8
I am using python 2.7.3 and opencv 2.4.8
相机是 PS3 Eye
The camera is the PS3 Eye
这篇关于如何在 OpenCV 中设置相机 FPS?CV_CAP_PROP_FPS 是假的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文