# cv::error: (-28:有效点数不足) 在函数 'solvePnP' 中

- **ID:** `opencv/solvepnp-insufficient-points`
- **领域:** opencv
- **类别:** computation_error
- **错误码:** `-28`
- **验证级别:** ai_generated
- **修复率:** 87%

## 根因

cv::solvePnP 需要至少 4 个非共线的点对应关系（P3P）或 6 个（PnP）；输入集太小或包含退化点。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.5.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.9.0 | active | — | — |

## 解决方案

1. ```
   确保至少有 4 个唯一且非共线的 3D-2D 点对应：if (objectPoints.size() < 4) { /* 收集更多点 */ }
   ```
2. ```
   使用 SOLVEPNP_EPNP，它可以处理 4 个或更多点，对少量点更鲁棒：cv::solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, false, cv::SOLVEPNP_EPNP);
   ```

## 无效尝试

- **** — All PnP methods require a minimum number of correspondences; iterative methods still need at least 4 points to compute a solution. (100% 失败率)
- **** — Duplicate or collinear points do not provide new constraints; the solver fails due to degeneracy or numerical instability. (90% 失败率)
