# cv::error: (-215:断言失败) objectPoints.size() == imagePoints.size() && objectPoints.size() >= 4 在函数 'cv::solvePnP' 中

- **ID:** `opencv/calib3d-solvepnp-empty-points`
- **领域:** opencv
- **类别:** assertion_error
- **错误码:** `-215`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

3D 物体点的数量与 2D 图像点的数量不匹配，或者点对应关系少于 PnP 求解所需的 4 个。

## 版本兼容性

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

## 解决方案

1. ```
   Ensure both vectors have equal size and contain at least 4 points. Use a checkerboard detection to generate at least 4 corners: cv::findChessboardCorners returns a vector of corners that can be paired with known 3D object points.
   ```
2. ```
   If using ArUco markers, ensure at least 4 markers are detected and their corners are properly paired with 3D model points using cv::aruco::estimatePoseSingleMarkers for each marker.
   ```

## 无效尝试

- **Adding random extra points to objectPoints to match imagePoints size without verifying correspondence** — Incorrect correspondences lead to wildly wrong pose estimates or solver failure; PnP requires accurate point pairs. (95% 失败率)
- **Using only 3 points because the user thinks 3 is enough for pose estimation** — solvePnP requires at least 4 non-coplanar points for a unique solution; 3 points can only provide up to 4 possible solutions. (100% 失败率)
