Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Use contour retrieval mode CV_RETR_TREE which will retrieves all of the contours and reconstructs a full hierarchy of nested contours.

Imgproc.findContours(canny, contours, hierarchy, Imgproc.CV_RETR_TREE,
                     Imgproc.CHAIN_APPROX_SIMPLE);

Also draw contours in a loop like

for( int i = 0; i< contours.size(); i++ ) 
   Imgproc.drawContours(canny, contours, i, new Scalar(255), -1, 8, hierarchy, 2, new Point(0, 0));

and still if there are some issue let me know...