【发布时间】:2012-05-29 23:21:19
【问题描述】:
我正在尝试使用以下代码设置相机参数,但它根本不起作用。
using namespace cv;
int main(int argc,char *argv[])
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
bool value = cap.set(CV_CAP_PROP_FRAME_WIDTH,10);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
imshow("frame", frame);
unsigned char *dad = (unsigned char*)frame.data;
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
【问题讨论】:
-
请解释“根本不工作”是什么意思。它编译吗?它会抛出错误吗?我可以想象您的相机和/或驱动程序不支持更改帧宽度参数。例如,在 Linux 中,无法更改使用 V4L 的相机的参数。
-
另外,如果你想显示图片,你应该在无限循环之前添加这行
cvNamedWindow( "frame", CV_WINDOW_AUTOSIZE );。 -
我的意思是我无法更改任何相机参数。