opencv - 了解OpenCV层次结构

标签 opencv hierarchy

这里是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中我们知道bcdef都包含在a中的同一级别上。 b也有一个子轮廓ge也有两个 child 。

关于opencv - 了解OpenCV层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22834456/

相关文章:

mysql - 在具有高写入负载的 MySQL 中存储分层数据

opencv - python 3.7版本下anaconda无法安装opencv

android - Android 项目中的 java.lang.ExceptionInInitializerError

python - 使用 Pyspark 从关系数据集构建层次结构

c# - 为层次结构中的实体获取父级

sql-server-2005 - 多父树(或有向图)实现sql server 2005

c++ - 如何在 Qt 4.8 (C++) 中使用 Video4Linux2 (v4l2) 在 OpenCV 2.4 中捕获视频?

opencv - 使用 OpenCV 去扭曲/校正图像

c++ - 为什么 openCV Mat.at 与原始矩阵不匹配

SQL - 对公共(public)表表达式进行排序