New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calibrate camera without moving external parameters #15781
Comments
Did you try these flags? Please provide more information about use case. |
Yes, I have tried those flags. I try to explain me better. In the calibrate camera function, the algorithm tries to find the best internal (K) and external parameters (R|T) to minimize the reprojection error between the 2D and 3D points. In my case, I know precisely the external parameters, but I do not know the internal one. so it will be helpful to add two flags: one to fix the translation and one to fix the rotation. |
I'm interested in implementing the two flags in this request but would like some guidance. After checking out the helper function cvCalibrateCamera2Internal(), I think a different calibration approach than the one available in OpenCV is needed. Currently, OpenCV computes intrinsic parameters first and uses them to compute extrinsic parameters (i.e. Zhang's method). However, this feature needs intrinsic parameters to be computed from user-supplied extrinsic parameters. Perhaps Tsai's method can be used as it computes extrinsic parameters before intrinsic parameters? Is this intuition reasonable? |
Hi thezane, Indeed the calibration algorithm is based on the idea that by exploiting the correspondences between the 3D and 2D positions it is possible to find the internal parameters of the system. To reach this goal the algorithm needs also to find the external parameters (i.e. the RT matrix). My point is, for example, that moving the camera's Z value has the same effect as changing the omega (focal length) of the camera. For this reason, if one knows exactly the real position of the camera (the RT matrix) it would be useful to be able to calibrate the camera iby fixing the external parameters. Maybe adding some flags here. One to fix the translation and one to fix the rotation of the camera. |
Thanks thewoz. After stepping through the helper function cvCalibrateCamera2Internal() with the debugger, I think your proposal will work. What I have to do is: The solver should then optimize the params without changing the initial extrinsic parameters. This is how user-provided focal lengths are fixed during calibration process via flags I'll try and open a PR with unit tests soon. |
@thewoz Just an update. I implemented the ability to fix the user-provided rotation and/or translation. After some testing, I noticed fixing just the rotation or just the translation frequently leads to a high projection error. Thus, I'm going to recommend we only allow fixing the extrinsic parameters as a whole. Would you be ok with this? If you're curious, the reason why fixing just the rotation leads to a high projection error is the camera matrix is estimated first without using the user provided rotation: opencv/modules/calib3d/src/calibration.cpp Line 1589 in b67c0e5
Then translation is computed using the estimated camera matrix: opencv/modules/calib3d/src/calibration.cpp Line 1045 in b67c0e5
This leads to a high initial projection error as the initial guess for camera and translation parameters are incompatible with the user provided rotation matrix. Then the LM method gets stuck in a local minimum with a high projection error. Similarly when just fixing the translation parameters. However, fixing the extrinsic parameters as a whole leads to a good estimate for the camera matrix as only the initial guess for the camera matrix is off. In fact, I found passing and fixing a good 3x3 rotation and 3x1 translation leads to a lower projection error than if you didn't pass them in at all. If you think fixing just the rotation or just the translation is crucial, then invasive changes are needed to the initial camera matrix computation to ensure it's compatible with the provided rotation or translation: opencv/modules/calib3d/src/calibration.cpp Line 1263 in b67c0e5
|
@thezane |
It is then possible to add a flag to do not move the external parameter during the optimisation in the calibrate camera function?
thanks
The text was updated successfully, but these errors were encountered: