-215
opencv
assertion_error
ai_generated
true
cv::error: (-215:断言失败) objectPoints.size() == imagePoints.size() && objectPoints.size() >= 4 在函数 'cv::solvePnP' 中
cv::error: (-215:Assertion failed) objectPoints.size() == imagePoints.size() && objectPoints.size() >= 4 in function 'cv::solvePnP'
ID: opencv/calib3d-solvepnp-empty-points
90%修复率
88%置信度
1证据数
2024-07-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.8.0 | active | — | — | — |
| 4.9.0 | active | — | — | — |
| 4.10.0 | active | — | — | — |
根因分析
3D 物体点的数量与 2D 图像点的数量不匹配,或者点对应关系少于 PnP 求解所需的 4 个。
English
The number of 3D object points does not match the number of 2D image points, or there are fewer than 4 point correspondences required for PnP solving.
官方文档
https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html#ga549c2075d5aa0ed5f5a6e6d7f3e4b5b9解决方案
-
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.
-
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
95% 失败
Incorrect correspondences lead to wildly wrong pose estimates or solver failure; PnP requires accurate point pairs.
-
Using only 3 points because the user thinks 3 is enough for pose estimation
100% 失败
solvePnP requires at least 4 non-coplanar points for a unique solution; 3 points can only provide up to 4 possible solutions.