# cv::error: (-28:Insufficient number of valid points) in function 'solvePnP'

- **ID:** `opencv/solvepnp-insufficient-points`
- **Domain:** opencv
- **Category:** computation_error
- **Error Code:** `-28`
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

cv::solvePnP requires at least 4 non-collinear point correspondences for P3P or 6 for PnP; the input set is too small or contains degenerate points.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 4.5.0 | active | — | — |
| 4.7.0 | active | — | — |
| 4.9.0 | active | — | — |

## Workarounds

1. **Ensure at least 4 unique, non-collinear 3D-2D point correspondences: if (objectPoints.size() < 4) { /* collect more points */ }** (95% success)
   ```
   Ensure at least 4 unique, non-collinear 3D-2D point correspondences: if (objectPoints.size() < 4) { /* collect more points */ }
   ```
2. **Use SOLVEPNP_EPNP which can work with 4 or more points; it is more robust to small sets: cv::solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, false, cv::SOLVEPNP_EPNP);** (85% success)
   ```
   Use SOLVEPNP_EPNP which can work with 4 or more points; it is more robust to small sets: cv::solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, false, cv::SOLVEPNP_EPNP);
   ```

## Dead Ends

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