linux v4l2 opencv,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;

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值