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:

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
↧