1.findContours
contours, hierarchy = cv.findContours( image, mode, method[, contours[, hierarchy[, offset]]] )
从二值化的图片中寻找轮廓
一个8位的单通道图片。非0的像素会被当成1处理,值为0的像素,仍然当成0处理,所以该图片是被当成二值图片来处理的。
参数 | 描述 |
---|---|
contours | 轮廓信息 |
hierarchy | 继承关系 |
image | 图片指针 |
mode | RetrievalModes |
method | ContourApproximationModes |
offset | 轮廓的偏移 |
mode | 描述 |
---|---|
cv.RETR_EXTERNAL | retrieves only the extreme outer contours. |
cv.RETR_LIST | retrieves all of the contours without establishing any hierarchical relationships. |
cv.RETR_CCOMP | retrieves all of the contours and organizes them into a two-level hierarchy. |
cv.RETR_TREE | retrieves all of the contours and reconstructs a full hierarchy of nested contours. |
cv.RETR_FLOODFILL |
method 主要是设置轮廓的显示模式,多点还是线
method | 描述 |
---|---|
CHAIN_APPROX_SIMPLE |
参考文献:
https://blog.csdn.net/sunny2038/article/details/12889059