![]() So each contour has its own information regarding what hierarchy it is, who is its child, who is its parent etc. I mentioned these things to understand terms like same hierarchy level, external contour, child contour, parent contour, first child etc. From the way I numbered the boxes, I would say contour-4 is the first child of contour-3a (It can be contour-5 also). Finally contours 4,5 are the children of contour-3a, and they come in the last hierarchy level. Similarly contour-3 is child of contour-2 and it comes in next hierarchy. It can be considered as a child of contour-2 (or in opposite way, contour-2 is parent of contour-2a). We can say, they are in hierarchy-0 or simply they are in same hierarchy level. Here, contours 0,1,2 are external or outermost. 2 and 2a denotes the external and internal contours of the outermost box. In this image, there are a few shapes which I have numbered from 0-5. Representation of this relationship is called the Hierarchy. And we can specify how one contour is connected to each other, like, is it child of some other contour, or is it a parent etc. This way, contours in an image has some relationship to each other. In this case, we call outer one as parent and inner one as child. But in some cases, some shapes are inside other shapes. Normally we use the cv.findContours() function to detect objects in an image, right ? Sometimes objects are in different locations. That is what we are going to deal in this article. Then what is this hierarchy and what is it for ? What is its relationship with the previous mentioned function argument ? But we never used this hierarchy anywhere. ![]() But what does it actually mean ?Īlso, in the output, we got three arrays, first is the image, second is our contours, and one more output which we named as hierarchy (Please checkout the codes in previous articles). We usually passed cv.RETR_LIST or cv.RETR_TREE and it worked nice. But when we found the contours in image using cv.findContours() function, we have passed an argument, Contour Retrieval Mode. In the last few articles on contours, we have worked with several functions related to contours provided by OpenCV. the parent-child relationship in Contours. This time, we learn about the hierarchy of contours, i.e. Prev Tutorial: Contours : More Functions Goal
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |