cnts = cv2.findContours(edged_image.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
cnts = sorted(cnts, key=cv2.contourArea, reverse=True)[:5]
Error:
OpenCV(4.1.1) error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function ‘cv::contourArea’
Solution:
Wrong operation here:
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
If you still want to use it, you can change it to:
cnts = cnts[1] if imutils.is_cv3() else cnts[0]
Similar Posts:
- Python OpenCV Save Image error: (-215:Assertion failed) !_img.empty()
- [Solved] HiC-Pro mergeSAM.py Error: Forward and reverse reads not paired. Check that BAM files have the same read names and are sorted.
- How to Solve Opencv error: assertion failed + error: (- 215)
- [Solved] Opencv3.4.0 Install error: fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory
- [Solved] Lego-loam Error: opencv fatal error: cv.h: No such file or directory
- AttributeError: ‘list’ object has no attribute ‘keys’
- [Solved] PIP install CV2 error: ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none)
- Upgrade pip Error: ”’SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED]…”
- [Solved] Docker Container Start Error: iptables: No chain/target/match by that name
- How to Solve “Fibers is not supported” Error in Nodejs V16.X or Higher Version