Python error when calling cv2.findContours: ValueError: not enough values to unpack (expected 3, got 2)

OpenCV legacy, returns three parameters:

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

To return three parameters :

3.4.3.18 The OpenCV downgrade it to enter pip install opencv-python == 3.4.3.18 terminal

The new OpenCV calls, returns two parameters :

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

Guess you like

Origin www.cnblogs.com/liuwenhua/p/11988351.html