Ask Your Question

Myproject.exe has triggered a breakpoint.

asked 2015-10-22 07:03:17 -0600

Mehdi.Am gravatar image

updated 2015-10-22 07:25:46 -0600

Hi guys

When I compile my code I face this error:

kooh1.exe has triggered a breakpoint.

, I don't know exactly what the problem is! maybe the size of the array caused this error:

here is a part of my code:(when it detects a face this error appears)

if (!frame.empty()){

            //clone from original frame
            original = frame.clone();

            //convert image to gray scale and equalize
            cvtColor(original, graySacleFrame, CV_BGR2GRAY);
            //equalizeHist(graySacleFrame, graySacleFrame);

            //detect face in gray image
            face_cascade.detectMultiScale(graySacleFrame, faces, 1.1, 3, 0, cv::Size(90, 90));

            //number of faces detected
            cout << faces.size() << " faces detected" << endl;
            std::string frameset = std::to_string(count);
            std::string faceset = std::to_string(faces.size());

            int width = 0, height = 0;

            //region of interest
            //cv::Rect roi;

            //person name
            string Pname = "";

            for (int i = 0; i < faces.size(); i++)
                //region of interest
                Rect face_i = faces[i];

                //crop the roi from grya image
                Mat face = graySacleFrame(face_i);

                //resizing the cropped image to suit to database image sizes
                Mat face_resized;
                cv::resize(face, face_resized, Size(img_width, img_height), 1.0, 1.0, INTER_CUBIC);

                //recognizing what faces detected
                int label = -1; double confidence = 0;
                model->predict(face_resized, label, confidence);

                cout << " confidencde " << confidence << endl;

                //drawing green rectagle in recognize face
                rectangle(original, face_i, CV_RGB(0, 255, 0), 1);
                string text = "Detected";
                if (label == 40){
                    //string text = format("Person is  = %d", label);
                    Pname = "gihan";
                    Pname = "unknown";

                int pos_x = std::max( - 10, 0);
                int pos_y = std::max( - 10, 0);

                //name the person who is in the image
                putText(original, text, Point(pos_x, pos_y), FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
                //cv::imwrite("E:/FDB/"+frameset+".jpg", cropImg);


            putText(original, "Frames: " + frameset, Point(30, 60), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
            putText(original, "Person: " + Pname, Point(30, 90), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
            //display to the winodw
            cv::imshow(window, original);

            //cout << "model infor " << model->getDouble("threshold") << endl;

        if (waitKey(10) >= 0) cout<<"hi"<<endl;

edit retag flag offensive close merge delete



A breakpoint is not an error! Its a place where you halt the execution of your code to inspect what it is doing and in what state all variables are at that moment. Make sure that you did not place one yourself, in most IDE environments, this is seen as a red dot marked in front of a line ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-22 07:52:45 -0600 )edit

@StevenPuttemans don't you think that it's devoted to array size?

Mehdi.Am gravatar imageMehdi.Am ( 2015-10-22 08:07:06 -0600 )edit

@StevenPuttemans I have to say that Visual Studio sometimes shows errors as "myprogram.exe has triggered a breakpoint". I think it's due to compiler options, but in any case it's not due to an explicit manual breakpoint.

LorenaGdL gravatar imageLorenaGdL ( 2015-10-22 08:20:12 -0600 )edit

@Mehdi.Am you should carefully debug your program and see what exact line throws the error

LorenaGdL gravatar imageLorenaGdL ( 2015-10-22 08:21:22 -0600 )edit

@LorenaGdL, did not know that! Could this mean some assert was generated?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-22 08:36:03 -0600 )edit

@StevenPuttemans I don't know, to be honest. I haven't still discovered why those weird triggered a breakpoint messages appear. Usually, CV_ASSERT errors show as normal exceptions. I suspect they point out memory/heap errors, but just a guess

LorenaGdL gravatar imageLorenaGdL ( 2015-10-22 08:41:12 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-10-22 08:47:24 -0600

updated 2015-10-22 08:51:55 -0600

Some explanation I have found

It is a very nice feature of the Windows heap allocator, available since Vista. It tells you that your code has a pointer bug. The actual cause ranges somewhere between mild, like trying to free memory that was already freed or allocated from another heap. Not uncommon when you interop with another program. To drastically nasty like having blown the heap to pieces earlier by overflowing a heap allocated buffer.

So lets us check if you are somewhere accessing illegal pointers or unexisting data structure.

Auch - might have found something in this piece of code

//crop the roi from grya image
Mat face = graySacleFrame(face_i);

This is actually only grabbing a pointer to a part of an existing image in memory. So you will start working on a small part of your original image. I would suggest changing that for a starter to

//crop the roi from grya image
Mat face = graySacleFrame(face_i).clone();

to ensure already that you have a local copy for your further processing!

Seems the only thing with pointers which is not correct that I could find!

edit flag offensive delete link more



Nice catch!

LorenaGdL gravatar imageLorenaGdL ( 2015-10-22 08:51:22 -0600 )edit

I can confirm that "...has triggered a breakpoint" messages from VisualStudio is related to some issue with memory management

pklab gravatar imagepklab ( 2015-10-24 05:41:29 -0600 )edit

Question Tools

1 follower


Asked: 2015-10-22 07:03:17 -0600

Seen: 5,467 times

Last updated: Oct 22 '15