Error: CNTS=sorted (CNTS, the key=CV. ContourArea, reverse=True) [5]
Cv2. Error: OpenCV (4.2.0) C: \ \ projects \ OpenCV - python OpenCV \ modules \ imgproc \ SRC \ shapedescr CPP: 315: error: (- 215: an Assertion failed) npoints & gt;=0 & amp; & (the depth==CV_32F | | the depth==CV_32S) in function 'CV: : contourArea'
After the extraction of contour profile to by contour size sorting, but has been an error
Baidu to find for a long time also didn't find a solution to


CodePudding user response:
CNTS=cv2. FindContours (edged. Copy (), cv2. RETR_LIST cv2. CHAIN_APPROX_SIMPLE) [0]It is ok to change that last 1 to 0
Remember that in Opencv4 cv2. FindContour () only returns two values: contours, hierachy https://docs.opencv.org/master/d4/d73/tutorial_py_contours_begin.html.
So it should be
CNTS=cv2. FindContours (mask, cv2. RETR_TREE, cv2 CHAIN_APPROX_SIMPLE) [0]