deepmask-pytorch icon indicating copy to clipboard operation
deepmask-pytorch copied to clipboard

File "computeProposals.py", line 66, in main _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: not enough values to unpack (expected 3, got 2)

Open tim94173 opened this issue 4 years ago • 2 comments

when i run "python computeProposals.py --arch DeepMask --resume $DEEPMASK/pretrained/deepmask/DeepMask.pth.tar --img ./data/test.jpg", I get this error result:

File "computeProposals.py", line 66, in main _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) ValueError: not enough values to unpack (expected 3, got 2)

how can i sovle it ,thank you

tim94173 avatar Mar 11 '20 15:03 tim94173

Downgrade cv2 version 4.x to version 3.x. OpenCV 3 changed cv2.findContours(...) to return image, contours, hierarchy, while OpenCV 2's cv2.findContours(...) and OpenCV 4's cv2.findContours(...) return contours, hierarchy.

alzayats avatar Mar 13 '20 11:03 alzayats

The easy way is to change this (computeProposals.py)

_, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

to this

contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

jefflgaol avatar Mar 27 '20 02:03 jefflgaol