使用 OpenCV 捕获图像 - 选择超时错误

Image Capture with OpenCV - Select Timeout Error(使用 OpenCV 捕获图像 - 选择超时错误)
本文介绍了使用 OpenCV 捕获图像 - 选择超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想保存从我的网络摄像头附加的 BeagleBone Black 捕获的图像,但是当我运行以下代码时,我收到错误:选择超时.

I would like to save a captured image from my webcam attached BeagleBone Black, however when I run the following code, I get the error: select timeout.

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/videoio.hpp"

using namespace std;
using namespace cv;

int main(){



        cout<< "Hello, OpenCV version: "<< CV_VERSION << endl;


        Mat frame;
        VideoCapture cap(0);


        cap.set(CV_CAP_PROP_FRAME_WIDTH , 320);
        cap.set(CV_CAP_PROP_FRAME_HEIGHT , 240);

        cap >> frame;

        imwrite("camCap.jpg", frame);

        return 0;
}

当我编译和运行代码时:

When I compile and run the code:

root@beaglebone:/home/iroh/test# g++ test.cpp -lopencv_core -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -o test
root@beaglebone:/home/iroh/test# ./test
Hello, OpenCV version: 3.1.0
select timeout
OpenCV Error: Assertion failed (total() == 0 || data != NULL) in Mat, file /home/iroh/Downloads/opencv-3.1.0/modules/core/include/opencv2/core/mat.inl.hpp, line 410
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/iroh/Downloads/opencv-3.1.0/modules/core/include/opencv2/core/mat.inl.hpp:410: error: (-215) total() == 0 || data != NULL in function Mat

Aborted

导致该问题的原因可能是什么?

What can be the cause of that problem?

根据错误输出,我的框架是空的.这是我第一次将这个网络摄像头连接到 BeagleBone Black.它可以在我的 PC 上正常运行,但我不知道它是否可以与 BeagleBone Black 一起成功运行.

According to the error output, my frame is empty. It is first time I attached this webcam to BeagleBone Black. It works properly on my PC, but I do not know whether it is working successfully with BeagleBone Black.

这里是 dmesg 输出:

Here is the dmesg output:

[ 4276.642456] usb 1-1: new high-speed USB device number 2 using musb-hdrc
[ 4277.411212] usb 1-1: New USB device found, idVendor=1e4e, idProduct=0110
[ 4277.411257] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4277.411284] usb 1-1: Product: USB2.0 Camera
[ 4277.411310] usb 1-1: Manufacturer: Etron Technology, Inc.
[ 4277.532768] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0110)
[ 4277.542871] input: USB2.0 Camera as /devices/platform/ocp/47400000.usb/47401c00.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/input/input1
[ 4277.547293] usbcore: registered new interface driver uvcvideo
[ 4277.547322] USB Video Class driver (1.1.1)

我该怎么办?

谢谢!

推荐答案

我遇到了同样的问题并设法解决了它.检查我的答案这里

I was running into this same issue and managed to fix it. Check my answer here

这篇关于使用 OpenCV 捕获图像 - 选择超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

What is the proper function for comparing two C-style strings?(比较两个 C 风格字符串的正确函数是什么?)
SHA256 HMAC using OpenSSL 1.1 not compiling(使用 OpenSSL 1.1 的 SHA256 HMAC 未编译)
How to make a Debian package depend on multiple versions of libboost(如何制作一个Debian包依赖于多个版本的libboost)
Why does strcpy_s not exist anywhere on my system?(为什么我系统上的任何地方都不存在 strcpy_s?)
Simplest way to get current time in current timezone using boost::date_time?(使用 boost::date_time 在当前时区获取当前时间的最简单方法?)
Qt debian/ubuntu: Can#39;t compile, error: cannot find -lGL(Qt debian/ubuntu:无法编译,错误:找不到-lGL)