在处理二值图像时,常用 cv2.findContours 查找轮廓,如下所示:
# find all cohntours
contours,hierarchy=cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
binary 代表二值图像;
之后可以用lambda 表达式对 contours 排序,如下所示:
contours.sort(key=lambda c: cv2.contourArea
在处理二值图像时,常用 cv2.findContours 查找轮廓,如下所示:
# find all cohntours
contours,hierarchy=cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
binary 代表二值图像;
之后可以用lambda 表达式对 contours 排序,如下所示:
contours.sort(key=lambda c: cv2.contourArea