报错
- 源码
contours, hierarchy = cv2.findContours(img_handled, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
# 据面积排序
contours.sort(key=lambda c: abs(cv2.contourArea(c)), reverse=True)
因为contours是元组没有sort属性
所以更改contours为列表
- 修改
contours, hierarchy = cv2.findContours(img_handled, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
# 据面积排序
contours = list(contours) # 添加!!!
contours.sort(key=lambda c: abs(cv2.contourArea(c)), reverse=True)
标签:sort,APPROX,no,hierarchy,attribute,cv2,abs,contours
From: https://www.cnblogs.com/user-yi/p/16768550.html