Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get number of contours

I would like to determine the number of white areas in this picture. I tried this with the findContours function to solve where all surfaces are detected but i dont know how to get the number of all contours. I thought the number is in the hierarchy but the size of hierarchy is only 24 and there are 33 contours in the image.

This is the code is used:

vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours( image, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);

image description