今天在使用cv2.findContours
報錯:
too many values to unpack (expected 2)
返回是兩個數值啊,但是,不同cv2版本的cv2.findContours
返回值不一樣,有返回三個數值的,第一個參數爲原來的圖像。。。
即在cv2.findContours
的返回值的第一項添加image返回參數。即:
將
tcl_contours, _ = cv2.findContours(tcl_mask.astype(np.uint8), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
修改爲:
images, tcl_contours, _ = cv2.findContours(tcl_mask.astype(np.uint8), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
game over。