How to fix a Heap Error when using findContours

asked 2016-01-27 02:34:53 -0500

cv_new gravatar image

updated 2016-01-27 02:35:15 -0500

After surfing on the internet, I still cannot fix the following error when using the findContours function.

image description

My code is:

  char outputname[50];
Mat gray, ret, threshold_output;
int thresh = 230;
cvtColor(inImg, gray, CV_BGR2GRAY);
threshold(gray, ret, 0, 255, CV_THRESH_BINARY_INV + CV_THRESH_OTSU);    

vector<int> horcnt;
vector<Vec4i> hierarchy;
vector<vector<Point> > contours;

threshold(ret, threshold_output, thresh, 255, THRESH_BINARY);
findContours(threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));
edit retag flag offensive close merge delete


this is most likely a linker, not a compiler problem.

please check carefully, if you accidentally linked opencv release libs to debug build or vice versa, also check, if you're using the correct c-runtime (/MTd)

berak gravatar imageberak ( 2016-01-27 03:09:54 -0500 )edit

It failed when it procceed to the code at "~vector() _NOEXCEPT { // destroy the object _Tidy(); }". Do you know what the problem is? I now sure that I am implementing in (/MTd) mode and linked with the debug libs.

cv_new gravatar imagecv_new ( 2016-01-27 04:06:18 -0500 )edit