I am using 2.4.3 version of opencv, and trying to use "findContours" function after canny edge detection like this:
struct Component
{
cv::Rect boundingBox;
double area;
double circularity;
}
cv::vector < Component > components;
cv::vector < cv::Vec4i > hierarchy;
cv::findContours ( cannyEdges, components, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_NONE);
Then it throws an error for line line "cv::findContours" like this:
OpenCV Error: Assertion failed (mtype == type0 || ( CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1((type0) & fixedDepthMask) != 0 )) in unknown function, file ...\opencv\modeuls\core\src\matrix.cpp, line 1421
How can I solve this?
cv::findcontours returns every contour as a vector of points (see http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#findcontours).
You have to convert these vectors to your data structure (Component) by yourself like in this minimal example I created: