我正在将Python OpenCV代码转换为Emgu。
在Python中,函数findContours
可以返回hierarchy
hierarchy – 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.
不幸的是,在Emgu中,我无法为
findContours
函数返回这样的数组。
最佳答案
如果选择CV_RETR_TREE
作为检索类型,则返回的Contour<Point>
将包含分层树结构。
这张来自here的图片显示了如何使用OpenCV中的h_next
和v_next
指针(即Emgu CV中的HNext
和VNext
)在层次结构中进行导航。
这样,您可以获得整个层次结构。
关于opencv - 等效于emgu中的层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15555615/