-215
opencv
computation_error
ai_generated
true
cv::error: (-215:Assertion failed) matches.size() >= 4 in function 'cv::detail::matchesGraphAsString'
ID: opencv/stitching-error-not-enough-matches
80%Fix Rate
85%Confidence
1Evidence
2024-11-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.5.5 | active | — | — | — |
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
Root Cause
Image stitching requires at least 4 good matches between images to compute homography, but fewer were found.
generic中文
图像拼接需要至少4个良好匹配点来计算单应性矩阵,但找到的匹配点少于4个。
Official Documentation
https://docs.opencv.org/4.x/d8/d19/tutorial_stitcher.htmlWorkarounds
-
75% success img = cv2.detailEnhance(img, sigma_s=10, sigma_r=0.15) # Or use contrast adjustment: img = cv2.convertScaleAbs(img, alpha=1.5, beta=0)
img = cv2.detailEnhance(img, sigma_s=10, sigma_r=0.15) # Or use contrast adjustment: img = cv2.convertScaleAbs(img, alpha=1.5, beta=0)
-
80% success sift = cv2.SIFT_create(nfeatures=5000, contrastThreshold=0.03, edgeThreshold=10) kp, des = sift.detectAndCompute(img, None) # Then use FLANN matcher with lower ratio threshold
sift = cv2.SIFT_create(nfeatures=5000, contrastThreshold=0.03, edgeThreshold=10) kp, des = sift.detectAndCompute(img, None) # Then use FLANN matcher with lower ratio threshold
中文步骤
img = cv2.detailEnhance(img, sigma_s=10, sigma_r=0.15) # Or use contrast adjustment: img = cv2.convertScaleAbs(img, alpha=1.5, beta=0)
sift = cv2.SIFT_create(nfeatures=5000, contrastThreshold=0.03, edgeThreshold=10) kp, des = sift.detectAndCompute(img, None) # Then use FLANN matcher with lower ratio threshold
Dead Ends
Common approaches that don't work:
-
70% fail
The error is about actual matches found, not the threshold; increasing threshold won't generate more matches.
-
80% fail
Lower quality images have fewer features, making the problem worse.
-
50% fail
ORB may produce fewer matches if images have low texture; fine-tuning is needed.