findContours 是 opencv 下的轮廓提取函数。

1. api 分析

findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
  • image,一般为单通道图像;
  • mode:轮廓检索模式(retrieve)
    • cv2.RETR_EXTERNAL,只检测外部轮廓,也即对所有轮廓hierarchy[i][2] == hierarchy[i][3] == -1
      • hierarchy[i],一级索引指的是全部检索到的轮廓,轮廓由四个元素构成的元组组成,
    • cv2.RETR_LIST:提取所有轮廓,并放置在 list 中,对检测到的轮廓不建立等级关系;
    • cv2.RETR_TREE:提取所有轮廓,建立网状的轮廓结构;
  • method:轮廓的近似方法,是提取轮廓上所有的像素点,还是一些关键点。
    • 如对于一条线段是提取所有点,还是仅提取两个端点;
  • contours:检索到的轮廓,为构成轮廓的点集;

2. 轮廓的层次结构

相关文章:

  • 2021-09-14
  • 2021-07-11
  • 2021-11-18
  • 2021-04-05
猜你喜欢
  • 2021-10-03
  • 2021-04-10
  • 2022-12-23
  • 2021-12-09
  • 2021-05-18
相关资源
相似解决方案