Ask Your Question
0

Program crashes during findContours() execution

asked 2012-11-18 05:11:49 -0600

Crash gravatar image

updated 2012-11-18 07:14:45 -0600

Hello guys

I got a problem with finding contours in the image. I'm trying to run a simple example on VS 2012 from the official site(http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html)

But the program always crashes with the following error:

OpenCV Error: Assertion failed (0 <= contourIdx && contourIdx < (int)last) in un known function, file ......\src\opencv\modules\imgproc\src\contours.cpp, line 1810

I've tried different modes CV_RETR_TREE,CV_RETR_LIST,CV_RETR_CCOMP but in vain.

I've also tried the sample from opencv/samples/cpp/connected_components.cpp, but always got another kind of mistake:

OpenCV Error: Unsupported format or combination of formats ([Start]FindContours support only 8uC1 and 32sC1 images) in unknown function, file ......\src\openc v\modules\imgproc\src\contours.cpp, line 196

I checked my code many times and red all manuals I'd found...all suggested samples are almost the same I begin to suppose the problem might consist into Visual Studio 2012 Also I noticed that all official samples run on Linux I use OpenCV version 2.4.3

Any ideas?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2012-11-18 12:57:19 -0600

Crash gravatar image

updated 2012-11-18 12:59:01 -0600

Problem has been solved I decided to come back to VS 2010 and all work fine now without any mistakes( damn Microsoft) VS 2012 is a piece of raw crap

edit flag offensive delete link more

Comments

1

Thanks for providing this enlightening insight.

SR gravatar imageSR ( 2012-11-19 01:48:47 -0600 )edit
0

answered 2012-11-18 07:00:46 -0600

Michael Burdinov gravatar image

Are you completely sure that your image is gray level image with one channel, and your contours is vector of vector of Point and not Point2d or anything like that?

edit flag offensive delete link more

Comments

If you see the example there is a function cvtColor( src, src_gray, CV_BGR2GRAY ); It converts images to the gray color I've tried different images, but the result is always the same. The simpliest way I tried in brouser right click->save image->then attempt to open it via opencv...and program craches.

Crash gravatar imageCrash ( 2012-11-18 07:09:38 -0600 )edit

Even if findContours is the function that crushed it doesn't mean that it is the one responsible for crash. Problem may start from any function before that. So I recommend you not to trust that everything was ok, but to put some 'if' statement before findContours just to be sure that input image is indeed CV_8UC1. From what I see in second error you posted this is not the case.

Michael Burdinov gravatar imageMichael Burdinov ( 2012-11-18 07:34:16 -0600 )edit
0

answered 2013-06-29 17:29:05 -0600

burakim gravatar image

You should check your Contour idx number. Try replace with zero ?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-18 05:11:49 -0600

Seen: 4,765 times

Last updated: Jun 29 '13