Error occurred when Python called cv2.findcontours: valueerror: not enough values to unpack (expected 3, got 2)

 

Opencv old version, return three parameters:

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

To return three parameters:

Just demote OpenCV to 3.4.3.18, and input PIP install opencv python = = 3.4.3.18 in the terminal

Opencv new version call, return two parameters:

 contours, hierarchy = cv2.findContours(mask, cv2.RETR_ TREE, cv2.CHAIN_ APPROX_ SIMPLE)

Read More: