Skip to content

Main PnP pose computation doc page#21320

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
catree:solvePnP_doc_page
Dec 24, 2021
Merged

Main PnP pose computation doc page#21320
opencv-pushbot merged 1 commit intoopencv:3.4from
catree:solvePnP_doc_page

Conversation

@catree
Copy link
Copy Markdown
Contributor

@catree catree commented Dec 22, 2021

Use a single PnP pose computation page similar to the Bayer conversion page in order to remove duplicated doc and avoid potential mistakes when updating the doc in the future.

Pull Request Readiness Checklist

See details at https://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


Pose refinement consists in estimating the rotation and translation that minimizes the reprojection error using a non-linear minimization method and starting from an initial estimate of the solution. OpenCV proposes cv::solvePnPRefineLM() and cv::solvePnPRefineVVS() for this problem.

cv::solvePnPRefineLM() uses a non-linear Levenberg-Marquardt minimization scheme @cite Madsen04 @cite Eade13 and the current implementation computes the rotation update as a perturbation and not on SO(3).
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@savuor

Is it correct for the current implementation that the rotation update is not done on SO(3)? So it should only be valid for small rotation perturbation.

What about the future LM implementation?

Copy link
Copy Markdown
Contributor

@savuor savuor Dec 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catree

I thought about it when reimplementing LevMarq. Of course, it's better to do it in true way with SO(3) and exponential oplus but:
(0) The current code works
(1) AFAIK the difference between the true method and the existing method has more influence on a convergence speed than on a result correctness
(2) LevMarq is a local optimization algorithm, it doesn't have to work well on large perturbations

The ongoing LevMarq implementation will let a user (OK, maybe not an OpenCV user but at least an OpenCV contributor) to implement objective functions which accept SE(3) among other things.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your answer. This makes sense.

(1) AFAIK the difference between the true method and the existing method has more influence on a convergence speed than on a result correctness

Maybe some related discussion: https://forum.opencv.org/t/slow-convergence-of-solvepnprefinelm/5486


Wondering if the new implementation would let adding additional constraints such as line of sight or similar ideas into the solving framework?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link to the discussion. Now it's obvious to me that sometimes bad convergence speed means bad accuracy.

I'm not sure what exactly this line of sight constraint is. If it can be done as a part of cost function in a regularization manner then even old LevMarq is able to work with them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info and the work done 👍


On another topic, there is this paper: A compact formula for the derivative of a 3-D rotation in exponential coordinates. Not sure if it can be useful pratically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the 3D rotation derivative: usually an exponential derivative near 0 is used in local optimization, see this example.

Copy link
Copy Markdown
Member

@alalek alalek 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 👍

@opencv-pushbot opencv-pushbot merged commit 3a8316a into opencv:3.4 Dec 24, 2021
This was referenced Dec 24, 2021
@alalek alalek mentioned this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: calib3d category: documentation Documentation fix or update port/backport done Label for maintainers. Authors of PR can ignore this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants