Program exited fast with exit code

asked 2015-07-06 01:40:46 -0500

I have written following program. which is exited as soon as i run it

    #include "opencv2/opencv.hpp"

using namespace cv;

int main(void)
    VideoCapture cap("video.webm");
    //  VideoCapture cap(0); // open the default camera
    if (!cap.isOpened())  // check if we succeeded
        return -1;
Mat edges;
namedWindow("edges", 1);
for (;;)
    Mat frame;
    cap >> frame; // get a new frame from camera

    if (frame.empty())
    else if (frame.channels()>1)
        cvtColor(frame, edges, CV_BGR2GRAY);
    else edges = frame;

    cvtColor(frame, edges, CV_BGR2GRAY);
    GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5);
    Canny(edges, edges, 0, 30, 3);
    imshow("edges", edges);
    if (waitKey(30) >= 0) break;
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;

It runs but exited with the following messages.

The thread 0x3ae0 has exited with code 0 (0x0). The thread 0x19b0 has exited with code 0 (0x0). The thread 0x4194 has exited with code 0 (0x0). The thread 0x4fe8 has exited with code 0 (0x0). The program '[10212] ConsoleApplication1.exe' has exited with code 0 (0x0).

edit retag flag offensive close merge delete


Do you want to use a continue instead of a break? Otherwise your program will terminate as soon as an empty frame was read.

FooBar gravatar imageFooBar ( 2015-07-06 03:56:51 -0500 )edit