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
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!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With