Ask Your Question

Revision history [back]

How to debug this error in python?

Line: contour[0] = max(contours, key = cv2.contourArea) cv2.error: OpenCV(4.2.0) C:\projects\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'

thresh = thresh[y:y+h, x:x+w] contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]

    if len(contours) > 0:
        contour[0] = max(contours, key = cv2.contourArea)
        if cv2.contourArea(contour) > 10000 and frames > 50:
            x1, y1, w1, h1 = cv2.boundingRect(contour)

How to debug this error in python?

Line: contour[0] = max(contours, key = cv2.contourArea) cv2.error: OpenCV(4.2.0) C:\projects\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''cv::contourArea.

thresh = thresh[y:y+h, x:x+w]
        contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]

cv2.CHAIN_APPROX_NONE)[1]
     if len(contours) > 0:
         contour[0] = max(contours, key = cv2.contourArea)
         if cv2.contourArea(contour) > 10000 and frames > 50:
             x1, y1, w1, h1 = cv2.boundingRect(contour)

How to debug this error in python?

Line: contour[0] = max(contours, key = cv2.contourArea) cv2.error: OpenCV(4.2.0) C:\projects\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.

thresh = thresh[y:y+h, x:x+w]
        contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]

        if len(contours) > 0:
            contour[0] = max(contours, key = cv2.contourArea)
            if cv2.contourArea(contour) > 10000 and frames > 50:
                x1, y1, w1, h1 = cv2.boundingRect(contour)