Ask Your Question

Revision history [back]

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).