首页 > 解决方案 > Opencv - 如何在 GaussianBlur 之后找到每个轮廓

问题描述

# GaussianBlur
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (7, 7), 0)
edged = cv2.Canny(gray, 50, 200)
edged = cv2.dilate(edged, None, iterations=1)
edged = cv2.erode(edged, None, iterations=1)

# find all Contour, 
cnts = cv2.findContours(edged.copy(), cv2.RETR_LIST,
                        cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
(cnts, _) = contours.sort_contours(cnts)
pixelsPerMetric = None

图片 1 - 我想找到所有的轮廓

图 2 - 但结果:我只能找到 1 个轮廓

我怎样才能得到所有的轮廓?

标签: opencvopencv-contour

解决方案


推荐阅读