
这里就是想提取一下轮廓,谁知道就崩了呢?!:
# 轮廓检测
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:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function ‘cv::contourArea’
解决方案:
提示:将 findContours(...)[1] 改为findContours(...)[0]
错误原因:应该是opencv的版本不同导致的
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)