Ubuntu网络摄像头上的Opencv错误(Logitech C270)捕获 – > HIGHGUI错误:V4L/V4L2:VIDIOC_S_CROP

使用logitech C270(OpenCV 2.4.2 / C)在Ubuntu上运行简单的摄像头捕获时出现此错误消息:

HIGHGUI ERROR: V4L/V4L2: VIdioC_S_CROP

并进一步:

Corrupt JPEG data: 2 extraneous bytes before marker 0xd1
Corrupt JPEG data: 1 extraneous bytes before marker 0xd6
Corrupt JPEG data: 1 extraneous bytes before marker 0xd0
Corrupt JPEG data: 1 extraneous bytes before marker 0xd0

我得到帧但是在写入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;

所以宽度和高度之间没有交换.

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...