gpt4 book ai didi

c++ - 使用 OpenCV 进行图像捕获 - 选择超时错误

转载 作者:太空狗 更新时间:2023-10-29 22:59:18 30 4
gpt4 key购买 nike

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

#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;
}

当我编译并运行代码时:

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

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

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

这是 dmesg 输出:

[ 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)

我该怎么办?

谢谢!

最佳答案

我遇到了同样的问题并设法解决了它。查看我的回答here

关于c++ - 使用 OpenCV 进行图像捕获 - 选择超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37273453/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com