Fisheye distortion coefficient format
shreyas23 opened this issue · 2 comments
Hey @rameau-fr hope you're doing well!
I'm calibrating a set of fisheye cameras and initializing K with some nominal known values while setting the distortion coefficients to 0. I noticed that k4 is always 0 after optimization.
After brief investigation it seems like there's a discrepancy in the format and order of the distortion vector:
via OpenCV in fisheye::calibrate() : Output vector of distortion coefficients (k1, k2, k3, k4).
MC-Calib/McCalib/include/Camera.hpp
Line 43 in 0f893aa
setDistortionVector:
MC-Calib/McCalib/src/Camera.cpp
Lines 59 to 63 in 0f893aa
getDistortionVector:
MC-Calib/McCalib/src/Camera.cpp
Lines 85 to 90 in 0f893aa
but then during optimization:
MC-Calib/McCalib/include/OptimizationCeres.h
Lines 67 to 70 in 0f893aa
If I understand correctly, the following changes should be made:
setDistortionVector:
intrinsics_[6] = distortion_vector.at<double>(2);
intrinsics_[7] = distortion_vector.at<double>(3);
getDistortionVector:
distortion_vector.at<double>(3) = intrinsics_[7]
Let me know if this sounds right to you.
Hello @shreyas23, I do not know how to thank you enough for reporting it !!
I think you are right. I will double-check this issue with @BAILOOL, and we will make the change as soon as possible. It is quite a big bug here. It might also be the reason why some persons calibrating large field-of-view cameras were facing issues during calibration.
Please, keep me in touch if you make some tests with your modified version of the code.
My pleasure! I did run some tests while fixing it on my end and seemingly had better convergence. I can run some comparisons when I get a chance but the effects likely aren't significant in my scenario as my FoV is not too high.