在erolog上使用Logitech C270(OpenCV 2.4.2/C++)运行简单的摄像头捕获时,会出现以下erorr消息:
并进一步:
我得到帧,但是在写入Mat对象时交换了帧的宽度和高度的值,如下所示:
Mat frame;
videoCapture = new VideoCapture(camId);
if(!videoCapture->isOpened()) throw Exception();
cout << "Frame width: " << videoCapture->get(CV_CAP_PROP_FRAME_WIDTH) << endl;
cout << "Frame height: " << videoCapture->get(CV_CAP_PROP_FRAME_HEIGHT) << endl;
(*videoCapture) >> frame;
cout << "Mat width: " << frame.rows << endl;
cout << "Mat height: " << frame.cols << endl;
输出:
Frame width: 640
Frame height: 480
Mat width: 480
Mat height: 640
最佳答案
图像的宽度由其列数给出。您的代码应为
cout << "Mat width: " << frame.cols << endl;
cout << "Mat height: " << frame.rows << endl;
因此,宽度和高度之间没有交换。
关于Ubuntu Webcam(Logitech C270)Capture上的Opencv错误-> HIGHGUI错误: V4L/V4L2: VIDIOC_S_CROP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15533338/