Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to extract only top-level contours?

When using findContours to identify blobs, is there a way to ignore any contours present within another contour. I only need to count the number of contours that are the outermost using contours.size();

I looked into this and found the RETR_EXTERNAL parameter instead of the RETR_LIST, is this enough? Or do I have to do anything with the hierarchy Mat object (third parameter)?