-215
opencv
data_error
ai_generated
true
cv::error: OpenCV(4.6.0) /modules/calib3d/src/solvepnp.cpp:123: error: (-215:断言失败) !cvIsNaN(distCoeffs.at<double>(i)) 在函数'solvePnP'中
cv::error: OpenCV(4.6.0) /modules/calib3d/src/solvepnp.cpp:123: error: (-215:Assertion failed) !cvIsNaN(distCoeffs.at<double>(i)) in function 'solvePnP'
ID: opencv/calib3d-solvepnp-distortion-nan
87%修复率
83%置信度
1证据数
2023-05-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.6.0 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.8.0 | active | — | — | — |
根因分析
畸变系数向量包含NaN(非数字)值,导致solvePnP失败。
English
The distortion coefficients vector contains NaN (Not a Number) values, causing solvePnP to fail.
官方文档
https://docs.opencv.org/4.6.0/d9/d0c/group__calib3d.html解决方案
-
Check and clean distortion coefficients: `distCoeffs = np.nan_to_num(distCoeffs, nan=0.0)` before calling solvePnP.
-
Re-run camera calibration with valid checkerboard images to generate proper distortion coefficients.
-
If distortion coefficients are not needed, pass an empty array: `cv2.solvePnP(objPoints, imgPoints, cameraMatrix, None)`
无效尝试
常见但无效的做法:
-
Setting all NaN values to 0 without re-calibrating.
60% 失败
Replacing NaN with 0 may still cause poor results if the original calibration was bad; it's a temporary patch.
-
Changing the camera index in VideoCapture.
80% 失败
Using a different camera index does not fix the distortion data.
-
Increasing the termination criteria iterations for solvePnP.
70% 失败
Increasing the number of iterations does not eliminate NaN in input.