Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV findContours function problem

I am trying to use the findContours function in OpenCV, but VS 2008 gives an error saying:

OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupport ed array type) in unknown function, file ........\ocv\opencv\src\cxcore\cxarr ay.cpp, line 2476

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Press any key to continue . . .

Here's the code:

Mat_<Vec<float,3>> originalimage;

Mat_<Vec<float,3>> resultingimage;

vector<vector<cv::Point>> v;

originalimage = cv::imread("Original.ppm");

cv::findContours(originalimage,v,CV_RETR_LIST,CV_CHAIN_APPROX_NONE);

Thanks in advance

like image 411
user123668 Avatar asked Jun 21 '10 19:06

user123668


1 Answers

FindContours only accepts binary image. That is , any image which is output of cvThreshold cvAdapiveThreshold cvCanny

try adding this statement before cv::findContours

cvThreshold(originalImage,resultingImage,100,100,CV_THRESH_BINARY) 

then call findcontours with resultingImage.

if it works then you should input the correct parameters to cvThreshold ( 100 is just an example).Check the reference for that matter.

EDIT: resultingImage should be a single channel image!!

like image 151
dnul Avatar answered Sep 29 '22 13:09

dnul