cv2.findContours 返回錯誤:too many values to unpack (expected 2)

今天在使用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。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章