-1

当我在调试模式下运行 OpenCV 项目时,它以代码 0 退出。

但这从文件夹运行没有问题。有人可以帮助我。

PS:这似乎是 Visual Studio 的一个问题,因为程序在通过双击从资源管理器运行时运行时没有任何错误。

#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <stdio.h>
#include<fstream>
#include <iostream>

using namespace std;
using namespace cv;


int main(int argc, char** argv) {

    VideoCapture capture;
    Mat frame;

    capture.open(0);
    if (capture.isOpened()) {
       while (true) {
            capture >> frame;
            if (!frame.empty()) {
                imshow("Test", frame);
            } else {
                printf(" --(!) No captured frame -- Break!");
                break;
            }

            int c = waitKey(10);
            if ((char) c == 'c') {
                break;
            }
        }
    }
    return 0;
}
4

1 回答 1

2

退出状态为 0 表示程序成功终止,因此您没有问题。参见例如C 中的 exit(0) 和 exit(1) 有什么区别?

于 2013-07-04T13:29:25.167 回答