Ask Your Question
1

shapes and hierarchy

asked 2014-10-11 05:10:40 -0600

Kimi gravatar image

updated 2014-10-16 13:14:07 -0600

I have four shapes. They are inside each other so the first is contains the second and the second contains the third etc. How can I choose the fourth and third shapes usin hierarchy? (opencv,python)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2014-10-11 06:00:49 -0600

Have you had a look at this docu:

http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.html

If h is your hierachy and x is the id of your topmost shape, then y = h[x][2] is the first child and z = h[y][2] is the third level. Another shape on this level is z_1 = h[z][0] or z_2 = h[z_1][0] (and so on until z_i is -1).

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-11 05:10:40 -0600

Seen: 284 times

Last updated: Oct 16 '14