# cv::error: (-215:断言失败) matches.size() >= 4 在函数 'cv::detail::matchesGraphAsString' 中

- **ID:** `opencv/stitching-error-not-enough-matches`
- **领域:** opencv
- **类别:** computation_error
- **错误码:** `-215`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

图像拼接需要至少4个良好匹配点来计算单应性矩阵，但找到的匹配点少于4个。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.5 | active | — | — |
| 4.8.0 | active | — | — |
| 4.9.0 | active | — | — |

## 解决方案

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)
   ```
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
   ```

## 无效尝试

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