Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can do that using the vector size. The output of findContours is stored in a vector, use iterators to loop on it and get the size. I am using opencv2.4

cv::findContours(inImg, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
std::vector<std::vector<cv::Point> >::iterator iteratorContours = contours.begin(); 
while (iteratorContours != contours.end()) {
cout << iteratorContours.size();
}