python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)

python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)

 

OpenCV旧版,返回三个参数:

im2, contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
要想返回三个参数:

把OpenCV 降级成3.4.3.18 就可以了,在终端输入pip install opencv-python==3.4.3.18

OpenCV 新版调用,返回两个参数:

 contours, hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

更多咨询,请关注 “青年夏日”公众号

python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)_第1张图片

你可能感兴趣的:(python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2))