You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ill-defined distortion model found by calibrateCamera #15577
The calibrateCamera() function can return distortion coefficients k1, k2... k6 that lead to a distortion model that is ill-defined. The denominator of the radial distortion part (1 + k4 r^2 + k5 r^4 + k6 r^6) can have roots r_i such that r_i^2 = ((u-cx)/fx)^2 + ((v-cy)/fy)^2 for some real-valued image points coordinates (u, v) within the image boundaries.
As a consequence, all image points located in the vicinity of this ellipsis may be attributed an incorrect value by the remap function, as the rectification maps will contain invalid coordinates.
This was observed after calibrating with a set of images in which the chessboard was placed mostly near the image center, so my guess is that the lack of constraints further from the center could explain why the optimization could converge towards such a solution. A work around is to check at the end of the calibration process that the radial distortion model is well-defined for every image pixel coordinates − i.e. compute the roots of the polynomial at the denominator.
My question is: when the rational distortion model is used, shouldn't the optimization be constrained in a way that prevents convergence towards such ill-defined sets of coefficients?
set of images in which the chessboard was placed mostly near the image center
This is incomplete input for calibrateCamera(). For best results you should cover all parts of camera frame including sides and corners.
Check reprojection error. If it is minimal then algo works "correctly" with provided constraints(input).
Detection of lack of constraints is currently out of scope.
Yes, I understand that with the input data set the calibration cannot be expected to be accurate over the whole field of view, only on the sub-part covered by the calibration images. Still, I think there is a difference between having a model which only approximates the actual distortion over a part of the field of view and a model which exhibits singularities (division by zero).
Also, except for very low distortion lenses, it is sometimes difficult if not impossible to place a chessboard corner near the image corners, which means that there is always a part of the field of view left unexplored.
Then I agree that with a good acquisition procedure (i.e. enough constraints) this should not happen.
Detection of lack of constraints is currently out of scope.
Got it, we can live with it and implement our own checks.
I looked into this issue using the interactive calibration app on 5.x (2d579693d87a). The reported distortion parameters have a denominator root at a normalized radius of approximately 1.00844, which falls within the app's rectification domain. Interestingly, all the generated floating-point map coordinates were finite.
I also tested calibrations using recorded opencv_extra observations and found roots within the preview domain in 3 out of 16 center-only rational fits, compared to none of the 16 broad-coverage rational fits.
Would it make sense to add an optional warning in CalibDataController::updateUndistortMap when such a root falls within the actual rectification domain? This would be limited to the interactive calibration app, without changing calibrateCamera or its public API.
Activity
alalek commentedon Sep 24, 2019
This is incomplete input for
calibrateCamera(). For best results you should cover all parts of camera frame including sides and corners.Check reprojection error. If it is minimal then algo works "correctly" with provided constraints(input).
Detection of lack of constraints is currently out of scope.
guillaume-jcb commentedon Sep 24, 2019
Yes, I understand that with the input data set the calibration cannot be expected to be accurate over the whole field of view, only on the sub-part covered by the calibration images. Still, I think there is a difference between having a model which only approximates the actual distortion over a part of the field of view and a model which exhibits singularities (division by zero).
Also, except for very low distortion lenses, it is sometimes difficult if not impossible to place a chessboard corner near the image corners, which means that there is always a part of the field of view left unexplored.
Then I agree that with a good acquisition procedure (i.e. enough constraints) this should not happen.
Got it, we can live with it and implement our own checks.
RITU940 commentedon Nov 27, 2026
I looked into this issue using the interactive calibration app on 5.x (
2d579693d87a). The reported distortion parameters have a denominator root at a normalized radius of approximately 1.00844, which falls within the app's rectification domain. Interestingly, all the generated floating-point map coordinates were finite.I also tested calibrations using recorded
opencv_extraobservations and found roots within the preview domain in 3 out of 16 center-only rational fits, compared to none of the 16 broad-coverage rational fits.Would it make sense to add an optional warning in
CalibDataController::updateUndistortMapwhen such a root falls within the actual rectification domain? This would be limited to the interactive calibration app, without changingcalibrateCameraor its public API.