OpenCV 3 版本输出3个值cloneImage, contours, hierarchy
OpenCV 4 版本输出2个值contours, hierarchy
OpenCV旧版,返回三个参数:
要想返回三个参数:
把OpenCV 降级成3.4.3.18 就可以了,在终端输入pip install opencv-python==3.4.3.18
cloneImage, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
OpenCV 4 新版调用,
要想返回两个参数,用两个参数接收即可:
contours, heriachy = cv.findContours(binary, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)