这里是OpenCV的新功能。我试图了解应该包含什么层次 vector 。我知道对于对象跟踪以及使用findCountours函数时,通常使用vector,但是我想了解这意味着什么。先谢谢您的帮助!
最佳答案
轮廓是围绕图像区域的闭合边缘。该轮廓可能包含轮廓,因此我们需要一种存储此层次结构的方法。层次 vector 包含所有信息,以解释轮廓如何彼此嵌套。
在OpenCV documentation中,它是一个
Optional output vector, containing information about the image topology. It has as many elements as the number of contours. For each i-th contour contours[i] , the elements hierarchy[i][0] , hiearchy[i][1] , hiearchy[i][2] , and hiearchy[i][3] are set to 0-based indices in contours of the next and previous contours at the same hierarchical level, the first child contour and the parent contour, respectively. If for the contour i there are no next, previous, parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
您可以将其视为双向链接列表,但是列表中的每个项目都可能指向父级和/或子级。我们可以使用下一个和上一个索引找到所有具有相同父级的轮廓。如果每个轮廓都包含一个子轮廓,则它们将指向一个子链接列表。负值与传统链表的
NULL
指针相同。An example:
a
|
b,c,d,e,f
| |
g h,i
a
是一个 child ,它指向b
,从b
中我们知道b
,c
,d
,e
和f
都包含在a
中的同一级别上。 b
也有一个子轮廓g
。 e
也有两个 child 。
关于opencv - 了解OpenCV层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22834456/