title: C++ OpenCV sort contour hierarchy by level
body: <p>I have a contour (RETR_TREE). I do understand, that I have a tree of contours denoted by the array </p>
  
  <pre><code>hierarchy[][4]
  </code></pre>
  
  <p>Structure is [Next, Previous, First_Child, Parent] </p>
  
  <p>(<a href="http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.html" rel="nofollow">http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.html</a>)</p>
  
  <p>My problem is to get the level of the current contour. I want to know the level. I have absolute no idea how to get this level from the parent, child, next or previous contour.</p>
  
  <p>Can anyone provide code to get the level of the contour in the tree?</p>
  
  <p>Thank you very much</p>