Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Android findContours returning too many contours

$
0
0
Hello, I'm trying to find the contours of the camera frame in a Android app. Here is the code: Imgproc.Canny(src, src, 50, 200); List contours = new ArrayList(); Mat hierarchy = new Mat(); // find contours: Imgproc.findContours(src, contours, hierarchy, Imgproc.RETR_TREE,Imgproc.CHAIN_APPROX_SIMPLE); for (int contourIdx = 0; contourIdx < contours.size(); contourIdx++) { Imgproc.drawContours(src, contours, contourIdx, new Scalar(0, 0, 255), -1); } Here is an example of frame: ![image description](/upfiles/1475267902879689.png) It's working but my problem is that findContour is returning too many contours. Sometimes it returns more than 3000 contours and it takes too much time to draw them. In the frame there is a person. I would like to get only one contour with the person instead of many of them in each line of the face. Is there a way to approximate the little contours in a only one with the whole object? I'm looking for a way to reduce the number of contours, getting only the biggest of them. Any tip will be very helpful, Thanks

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>