Ask Your Question

Revision history [back]

FindContours() causing heap corruption on VS2013?

Hey fellow forum-goers,

I ran into some trouble with FindContours() in OpenCV 3.0 and OpenCV 3.1 using Visual Studio 2013. At first I assumed I am at fault (and I'm not entirely unsure that I've not messed up somewhere still), but I'm slowly beginning to wonder if perhaps FindContours() actually does cause heap corruption?

The following straight forward code seems to cause heap corruption for me:

std::vector<std::vector<cv::Point> > contours;
cv::Mat inp( cv::Size( 400, 400 ), CV_8UC1 );
cv::findContours( inp, contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE );

I use Cinder at a framework for lots of my coding, but given its robust history, I'd be surprised if anything in an empty skeleton setup would interfere with the OpenCV code I've posted above. This code run on its own causes this error in Vs2013:

Debug Assertion Failed!

Program: D:\Code\FindContoursTest\vc2013\x64\Debug\FindContoursTest.exe
File: f:\dd\vctools\crt\crtw32\misc\dbgheap.c
Line: 1424

Expression: _pFirstBlock == pHead

I've found numerous posts regarding the use (or rather misuse) of OpenCV, and perhaps something is bad with the code above, but as far as I've been able to ascertain, it certainly shouldn't cause any heap corruption. I came across this post by lowlander256 who claims that it is indeed an issue in OpenCV.

Perhaps someone can help me at least figure out if the isolated code above should run fine?

Regards,

Gazoo