【发布时间】:2016-06-19 18:22:40
【问题描述】:
我正在尝试使用 Qt 设置 openCV。尽管我目前只进行 C++/opencv 调用,但我正在使用 Qt creator。此代码适用于我的集成网络摄像头,但是当我切换到我的 USB 摄像头时,我收到一个 Windows 错误,告诉我 opencv.exe 已崩溃,Qt 告诉我我的程序意外完成。有趣的是,如果我将 imshow 更改为 imwrite,我会在一个文件中从网络摄像头获取输出,因此捕获似乎可以正常工作,我只是无法显示。
#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;
}
【问题讨论】:
标签: c++ qt opencv window video-capture