opencv 2與3 關於cv2.findContours 輪廓檢測區別

關於opencv 輪廓檢測 中的 ValueError: too many values to unpack ,ValueError: not enough values to unpack (expected 3, got 2)

Opencv2代碼實現

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

函數原型

cv2.findContours(image, mode, method[, contours[, hierarchy[, offset ]]])  

返回兩個值:contours;hierarchy。

Opencv3代碼實現

image,cnts,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)  

返回三個值:image;contours;hierarchy。

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