Image Capture with OpenCV - Select Timeout Error(使用 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 捕获图像 - 选择超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 OpenCV 捕获图像 - 选择超时错误


基础教程推荐
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01