So finaly I use bounding boxes for filtering, but still many countours pass - Im not sure how get only countour with two child countours - holes (eyes) to eliminate others.
List<Mat> contours = new ArrayList<Mat>(10);
Mat hierarchy = new Mat(20,20,CvType.CV_32SC2, new Scalar(0));
Imgproc.findContours(mDiff.submat(eyearea),contours, hierarchy, Imgproc.RETR_CCOMP,Imgproc.CHAIN_APPROX_SIMPLE);
int hierarchy_buff_size = (int) (hierarchy.total() * hierarchy.channels());
int iBuff[] = new int[hierarchy_buff_size];
hierarchy.get(0, 0, iBuff);
dump is eg.
Hierarchy = [1, -1, -1, -1, 2, 0, -1, -1, 3, 1, -1, -1, 4, 2, -1, -1, 5, 3, -1, -1, 6, 4, -1, -1, 7, 5, -1, -1, -1, 6, -1, -1]
So contoure in index 4 has 2 holes - childs?
And I could get it via contours.get(4) is the index same? How to get the holes?
hierarchy.get(0, 0, iBuff); - this is for top levels contours right? and for second level hierarchy.get(0,1, iBuff); ?
Thanks
Roman
Dne úterý, 27. března 2012 0:45:32 UTC+2 Rui Marques napsal(a):