Error Messages: cv2.drawContours(thresh_Contours, cnts, -1, (0, 0, 255), 3)
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\drawing.cpp:2502: error: (-215:Assertion failed) npoints > 0 in function ‘cv::drawContours’
Reason: Different Opencv versions cause errors
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)[1]
cv2.drawContours(thresh_Contours, cnts, -1, (0, 0, 255), 3)
Correction method: change “1” to “0”
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)[0]
cv2.drawContours(thresh_Contours, cnts, -1, (0, 0, 255), 3)
Read More:
- [Solved] cv2.error: OpenCV(4.5.1) XXX\shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 &&……
- [Solved] cv2.error: (-215:Assertion failed) encoder->isFormatSupported(CV_8U) in function ‘imwrite_‘
- [Solved] error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor‘
- [Solved] Python opencv imshow Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- [Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function “pointPolygonTest“
- [Solved] python opencv Error: findContours() Can only use the Grayscale
- [Solved] cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\……
- [Solved] error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘imshow‘
- [Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function ‘circle‘
- Opencv Python realizes the paint filling function in PS, one click filling color and the possible reasons for opencv’s frequent errors
- error: (-5:Bad argument) in function ‘seamlessClone‘ and error: (-215:Assertion failed) 0 <= roi.x && 0 [How to Solve]
- Detailed explanation of OpenCV approxpolydp() function
- How to Solve Opencv Reads Video Error: cv2.error
- [Solved] Cv2.imshow Error: window.cpp:1274: error: (-2:Unspecified error) The function is not implemented.
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- [Solved] Pyinstaller package opencv error: ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.
- [Solved] cv2.xfeatures2d.SIFT_create() Error: module ‘cv2.cv2’ has no attribute ‘xfeatures2d’
- [Solved] error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function ‘copyMakeBorder‘
- [Solved] Django backend error: Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay()