.exe不断崩溃,打开CV

时间:2018-07-29 13:52:28

标签: opencv compilation crash

这个简单的代码让我感到困惑,该代码本来可以打开相机,但是.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;
}

0 个答案:

没有答案
相关问题