cv_retr_list,cv_retr_tree,cv_retr_external之间的区别?[英] difference between CV_RETR_LIST,CV_RETR_TREE,CV_RETR_EXTERNAL?

本文是小编为大家收集整理的关于cv_retr_list,cv_retr_tree,cv_retr_external之间的区别?的处理方法,想解了cv_retr_list,cv_retr_tree,cv_retr_external之间的区别?的问题怎么解决?cv_retr_list,cv_retr_tree,cv_retr_external之间的区别?问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我正在使用openCV的cvfindContour函数,其中有一个参数ret_type表示retrivel类型,因此我没有得到CV_RETR_LIST,CV_RETR_TREE,CV_RETR_TREE,CV_RETR_EXTERNAL?

之间有什么区别

推荐答案

.

主要区别在于返回的hierarchy(给出一个轮廓和下一个轮廓之间的关系).

  • CV_RETR_EXTERNAL给出"外部"轮廓,因此,如果您有(说)一个轮廓包含另一个轮廓(如同心圆),则只给出了最外面的.
  • CV_RETR_LIST给出了所有轮廓,甚至不费心计算hierarchy - 如果您只想要轮廓并且不在乎一个人是否嵌套在另一个轮廓.
  • CV_RETR_CCOMP给出轮廓并将其组织成外部和内部轮廓.每个轮廓要么是对象的轮廓,要么是内部对象的轮廓另一个对象(即孔).相应地调整hierarchy.如果(说)您想找到所有孔.
  • CV_RETR_TREE计算轮廓的完整层次结构.因此,您可以说Object1在Object2中嵌套了4个级别,并且Object3也嵌套了4个级别.

其他推荐答案

来自imgproc.cpp:

//! mode of the contour retrieval algorithm
enum RetrievalModes {
    /** retrieves only the extreme outer contours. It sets `hierarchy[i][2]=hierarchy[i][3]=-1` for
    all the contours. */
    RETR_EXTERNAL  = 0,
    /** retrieves all of the contours without establishing any hierarchical relationships. */
    RETR_LIST      = 1,
    /** retrieves all of the contours and organizes them into a two-level hierarchy. At the top
    level, there are external boundaries of the components. At the second level, there are
    boundaries of the holes. If there is another contour inside a hole of a connected component, it
    is still put at the top level. */
    RETR_CCOMP     = 2,
    /** retrieves all of the contours and reconstructs a full hierarchy of nested contours.*/
    RETR_TREE      = 3,
    RETR_FLOODFILL = 4 //!<
};

opencv 2.4.13

本文地址:https://www.itbaoku.cn/post/359082.html