使用OpenCV捕获图像-选择超时错误 [英] Image Capture with OpenCV - Select Timeout Error
问题描述
我想从连接了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捕获图像-选择超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!