Opencv版本不同导致findContours()报错问题

在代码移植时,Opencv的findContours()出现了报错问题

通过查找资料发现是Opencv版本不同导致的,只需修改下列代码即可.

opencv3.x

cnts = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[1]
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:5]

opencv4.x

cnts = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[1]
cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:5]

你可能感兴趣的:(opencv,python)