I am currently working to calibrate a camera and I tried using both the Caltech Camera Calibration Toolbox for Matlab and OpenCV. I used the same images for both methods. Even if the error seems to be more or less the same between the two methods, the values don't quite match, especially the distortion coefficients

Matlab results

Calibration results after optimization (with uncertainties):

Focal Length:          fc = [ 1475.06776   1474.34956 ] +/- [ 1.30130   1.28283 ]
Principal point:       cc = [ 967.66660   535.09387 ] +/- [ 1.44019   1.23663 ]
Skew:             alpha_c = [ 0.00000 ] +/- [ 0.00000  ]   => angle of pixel axes = 90.00000 +/- 0.00000 degrees
Distortion:            kc = [ 0.06844   -0.15582   0.00049   0.00021  0.00000 ] +/- [ 0.00235   0.00641   0.00028   0.00035  0.00000 ]
Pixel error:          err = [ 0.64754   0.45951 ]

Note: The numerical errors are approximately three times the standard deviations (for reference).

and OpenCV results

RMS:  0.40118611304523083
Camera matrix:  [[1.46405121e+03 0.00000000e+00 9.64151487e+02]
 [0.00000000e+00 1.46362963e+03 5.35514933e+02]
 [0.00000000e+00 0.00000000e+00 1.00000000e+00]]
Distortion coefficients:  [[ 2.27565390e-01 -1.22470407e+00  3.58771830e-04 -4.77602117e-04

I understand that there are differences between the two methods (e.g. corner extraction method) so I shouldn't expect exactly the same results, but the difference still looks significant to me. I tried taking more images of my chessboard tilted at different angles, but the values and the errors don't vary that much.

I am mostly surprised by the difference in the distortion coefficients, as they have orders of difference. If I undistort the chessboard images using the values from the two calibrations, they both look reasonable even if the OpenCV one shows more barrell correction.

Undistorted using Matlab calibration Undistorted using Matlab calibration

Undistorted using OpenCV calibration Undistorted using OpenCV calibration

My guess is that since the camera does not have too much distortion to start with the two methods converge to different solutions. My question is, is there a way to determine which of these two calibration gives the "best" result? Would they be both acceptable even if they are clearly different?


2 Answers 2


Depending on the lens-distortion model used, the achievable accuracy can be significantly different: https://discorpy.readthedocs.io/en/latest/tutorials/methods.html Have a go with another approach here: https://discorpy.readthedocs.io/en/latest/usage/demo_06.html, you may get better results. Straight lines should be straight after unwarping.


The main reason you are not getting similar results is that you've used different camera models. With OpenCV you are using the highest order radial distortion coefficient k3 while it was excluded (fixed to 0) in Matlab. OpenCV achieves a lower error because the model is more flexible. However you notice that the highest order term dominates the distortion model near the image boundary and produces non-physical results. Including k3 is probably not a good idea. Have a look at the std.error of that parameter. An article explaining this can be found here: https://calib.io/blogs/knowledge-base/understanding-parameter-uncertainty


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.