thresh_Contours = thresh.copy()
cnts = cv.findContours(thresh_Contours, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)[1]
cv.drawContours(thresh_Contours, cnts, -1, (0, 0, 0), 3)
cv_show('thresh_Contours',thresh_Contours)

报错如下

error: (-215:Assertion failed) npoints > 0 in function 'cv::drawContours'

把[1]改成[0]即可

thresh_Contours = thresh.copy()
cnts = cv.findContours(thresh_Contours, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)[0]
cv.drawContours(thresh_Contours, cnts, -1, (0, 0, 0), 3)
cv_show('thresh_Contours',thresh_Contours)

Logo

一站式 AI 云服务平台

更多推荐