# cv::error: (-215:Assertion failed) matches.size() >= 4 in function 'cv::detail::matchesGraphAsString'

- **ID:** `opencv/stitching-error-not-enough-matches`
- **Domain:** opencv
- **Category:** computation_error
- **Error Code:** `-215`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Image stitching requires at least 4 good matches between images to compute homography, but fewer were found.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.5 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **img = cv2.detailEnhance(img, sigma_s=10, sigma_r=0.15)
# Or use contrast adjustment:
img = cv2.convertScaleAbs(img, alpha=1.5, beta=0)** (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)
   ```
2. **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** (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
   ```

## Dead Ends

- **** — The error is about actual matches found, not the threshold; increasing threshold won't generate more matches. (70% fail)
- **** — Lower quality images have fewer features, making the problem worse. (80% fail)
- **** — ORB may produce fewer matches if images have low texture; fine-tuning is needed. (50% fail)
