findContour crashes despite image being CV_8UC1

asked 2012-12-10 07:22:51 -0500

Rex gravatar image

updated 2012-12-10 07:24:09 -0500

Vladislav Vinogradov gravatar image


the tutorial code for finding contours crashes on the method findContours.

I have almost coppied the code exactly and played with the parameters, checked the code according to the reference manual.

As far as I can tell I am not overlooking something. Is the method findContours known to be broken?

I have seen the previsou posts on this but they seem to point to the image not being CV_8UC1 which in my case is checked for.

See code below for what I am attempting:

//If already GrayScale
    QMessageBox::information(0,"ProcessImage","Image is not grayscale, bailing");

RNG rng(12345); //Random number

Mat canny_output;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
/// Detect edges using canny

blur(CurrentMat,CurrentMat, Size(3,3)); //Does not really help
//Canny( CurrentMat, canny_output, thresh, thresh*15, 3 );

/// Find contours
findContours( CurrentMat, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
edit retag flag offensive close merge delete


I had a similar problem using Haar cascade for face detection. It worked in release mode and crash for debug.

I was linking to dll binaries compiled in advance. One option that I am trying now is to download the source and compile it my self. This way I can ensure there are no compatibility issues.

The other quick and dirty option was to link to the release dlls but set the options for my project to enable debug.

It solved the problem for haarcascade perhaps it will help you for findContours?

Y Simson gravatar imageY Simson ( 2014-05-10 09:28:08 -0500 )edit