1
我正在尝试使用Qt openCV设置。我正在使用Qt创建器,但我目前只在进行C++/opencv调用。此代码适用于我的集成摄像头,但是当我切换到我的USB摄像头时,我得到一个Windows错误,告诉我opencv.exe已经崩溃,Qt告诉我我的程序意外完成。有趣的是,如果我将imshow更改为imwrite,我会从网络摄像头获取文件中的输出,以便捕获似乎可行,但我无法显示。OpenCV在imShow上崩溃只为USB摄像头
#include <opencv2/core/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
using namespace cv;
int main(int argc, char *argv[])
{
VideoCapture cap(0);
// open the default camera, use something different from 0 otherwise;
// Check VideoCapture documentation.
if(!cap.isOpened())
return 1;
for(;;)
{
Mat frame;
cap.retrieve(frame);
if(frame.empty()) break; // end of video stream
imshow("this is you, smile! :)", frame);
if(waitKey(1) == 27) break; // stop capturing by pressing ESC
}
// the camera will be closed automatically upon exit
// cap.close();
return 0;
}
更换
是忘了提,我不从盖变化(0)到盖(1)。实际上取决于当我启动它的盖帽(0)并且我的集成摄像头是盖帽(1)时是否有USB摄像头。没有运气改变为2或3他们在!cap.isOpened()调用退出。我尝试重新安装驱动程序。尽管我认为他们正在工作,因为我可以将帧写入文件 – CrimsonKnights