Ask Your Question

Revision history [back]

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

    void detectAndDisplay(Mat frame)
    {
        std::vector<Rect> faces, eyes;

        Mat frame_gray, crop, gray;

        cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
        equalizeHist(frame_gray, frame_gray);

        // Detect faces and eyes
        face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

        size_t ic = 0; // ic is index of current element
        unsigned long ac = 0; // ac is area of current element

        size_t ib = 0; // ib is index of biggest element
        unsigned long ab = 0; // ab is area of biggest element

        for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
        {
            ac = faces[ic].area();
            ab = faces[ib].area();

            if (ac > ab)
                ib = ic; 
        }

            crop = frame(faces[ib]);
            cvtColor(crop, gray, COLOR_BGR2GRAY);
            equalizeHist(gray, gray);
            eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));

            Point Ept1, Ept2;       

         for (int i = 0; i < eyes.size(); ++i)
          {
               Ept1.x = eyes[i].x; 
               Ept1.y = eyes[i].y;

               Ept2.x = eyes[i].x + eyes[i].width; 
               Ept2.y = eyes[i].y + eyes[i].height;

               rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
          }

        namedWindow("original", WINDOW_NORMAL);
        imshow("original", frame);  
 }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

    void detectAndDisplay(Mat frame)
    {
        std::vector<Rect> faces, eyes;

        Mat frame_gray, crop, gray;

        cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
        equalizeHist(frame_gray, frame_gray);

        // Detect faces and eyes
        face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

        size_t ic = 0; // ic is index of current element
        unsigned long ac = 0; // ac is area of current element

        size_t ib = 0; // ib is index of biggest element
        unsigned long ab = 0; // ab is area of biggest element

        for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
        {
            ac = faces[ic].area();
            ab = faces[ib].area();

            if (ac > ab)
                ib = ic; 
        }

      if(faces.size())
       {
            crop = frame(faces[ib]);
            cvtColor(crop, gray, COLOR_BGR2GRAY);
            equalizeHist(gray, gray);
            eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));

            Point Ept1, Ept2;       

         for (int i = 0; i < eyes.size(); ++i)
          {
               Ept1.x = eyes[i].x; 
               Ept1.y = eyes[i].y;

               Ept2.x = eyes[i].x + eyes[i].width; 
               Ept2.y = eyes[i].y + eyes[i].height;

               rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
          }
      } 
        namedWindow("original", WINDOW_NORMAL);
        imshow("original", frame);  
 }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

    void detectAndDisplay(Mat frame)
    {
        std::vector<Rect> faces, eyes;

        Mat frame_gray, crop, gray;

        cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
        equalizeHist(frame_gray, frame_gray);

        // Detect faces and eyes
        face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

        size_t ic = 0; // ic is index of current element
        unsigned long ac = 0; // ac is area of current element

        size_t ib = 0; // ib is index of biggest element
        unsigned long ab = 0; // ab is area of biggest element

        for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
        {
            ac = faces[ic].area();
            ab = faces[ib].area();

            if (ac > ab)
                ib = ic; 
        }

      if(faces.size())
       {
            crop = frame(faces[ib]);
            cvtColor(crop, gray, COLOR_BGR2GRAY);
            equalizeHist(gray, gray);
            eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));

 
        if(eyes.size())  
          {
          Point Ept1, Ept2;      

         for (int i = 0; i < eyes.size(); ++i)
          {
               Ept1.x = eyes[i].x; 
               Ept1.y = eyes[i].y;

               Ept2.x = eyes[i].x + eyes[i].width; 
               Ept2.y = eyes[i].y + eyes[i].height;

               rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
           }
       } 
       } 
      namedWindow("original", WINDOW_NORMAL);
       imshow("original", frame);   
 }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

     #include "opencv2/objdetect/objdetect.hpp"
        #include "opencv2/highgui/highgui.hpp"
        #include "opencv2/imgproc/imgproc.hpp"

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

        using namespace std;
        using namespace cv;

        // Function Headers
        void detectAndDisplay(Mat frame);
        void CallBackFunc(int event, int x, int y, int flags, void* userdata);

        // Global variables
        // Copy this file from opencv/data/haarscascades to target folder
        string face_cascade_name = "haarcascade_frontalface_alt.xml";
        CascadeClassifier face_cascade;
        string eye_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
        CascadeClassifier eye_cascade;

        string window_name = "Capture - Face detection";


        // Function main
        int main(void)
        {
            VideoCapture capture(0);

            if (!capture.isOpened())  // check if we succeeded
                return -1;

            // Load the cascade
            if (!face_cascade.load(face_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            if (!eye_cascade.load(eye_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            // Read the video stream
            Mat frame;

            for (;;)
            {
                capture >> frame;

                // Apply the classifier to the frame
                if (!frame.empty())
                    detectAndDisplay(frame);

                else
                {
                    printf(" --(!) No captured frame -- Break!");
                    break;
                }

                int c = waitKey(10);

                if (27 == char(c))
                    break;
            }

            return 0;
        }

            void detectAndDisplay(Mat frame)
     {
         std::vector<Rect> faces, eyes;

         Mat frame_gray, crop, gray;
                 string text; 
                stringstream sstm;          

                cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
         equalizeHist(frame_gray, frame_gray);

         // Detect faces and eyes
         face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

                  Point cen_win(frame.size().width / 2, frame.size().height / 2);
              circle(frame, cen_win, 1, Scalar(0, 0, 255), CV_FILLED);


                    size_t ic = 0; // ic is index of current element
         unsigned long ac = 0; // ac is area of current element

         size_t ib = 0; // ib is index of biggest element
         unsigned long ab = 0; // ab is area of biggest element

         for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
         {
             ac = faces[ic].area();
             ab = faces[ib].area();

             if (ac > ab)
                 ib = ic; 
         }

       if(faces.size())
        {
                    Point pt1(faces[ib].x, faces[ib].y);
            Point pt2((faces[ib].x + faces[ib].width), (faces[ib].y + faces[ib].height));
            rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0); //Coords pt1 are of left corner.

                    crop = frame(faces[ib]);
             cvtColor(crop, gray, COLOR_BGR2GRAY);
             equalizeHist(gray, gray);
             eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));


         if(eyes.size())  
           {
           Point Ept1, Ept2;     

          for (int i = 0; i < eyes.size(); ++i)
           {
                Ept1.x = eyes[i].x; 
                Ept1.y = eyes[i].y;

                Ept2.x = eyes[i].x + eyes[i].width; 
                Ept2.y = eyes[i].y + eyes[i].height;

                rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
             }
           } 
                    Point cen_rec(faces[ib].x + faces[ib].width / 2, faces[ib].y + faces[ib].height / 2);
            circle(frame, cen_rec, 1, Scalar(0, 0, 255), CV_FILLED); //Marks the center of detected face.                                          


// Show image
            sstm << "Crop area size: " << faces[ib].width << "x" << faces[ib].height << " Size of window: " << frame.size().width << '*' << frame.size().height;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());

            double percentage;
            percentage = ((double)ab) / (frame.size().width * frame.size().height) * 100;
            sstm << "Percentage: " << percentage << " Tilt: " << (cen_rec.y - cen_win.y)/10 << " Pan: " << (cen_rec.x - cen_win.x) / 10;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 50), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());
               } 
       namedWindow("original", WINDOW_NORMAL);
              setMouseCallback("original", CallBackFunc, NULL);
              imshow("original", frame);    

    if (!crop.empty())
        {
            imshow("detected", crop);
        }
        else
            destroyWindow("detected");

         }

    void CallBackFunc(int event, int x, int y, int flags, void * userdata)
    {
        if (event == EVENT_LBUTTONDOWN)
        {
            cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_RBUTTONDOWN)
        {
            cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_MBUTTONDOWN)
        {
            cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        /*else if (event == EVENT_MOUSEMOVE)
        {
        cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;

        }*/
    }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

Output screenI'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

        #include "opencv2/objdetect/objdetect.hpp"
        #include "opencv2/highgui/highgui.hpp"
        #include "opencv2/imgproc/imgproc.hpp"

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

        using namespace std;
        using namespace cv;

        // Function Headers
        void detectAndDisplay(Mat frame);
        void CallBackFunc(int event, int x, int y, int flags, void* userdata);

        // Global variables
        // Copy this file from opencv/data/haarscascades to target folder
        string face_cascade_name = "haarcascade_frontalface_alt.xml";
        CascadeClassifier face_cascade;
        string eye_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
        CascadeClassifier eye_cascade;

        string window_name = "Capture - Face detection";


        // Function main
        int main(void)
        {
            VideoCapture capture(0);

            if (!capture.isOpened())  // check if we succeeded
                return -1;

            // Load the cascade
            if (!face_cascade.load(face_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            if (!eye_cascade.load(eye_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            // Read the video stream
            Mat frame;

            for (;;)
            {
                capture >> frame;

                // Apply the classifier to the frame
                if (!frame.empty())
                    detectAndDisplay(frame);

                else
                {
                    printf(" --(!) No captured frame -- Break!");
                    break;
                }

                int c = waitKey(10);

                if (27 == char(c))
                    break;
            }

            return 0;
        }

            void detectAndDisplay(Mat frame)
            {
                std::vector<Rect> faces, eyes;

                Mat frame_gray, crop, gray;
                string text; 
                stringstream sstm;          

                cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
                equalizeHist(frame_gray, frame_gray);

                // Detect faces and eyes
                face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

                  Point cen_win(frame.size().width / 2, frame.size().height / 2);
              circle(frame, cen_win, 1, Scalar(0, 0, 255), CV_FILLED);


                    size_t ic = 0; // ic is index of current element
                unsigned long ac = 0; // ac is area of current element

                size_t ib = 0; // ib is index of biggest element
                unsigned long ab = 0; // ab is area of biggest element

                for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
                {
                    ac = faces[ic].area();
                    ab = faces[ib].area();

                    if (ac > ab)
                        ib = ic; 
                }

              if(faces.size())
               {
                    Point pt1(faces[ib].x, faces[ib].y);
            Point pt2((faces[ib].x + faces[ib].width), (faces[ib].y + faces[ib].height));
            rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0); //Coords pt1 are of left corner.

                    crop = frame(faces[ib]);
                    cvtColor(crop, gray, COLOR_BGR2GRAY);
                    equalizeHist(gray, gray);
                    eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));


                if(eyes.size())  
                  {
                  Point Ept1, Ept2;     

                 for (int i = 0; i < eyes.size(); ++i)
                  {
                       Ept1.x = eyes[i].x; 
                       Ept1.y = eyes[i].y;

                       Ept2.x = eyes[i].x + eyes[i].width; 
                       Ept2.y = eyes[i].y + eyes[i].height;

                       rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
                    }
                  } 
                    Point cen_rec(faces[ib].x + faces[ib].width / 2, faces[ib].y + faces[ib].height / 2);
            circle(frame, cen_rec, 1, Scalar(0, 0, 255), CV_FILLED); //Marks the center of detected face.                                          


// Show image
            sstm << "Crop area size: " << faces[ib].width << "x" << faces[ib].height << " Size of window: " << frame.size().width << '*' << frame.size().height;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());

            double percentage;
            percentage = ((double)ab) / (frame.size().width * frame.size().height) * 100;
            sstm << "Percentage: " << percentage << " Tilt: " << (cen_rec.y - cen_win.y)/10 << " Pan: " << (cen_rec.x - cen_win.x) / 10;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 50), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());
               } 
              namedWindow("original", WINDOW_NORMAL);
              setMouseCallback("original", CallBackFunc, NULL);
              imshow("original", frame);    

    if (!crop.empty())
        {
            imshow("detected", crop);
        }
        else
            destroyWindow("detected");

         }

    void CallBackFunc(int event, int x, int y, int flags, void * userdata)
    {
        if (event == EVENT_LBUTTONDOWN)
        {
            cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_RBUTTONDOWN)
        {
            cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_MBUTTONDOWN)
        {
            cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        /*else if (event == EVENT_MOUSEMOVE)
        {
        cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;

        }*/
    }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

Output screenI'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

        #include "opencv2/objdetect/objdetect.hpp"
        #include "opencv2/highgui/highgui.hpp"
        #include "opencv2/imgproc/imgproc.hpp"

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

        using namespace std;
        using namespace cv;

        // Function Headers
        void detectAndDisplay(Mat frame);
        void CallBackFunc(int event, int x, int y, int flags, void* userdata);

        // Global variables
        // Copy this file from opencv/data/haarscascades to target folder
        string face_cascade_name = "haarcascade_frontalface_alt.xml";
        CascadeClassifier face_cascade;
        string eye_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
        CascadeClassifier eye_cascade;

        string window_name = "Capture - Face detection";


        // Function main
        int main(void)
        {
            VideoCapture capture(0);

            if (!capture.isOpened())  // check if we succeeded
                return -1;

            // Load the cascade
            if (!face_cascade.load(face_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            if (!eye_cascade.load(eye_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

            // Read the video stream
            Mat frame;

            for (;;)
            {
                capture >> frame;

                // Apply the classifier to the frame
                if (!frame.empty())
                    detectAndDisplay(frame);

                else
                {
                    printf(" --(!) No captured frame -- Break!");
                    break;
                }

                int c = waitKey(10);

                if (27 == char(c))
                    break;
            }

            return 0;
        }

            void detectAndDisplay(Mat frame)
            {
                std::vector<Rect> faces, eyes;

                Mat frame_gray, crop, gray;
                string text; 
                stringstream sstm;          

                cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
                equalizeHist(frame_gray, frame_gray);

                // Detect faces and eyes
                face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

                  Point cen_win(frame.size().width / 2, frame.size().height / 2);
              circle(frame, cen_win, 1, Scalar(0, 0, 255), CV_FILLED);


                    size_t ic = 0; // ic is index of current element
                unsigned long ac = 0; // ac is area of current element

                size_t ib = 0; // ib is index of biggest element
                unsigned long ab = 0; // ab is area of biggest element

                for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
                {
                    ac = faces[ic].area();
                    ab = faces[ib].area();

                    if (ac > ab)
                        ib = ic; 
                }

              if(faces.size())
               {
                    Point pt1(faces[ib].x, faces[ib].y);
            Point pt2((faces[ib].x + faces[ib].width), (faces[ib].y + faces[ib].height));
            rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0); //Coords pt1 are of left corner.

                    crop = frame(faces[ib]);
                    cvtColor(crop, gray, COLOR_BGR2GRAY);
                    equalizeHist(gray, gray);
                    eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));


                if(eyes.size())  
                  {
                  Point Ept1, Ept2;     

                 for (int i = 0; i < eyes.size(); ++i)
                  {
                       Ept1.x = eyes[i].x; 
                       Ept1.y = eyes[i].y;

                       Ept2.x = eyes[i].x + eyes[i].width; 
                       Ept2.y = eyes[i].y + eyes[i].height;

                       rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
                    }
                  } 
                    Point cen_rec(faces[ib].x + faces[ib].width / 2, faces[ib].y + faces[ib].height / 2);
            circle(frame, cen_rec, 1, Scalar(0, 0, 255), CV_FILLED); //Marks the center of detected face.                                          


// Show image
            sstm << "Crop area size: " << faces[ib].width << "x" << faces[ib].height << " Size of window: " << frame.size().width << '*' << frame.size().height;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());

            double percentage;
            percentage = ((double)ab) / (frame.size().width * frame.size().height) * 100;
            sstm << "Percentage: " << percentage << " Tilt: " << (cen_rec.y - cen_win.y)/10 << " Pan: " << (cen_rec.x - cen_win.x) / 10;
            text = sstm.str();
            putText(frame, text, cvPoint(30, 50), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
            sstm.clear();
            sstm.str(string());
               } 
              namedWindow("original", WINDOW_NORMAL);
              setMouseCallback("original", CallBackFunc, NULL);
              imshow("original", frame);    

    if (!crop.empty())
        {
            imshow("detected", crop);
        }
        else
            destroyWindow("detected");

         }

    void CallBackFunc(int event, int x, int y, int flags, void * userdata)
    {
        if (event == EVENT_LBUTTONDOWN)
        {
            cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_RBUTTONDOWN)
        {
            cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        else if (event == EVENT_MBUTTONDOWN)
        {
            cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
        /*else if (event == EVENT_MOUSEMOVE)
        {
        cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;

        }*/
    }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

Console screen

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

  #include "opencv2/objdetect/objdetect.hpp"
       #include "opencv2/highgui/highgui.hpp"
       #include "opencv2/imgproc/imgproc.hpp"

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

       using namespace std;
       using namespace cv;

       // Function Headers
       void detectAndDisplay(Mat frame);
       void CallBackFunc(int event, int x, int y, int flags, void* userdata);

       // Global variables
        // Copy this file from opencv/data/haarscascades to target folder
  variable
      string face_cascade_name = "haarcascade_frontalface_alt.xml";
       CascadeClassifier face_cascade;
       string eye_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
       CascadeClassifier eye_cascade;

       string window_name = "Capture - Face detection";

   // Function main
       int main(void)
         {
             VideoCapture capture(0);

             if (!capture.isOpened())  // check if we succeeded
                 return -1;

             // Load the cascade
             if (!face_cascade.load(face_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }
              if (!eye_cascade.load(eye_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

             // Read the video stream
             Mat frame;

             for (;;)
             {
                 capture >> frame;

                 // Apply the classifier to the frame
                 if (!frame.empty())
                     detectAndDisplay(frame);

                 else
                 {
                     printf(" --(!) No captured frame -- Break!");
                     break;
                 }

                 int c = waitKey(10);

                 if (27 == char(c))
                     break;
             }

             return 0;
         }

 void detectAndDisplay(Mat frame)
 {
    std::vector<Rect> faces, eyes;

    Mat frame_gray, crop, gray;
    string text; 
    stringstream sstm;          

    cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
    equalizeHist(frame_gray, frame_gray);

     // Detect faces and eyes
     face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

     Point cen_win(frame.size().width / 2, frame.size().height / 2);
     circle(frame, cen_win, 1, Scalar(0, 0, 255), CV_FILLED);

     size_t ic = 0; // ic is index of current element
     unsigned long ac = 0; // ac is area of current element

     size_t ib = 0; // ib is index of biggest element
     unsigned long ab = 0; // ab is area of biggest element

      for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
            {
                 ac = faces[ic].area();
                 ab = faces[ib].area();

                 if (ac > ab)
                     ib = ic; 
            }

       if(faces.size())
           {
                Point pt1(faces[ib].x, faces[ib].y);
             Point pt2((faces[ib].x + faces[ib].width), (faces[ib].y + faces[ib].height));
             rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0); //Coords pt1 are of left corner.

                crop = frame(faces[ib]);
                cvtColor(crop, gray, COLOR_BGR2GRAY);
                equalizeHist(gray, gray);
                eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));


                if(eyes.size())  
                   {
                   Point Ept1, Ept2;                        for (int i = 0; i < eyes.size(); ++i)
                   {
                        Ept1.x = eyes[i].x; 
                        Ept1.y = eyes[i].y;

                        Ept2.x = eyes[i].x + eyes[i].width; 
                        Ept2.y = eyes[i].y + eyes[i].height;

                        rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
                     }
                   } 
                   Point cen_rec(faces[ib].x + faces[ib].width / 2, faces[ib].y + faces[ib].height / 2);
             circle(frame, cen_rec, 1, Scalar(0, 0, 255), CV_FILLED); //Marks the center of detected face.                                          

  // Show image
Output text
                sstm << "Crop area size: " << faces[ib].width << "x" << faces[ib].height << " Size of window: " << frame.size().width << '*' << frame.size().height;
             text = sstm.str();
             putText(frame, text, cvPoint(30, 30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
             sstm.clear();
             sstm.str(string());

             double percentage;
             percentage = ((double)ab) / (frame.size().width * frame.size().height) * 100;
             sstm << "Percentage: " << percentage << " Tilt: " << (cen_rec.y - cen_win.y)/10 << " Pan: " << (cen_rec.x - cen_win.x) / 10;
             text = sstm.str();
             putText(frame, text, cvPoint(30, 50), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
             sstm.clear();
             sstm.str(string());
          } 
      namedWindow("original", WINDOW_NORMAL);
     setMouseCallback("original", CallBackFunc, NULL);
     imshow("original", frame);   

    if (!crop.empty())
        {
            imshow("detected", crop);
 
    else
           destroyWindow("detected");
}
        else
            destroyWindow("detected");

         }

     void CallBackFunc(int event, int x, int y, int flags, void * userdata)
     {
         if (event == EVENT_LBUTTONDOWN)
        {
            cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
         else if (event == EVENT_RBUTTONDOWN)
        {
            cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
         else if (event == EVENT_MBUTTONDOWN)
        {
            cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;
        }
         /*else if (event == EVENT_MOUSEMOVE)
         {
         cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;
          }*/
 }

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

Console screen

What should I do now to understand why the program keeps crashing?

Program crashes giving unhelpful exit codes

I'm building a face and eye detecting program using OpenCV 3.1 using Visual Studio 2015. I've changed the sample code provided to suit my purposes. The function definition is given below.

      #include "opencv2/objdetect/objdetect.hpp"
      #include "opencv2/highgui/highgui.hpp"
      #include "opencv2/imgproc/imgproc.hpp"

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

      using namespace std;
      using namespace cv;

      // Function Headers
      void detectAndDisplay(Mat frame);
      void CallBackFunc(int event, int x, int y, int flags, void* userdata);

      // Global variable
      string face_cascade_name = "haarcascade_frontalface_alt.xml";
      CascadeClassifier face_cascade;
      string eye_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
      CascadeClassifier eye_cascade;

      string window_name = "Capture - Face detection";

  // Function main
      int main(void)
            {
                VideoCapture capture(0);

                if (!capture.isOpened())  // check if we succeeded
                    return -1;

                // Load the cascade
cascades
                if (!face_cascade.load(face_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }
                if (!eye_cascade.load(eye_cascade_name)){ printf("--(!)Error loading\n"); return (-1); }

                // Read the video stream
                Mat frame;

                for (;;)
                {
                    capture >> frame;

                    // Apply the classifier to the frame
                    if (!frame.empty())
                        detectAndDisplay(frame);

                    else
                    {
                        printf(" --(!) No captured frame -- Break!");
                        break;
                    }

                    int c = waitKey(10);

                    if (27 == char(c))
                        break;
                }

                return 0;
            }

void detectAndDisplay(Mat frame)
{
   std::vector<Rect> faces, eyes;

   Mat frame_gray, crop, gray;
   string text; 
   stringstream sstm;          

   cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
   equalizeHist(frame_gray, frame_gray);

    // Detect faces and eyes
     face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(40, 40));

    Point cen_win(frame.size().width / 2, frame.size().height / 2);
    circle(frame, cen_win, 1, Scalar(0, 0, 255), CV_FILLED);

    size_t ic = 0; // ic is index of current element
    unsigned long ac = 0; // ac is area of current element

    size_t ib = 0; // ib is index of biggest element
    unsigned long ab = 0; // ab is area of biggest element

     for (ic = 0; ic < faces.size(); ic++) // Iterate through all current elements (detected faces)
detected faces
           {
                ac = faces[ic].area();
                ab = faces[ib].area();

                if (ac > ab)
                    ib = ic; 
           }

      if(faces.size())
          {
               Point pt1(faces[ib].x, faces[ib].y);
               Point pt2((faces[ib].x + faces[ib].width), (faces[ib].y + faces[ib].height));
               rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0); //Coords pt1 are of left corner.
 
               crop = frame(faces[ib]);
               cvtColor(crop, gray, COLOR_BGR2GRAY);
               equalizeHist(gray, gray);
               eye_cascade.detectMultiScale(gray, eyes, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(10, 10));


               if(eyes.size())  
                      {
                           Point Ept1, Ept2;        

                           for (int i = 0; i < eyes.size(); ++i)
                             {
                              Ept1.x = eyes[i].x; 
                              Ept1.y = eyes[i].y;

                                  Ept2.x = eyes[i].x + eyes[i].width; 
                              Ept2.y = eyes[i].y + eyes[i].height;

                              rectangle(frame, Ept1, Ept2, Scalar(0, 255, 0), 2, 8, 0);
                                }
                       } 

                 Point cen_rec(faces[ib].x + faces[ib].width / 2, faces[ib].y + faces[ib].height / 2);
                 circle(frame, cen_rec, 1, Scalar(0, 0, 255), CV_FILLED); //Marks the center of detected face.                                          

                // Output text
                sstm << "Crop area size: " << faces[ib].width << "x" << faces[ib].height << " Size of window: " << frame.size().width << '*' << frame.size().height;
                text = sstm.str();
                putText(frame, text, cvPoint(30, 30), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
                sstm.clear();
                sstm.str(string());

                double percentage;
                percentage = ((double)ab) / (frame.size().width * frame.size().height) * 100;
                sstm << "Percentage: " << percentage << " Tilt: " << (cen_rec.y - cen_win.y)/10 << " Pan: " << (cen_rec.x - cen_win.x) / 10;
                text = sstm.str();
                putText(frame, text, cvPoint(30, 50), FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(0, 0, 255), 1, CV_AA);
                sstm.clear();
                sstm.str(string());
         } 

    namedWindow("original", WINDOW_NORMAL);
    setMouseCallback("original", CallBackFunc, NULL);
    imshow("original", frame);  

    if (!crop.empty())
           imshow("detected", crop);

    else
           destroyWindow("detected");
}

void CallBackFunc(int event, int x, int y, int flags, void * userdata)
      {
           if (event == EVENT_LBUTTONDOWN)
                cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

           else if (event == EVENT_RBUTTONDOWN)
               cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

           else if (event == EVENT_MBUTTONDOWN)
              cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

            /*else if (event == EVENT_MOUSEMOVE)
            {
            cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;
            }*/
}

The cascades load and are located in the source folder. The program worked fine before I added the eye detection feature.

Now the following happens every time I start debugging the code: Video Capture begins and in less than a second the screen freezes, rendering the program unresponsive. No features have been detected by the program at this point.

Closing the console window turns the whole screen blank for a moment. However of note are the exit codes of the program. There is no other information that I have that I could possibly use to understand what is going wrong.

The thread 0x2f54 has exited with code 0 (0x0).
The thread 0x2a5c has exited with code 0 (0x0).
The thread 0x850 has exited with code 0 (0x0).
The thread 0x2a14 has exited with code -1073741510 (0xc000013a).
The thread 0x21e0 has exited with code -1073741510 (0xc000013a).
The thread 0xbe4 has exited with code -1073741510 (0xc000013a).
The thread 0x338c has exited with code -1073741510 (0xc000013a).
The thread 0x16ac has exited with code -1073741510 (0xc000013a).
The thread 0x26a8 has exited with code -1073741510 (0xc000013a).
The thread 0x2a54 has exited with code -1073741510 (0xc000013a).
The thread 0x1e14 has exited with code -1073741510 (0xc000013a).
The thread 0x2f60 has exited with code -1073741510 (0xc000013a).
The thread 0x2594 has exited with code -1073741510 (0xc000013a).
The thread 0x26a0 has exited with code -1073741510 (0xc000013a).
The thread 0x2be4 has exited with code -1073741510 (0xc000013a).
The thread 0x11c has exited with code -1073741510 (0xc000013a).

Console screen

What should I do now to understand why the program keeps crashing?