Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

calling findcontours throws an exception...

$
0
0
Hi, I'm new to opencv, trying my hand at image tracking using OpenCV 3.0 and Visual Studio version 12.0.31101.00 Update 4 (2013). I am using code from this tutorial: https://youtu.be/X6rPdRZzgjg (I'd link directly to the code in dropbox but youtube is playing games w/the URLs.) ...which is (likely) intended for an older version of OpenCV & Visual Studio. But, after altering the project's variables and the program's include and using lines, the code compiles and successfully calls many OpenCV methods. Including "cvtColor", "absdiff", "threshold" and "blur". Unfortunately, the program throws an exception when "findContours" is called. When checking the "findContours" arguments, I see where the 3rd variable (usually referred to as "hierarchy") is abnormally large (19 decimal digits long) in size. After reading some posts, I tried switching from calling the "threshold" method to calling the "Canny" method when preparing the image for the "findContours" method. But the program still threw the exception. I have even tried completely different videos. The calls to the other methods worked (pressing "d" while the program runs displays the intermediate images verifying this). But the "findContours" method (pressing "t" while the program runs allows calls to the "findContours" method) still threw the exception. It is not a very long program. I'll try and insert my version of code here: (Wow, including code using this web/interface/editor is really difficult! The editor keeps breaking it up with (kind-of) normal text.) (Sorry, it doesn't appear I can drop in all the code w/o this editor chopping it up. I'll try to drop in only the important bits then.) This is the bit of code that prepare the image for the call to the "findContours" method. The calls to "imshow" verify these methods are working as expected. Notice I tried to replace a call to the "threshold" method with a call to the "Canny" method as an attempt to avoid the exception when calling the "findContours" method. The call to the "findContours" method is inside the "searchForMovement" method called at the end of this section of code: while (capture.get(CV_CAP_PROP_POS_FRAMES)> contours; vector hierarchy; //find contours of filtered image using openCV findContours function // findContours(temp,contours,hierarchy,CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE );// retrieves all contours findContours(temp, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);// retrieves external contours // findContours(temp, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);// retrieves external contours // findContours(temp, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); //if contours vector is not empty, we have found some objects if (contours.size()>0)objectDetected = true; else objectDetected = false; Any ideas as to what to try next would be appreciated. -thanks

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>