这里就是想提取一下轮廓,谁知道就崩了呢?!:
# 轮廓检测 cnts = cv2.findContours(edged.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)[1] cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:5]
-错误提示
提示:Traceback (most recent call last): cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:5]cv2.error: OpenCV(4.5.5) D:aopencv-pythonopencv-pythonopencvmodulesimgprocsrcshapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function ‘cv::contourArea’
解决方案:
提示:将 findContours(...)[1] 改为findContours(...)[0]
错误原因:应该是opencv的版本不同导致的



