Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Use input rotation and translation in camera calibration#20219
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:4.x
Are you sure you want to change the base?
Use input rotation and translation in camera calibration#20219
Conversation
c87d30f toabe2206Compare32cbf34 to4b1eaa1Compare4b1eaa1 to4c57506Compare
alalek left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for the contribution!
| space. Due to its duality, this tuple is equivalent to the position of the calibration pattern with | ||
| respect to the camera coordinate space. If @ref CALIB_FIX_EXTRINSIC is specified, rotation | ||
| matrices and translation vectors equal in size to the number of images must be initialized and will | ||
| be used for calibration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
will be used for calibration
This contradicts withOutputArrayOfArrays rvecs parameter declaration which is critical for bindings generators (Python/Java/etc code).
Perhaps we should make dedicated overload (at least in public headers).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks@alalek . I see 4 api versions of calibrate camera in calib3d.hpp:
- calibrateCameraExtended
- calibrateCamera
- calibrateCameraROExtended
- calibrateCameraRO
Here's an initial proposal for the overload:
- calibrateCameraFEExtended: Based on calibrateCameraROExtended but with rvecs and tvecs as InputOutputArrayOfArrays
- calibrateCameraFE: Based on calibrateCameraRO but with rvecs and tvecs as InputOutputArrayOfArrays
The "FE" stands for "FixedExtrinsics". This is similar to how calibrateCameraROExtended and calibrateCameraRO are declared and how "RO" stands for "ReleasingObject". I selected InputOutputArrayOfArrays instead of InputArrayOfArrays in case one day we want the user to be able to pass in an initial guess for extrinsics that will be optimized by the LM solver.
Basing the extension on calibrateCameraRO also allows the method of releasing object to be combined with fixed extrinsics.
What's your opinion?
thewoz commentedMar 10, 2022
Hi@alalek what about this? |
asmorkalov commentedMay 23, 2022
thezane commentedMay 26, 2022
Thanks for the reminder. I'll propose a new api soon. |
14f3a00 to32942b2Comparecbf30bf toc452d97Comparec7adc4c to180fb9cCompare180fb9c toeb913c5Compare| InputOutputArray cameraMatrix, InputOutputArray distCoeffs, | ||
| InputOutputArrayOfArrays rvecs, InputOutputArrayOfArrays tvecs, | ||
| int flags =0, TermCriteria criteria = TermCriteria( | ||
| TermCriteria::COUNT + TermCriteria::EPS,30, DBL_EPSILON) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@alalek@asmorkalov I propose a dedicated api to support passing in extrinsics. Can you see if you're agreeable with the api?
The extrinsics type isInputOutputArrayOfArrays, which allows OpenCV to modify it in case we want to support an initial guess for the extrinsics in the future.
thewoz commentedJan 30, 2023
Hi, any news about this? |
thewoz commentedMay 28, 2025
Hi everyone is there anything I can do about this pull request? |
| CALIB_FIX_TAUX_TAUY =0x80000, | ||
| CALIB_USE_QR =0x100000,//!< use QR instead of SVD decomposition for solving. Faster but potentially less precise | ||
| CALIB_FIX_TANGENT_DIST =0x200000, | ||
| CALIB_FIX_EXTRINSIC = (1 <<23), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There isCALIB_RECOMPUTE_EXTRINSIC for fisheye. Also need to align with new flags in 5.x.
Uh oh!
There was an error while loading.Please reload this page.
Pull Request Readiness Checklist
See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Description
Add a flag
CALIB_FIX_EXTRINSICtocalibrateCamerathat allows users to fix input rotation and translation parameters during calibration. Unit tests are added to verify calibration results and format of extrinsic arguments . This PR is a response to#15781.FAQ
The requester in#15781 asked for separate flags to fix rotation and translation. Why does this PR only allow fixing rotation and translation together?
When testing calibration results with
calib1.dataandcalib2.data, I noticed the LM solver struggles to arrive at a good calibration result when only rotation is fixed but not when rotation and translation are fixed.The reason is opencv performs calibration withZhang's method, which estimates camera matrix first and translation matrices from camera matrix after. This forces the LM solver to optimize both the camera and translation matrices, which it's unable to do as the initial guess for the camera and translation matrices are a poor fit for the input rotation matrix. Likewise when only translation is fixed.
In contrast, when fixing both rotation and translation, the LM solver only has to optimize the camera matrix and is able to arrive at a good calibration result.