根据OpenCV版本,
cv2.findContours()具有不同的返回签名。
在OpenCV
3.4.X中,
cv2.findContours()返回3个项目
image, contours, hierarchy = cv.findContours(image, mode, method[, contours[, hierarchy[, offset]]])
在OpenCV
4.1.X中,
cv2.findContours()返回2个项目
contours, hierarchy = cv.findContours(image, mode, method[, contours[, hierarchy[, offset]]])
无论使用哪种版本,都可以轻松获取轮廓:
tmp = cv2.findContours(des,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE)contours = tmp[0] if len(tmp) == 2 else tmp[1]



