Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
thezane wants to merge2 commits intoopencv:4.x
base:4.x
Choose a base branch
Loading
fromthezane:use-input-rotation-translation-in-calibration

Conversation

@thezane
Copy link
Contributor

@thezanethezane commentedJun 6, 2021
edited
Loading

Pull Request Readiness Checklist

See details athttps://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Description

Add a flagCALIB_FIX_EXTRINSIC tocalibrateCamera that 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 withcalib1.data andcalib2.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.

force_builders_only=linux,docs

crackwitz and barkm reacted with thumbs up emoji
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch 9 times, most recently fromc87d30f toabe2206CompareJune 6, 2021 18:37
@thezanethezane marked this pull request as ready for reviewJune 6, 2021 21:31
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch 3 times, most recently from32cbf34 to4b1eaa1CompareJune 7, 2021 05:18
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch from4b1eaa1 to4c57506CompareJune 9, 2021 01:28
Copy link
Member

@alalekalalek left a 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.
Copy link
Member

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).

Copy link
ContributorAuthor

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
Copy link
Contributor

Hi@alalek what about this?
Can I do something?

@asmorkalov
Copy link
Contributor

@thezane@alalek friendly reminder.

@thezane
Copy link
ContributorAuthor

Thanks for the reminder. I'll propose a new api soon.

@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch 2 times, most recently from14f3a00 to32942b2CompareJune 6, 2022 03:54
@thezanethezane marked this pull request as draftJune 6, 2022 03:55
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch 3 times, most recently fromcbf30bf toc452d97CompareJuly 18, 2022 08:18
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch 2 times, most recently fromc7adc4c to180fb9cCompareAugust 28, 2022 19:19
@thezanethezaneforce-pushed theuse-input-rotation-translation-in-calibration branch from180fb9c toeb913c5CompareAugust 28, 2022 23:20
@thezanethezane marked this pull request as ready for reviewAugust 29, 2022 07:47
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
InputOutputArrayOfArrays rvecs, InputOutputArrayOfArrays tvecs,
int flags =0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS,30, DBL_EPSILON) );
Copy link
ContributorAuthor

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.

@asmorkalovasmorkalov modified the milestones:4.7.0,4.8.0Dec 12, 2022
@thewoz
Copy link
Contributor

Hi, any news about this?

@asmorkalovasmorkalov modified the milestones:4.8.0,4.9.0May 5, 2023
@asmorkalovasmorkalov modified the milestones:4.9.0,4.10.0Dec 1, 2023
@asmorkalovasmorkalov modified the milestones:4.10.0,4.11.0May 16, 2024
@asmorkalovasmorkalov modified the milestones:4.11.0,4.12.0Dec 18, 2024
@thewoz
Copy link
Contributor

Hi everyone is there anything I can do about this pull request?
@asmorkalov

asmorkalov reacted with eyes emoji

@asmorkalovasmorkalov modified the milestones:4.12.0,4.13.0Jun 3, 2025
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),
Copy link
Contributor

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.

@asmorkalovasmorkalov modified the milestones:4.13.0,4.14.0Dec 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asmorkalovasmorkalovasmorkalov left review comments

@alalekalalekalalek left review comments

Assignees

No one assigned

Projects

None yet

Milestone

4.14.0

Development

Successfully merging this pull request may close these issues.

4 participants

@thezane@thewoz@asmorkalov@alalek

[8]ページ先頭

©2009-2025 Movatter.jp