-215
opencv
data_error
ai_generated
true
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%Fix Rate
83%Confidence
1Evidence
2023-05-12First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.6.0 | active | — | — | — |
| 4.7.0 | active | — | — | — |
| 4.8.0 | active | — | — | — |
Root Cause
The distortion coefficients vector contains NaN (Not a Number) values, causing solvePnP to fail.
generic中文
畸变系数向量包含NaN(非数字)值,导致solvePnP失败。
Official Documentation
https://docs.opencv.org/4.6.0/d9/d0c/group__calib3d.htmlWorkarounds
-
85% success Check and clean distortion coefficients: `distCoeffs = np.nan_to_num(distCoeffs, nan=0.0)` before calling solvePnP.
Check and clean distortion coefficients: `distCoeffs = np.nan_to_num(distCoeffs, nan=0.0)` before calling solvePnP.
-
90% success Re-run camera calibration with valid checkerboard images to generate proper distortion coefficients.
Re-run camera calibration with valid checkerboard images to generate proper distortion coefficients.
-
80% success If distortion coefficients are not needed, pass an empty array: `cv2.solvePnP(objPoints, imgPoints, cameraMatrix, None)`
If distortion coefficients are not needed, pass an empty array: `cv2.solvePnP(objPoints, imgPoints, cameraMatrix, None)`
中文步骤
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)`
Dead Ends
Common approaches that don't work:
-
Setting all NaN values to 0 without re-calibrating.
60% fail
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% fail
Using a different camera index does not fix the distortion data.
-
Increasing the termination criteria iterations for solvePnP.
70% fail
Increasing the number of iterations does not eliminate NaN in input.