Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

Kien Huynh's profile - activity

2018-11-22 11:55:30 -0500 received badge  Popular Question (source)
2015-12-30 10:48:15 -0500 received badge  Student (source)
2014-06-26 10:18:08 -0500 commented question Problem with findContours and drawContours

Well, I don't know why but I tested the same code with the same image on my friends computer, it works perfectly fine. The entire source code was what I posted in the question excluding the necessary headers, and the image board.jpg was in the opencv sample folder: sources\samples\cpp\board.jpg

2014-06-26 01:28:02 -0500 commented question Problem with findContours and drawContours

Yes, those values were from the debug code, but the release code returned the same values. You meant the JIT optimization of debug mode? Yes it was suppressed.

2014-06-25 12:28:06 -0500 asked a question Problem with findContours and drawContours

Hi, I'm new to OpenCV, I was trying to run this simple code to find the contours of an image:

int main( int argc, char** argv )
    cv::Mat immat = cv::imread("board.jpg", 1);
    cv::Mat img;
    cv::cvtColor(immat, img, CV_BGR2GRAY);

    cv::Mat imcanny;
    cv::Canny (img,imcanny,75,150,3);

    std::vector<std::vector<cv::Point> > contours;

    std::cout << "found " << contours.size() << " contours\n";
    cv::imwrite("contours.png", immat);
    return 0;

But there was something strange about the output of the contours, it looks like this when I checked it: image description

There are a lot of contours with an extremely huge size and all of their points are {x=??? y=???}. Is this normal output for findcontours function?

Not only that, when I execute the program (release mode) to the end of the main function, I got two messages "myproject has triggered a breakpoint", after I pressed continue on both of them, I got "A heap has been corrupted" exception. While in debug mode, I got a Debug Assertion Failed: _CrtIsValidHeapPointer(pUserData). Everything else works fine if I comment the findContours and drawContours lines.

How can I solve this problem? For more information, I was using VS2012 and OpenCV 2.49.