Ask Your Question

I have problem with function Find Contours! what could be the problem?

asked 2015-12-01 01:08:29 -0500

MValeriy gravatar image

I have very simple code. Upload an image and find a contour there. it should be so, but does not go

Code `

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include <iostream>
using namespace cv;
using namespace std;
        /// Global Variables
        Scalar color = Scalar(0,0,255);
int main(int argc, char** argv)
 Mat src;
src = imread("11.jpg");
        return -1;
  Mat gray;
    cvtColor( src, gray, COLOR_BGR2GRAY );
    gray = gray > 127;
            // Find contours
            vector<vector<Point> > contours;
            vector<Point> contour;
            findContours( gray, contours, CV_RETR_TREE, CV_CHAIN_APPROX_NONE );
            for ( size_t i = 0; i < contours.size(); i++)
    imshow("gray", gray);
    imshow("src", src);
    return 0;

it showed me:

but if I ignore the side with find contour, which is displayed as normal picture me.

I work with opencv3.0.0 and VS12.

what could be the problem?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-12-01 02:50:28 -0500

pklab gravatar image

....exe has triggered a breakpoint message from VisualStudio is related to some issue with memory management. Read here.

In your case, the code is pretty simple so I suppose you have some issue with project like:

  • you are using inappropriate opencv binary version for your visual studio version (example: VS2012 -> ocv11, VS2013 -> ocv12, VS2015 -> your own OCV build )
  • you are mixing debug libs with release dlls (or reverse), or 32bit with 64bit
  • in the project properties "Multi-threaded Debug DLL (/MDd)" flag is off

After this, clean your project and retry

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-12-01 01:08:29 -0500

Seen: 971 times

Last updated: Dec 01 '15