这个简单的代码让我感到困惑,该代码本来可以打开相机,但是.exe
经常崩溃。知道我该怎么办吗?
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
Mat image;
VideoCapture cap(0);
if(!cap.isOpened()) {
cerr << "No camera detected on this system" << endl;
return -1;
}
while(true) {
cap >> image;
if(image.empty()) {
cerr << "Frame invalid and skipped!" << endl;
continue;
}
imshow("test", image);
waitKey(5);
}
return 0;
}