如何在OpenCV中设置相机FPS? CV_CAP_PROP_FPS是假的 [英] How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake
问题描述
如何设定相机FPS?
可能是
cvSetCaptureProperty(cameraCapture,CV_CAP_PROP_FPS,30);
?
May be cvSetCaptureProperty(cameraCapture, CV_CAP_PROP_FPS, 30); ?
但返回
HIGHGUI错误:V4L2:无法获取属性(5) - 参数无效
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\n",
property_id);
}
/* return the the status */
return retval;
}
如何解决?
推荐答案
我不知道这是否仍然有效,但前一段时间,像一年半,我遇到了确切的问题。我与OpenCV的开发人员联系,他告诉我,改变捕获的一些属性的访问和能力尚未实现,其他一些只是为某些类型的相机工作。我终于看了一下 libdc1394 (在Linux中工作),并做了一些功能,将libdc1394检索的数据转换为IplImages从OpenCV。这不是一个艰巨的任务。
I don't know if that's still valid, but some time ago, something like one year and a half, I encountered that exactly problem. I contacted with a developer of OpenCV and he told me that the access and ability to change some of the properties of a capture weren't implemented yet and some other just worked for certain kinds of camera. I finally took a look to libdc1394 (working in linux) and made some functions that converted the data retrieved by libdc1394 to IplImages from OpenCV. It wasn't a such a tough task.
这篇关于如何在OpenCV中设置相机FPS? CV_CAP_PROP_FPS是假的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!