8000 Use analytical Jacobian in IterativeUndistortion. Add trust region by B1ueber2y · Pull Request #2857 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use analytical Jacobian in IterativeUndistortion. Add trust region #2857

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

Merged
merged 11 commits into from
Oct 28, 2024

Conversation

B1ueber2y
Copy link
Contributor
@B1ueber2y B1ueber2y commented Oct 26, 2024

Attempt on #2802 (improvement but did not manage to fully fix as discussed in the post below)

Remove templating of CamFromImg as it is never used in the optimization (and is tricky to be used in the optimization due to the unrolling in IterativeUndistortion).

Use Jet from ceres to enable analytical Jacobian in the IterativeUndistortion.

@B1ueber2y B1ueber2y marked this pull request as draft October 26, 2024 17:14
@B1ueber2y
Copy link
Contributor Author

Making the Jacobian analytical brings some gain. However, Newton does not converge when the theta is larger than around 1.25 for the parameters in #2802. The loss landscape is very bad for Newton convergence, that leads to extreme oscillations.

With the previous IterativeUndistortion the oscillation can lead to a different root potentially with norm larger than pi/2, which essentially invalids the tangent function, leading to > 500 pixel error. Adding a trust region would reduce the forward-backward error to always less than 75 pixels (extreme case happens for thetas close to pi/2), but does not resolve the convergence issue. The fact that k3, k4 are large enough for the radial distortion with an exponentially growing theta^8 makes it hard to converge with theta that is larger than 1.25.

I dont think we can do better with Newton here. I also tried adding damping factors that does not give much gain. I believe we need to resort to other optimization approach in order to fully resolve the issue.

@B1ueber2y B1ueber2y marked this pull request as ready for review October 27, 2024 03:16
@B1ueber2y B1ueber2y changed the title Use analytical Jacobian in IterativeUndistortion Use analytical Jacobian in IterativeUndistortion. Add trust region Oct 27, 2024
Copy link
Contributor
@ahojnnes ahojnnes 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, this is a good improvement. I assume this now converges in fewer iterations than before and the autodiff Jacobian is faster to evaluate than numeric differentiation?

For the remaining failure cases, I am wondering whether we can benefit from @vlarsson's approach here: https://github.com/PoseLib/PoseLib/blob/master/PoseLib/misc/colmap_models.cc#L643

@B1ueber2y
Copy link
Contributor Author
B1ueber2y commented Oct 27, 2024

Thank you, this is a good improvement. I assume this now converges in fewer iterations than before and the autodiff Jacobian is faster to evaluate than numeric differentiation?

For the remaining failure cases, I am wondering whether we can benefit from @vlarsson's approach here: https://github.com/PoseLib/PoseLib/blob/master/PoseLib/misc/colmap_models.cc#L643

Thanks. I think the one from PoseLib (optimization on the radius first) only works with radial distortion, but does not work with tangential and ThinPrism. We could definitely try the idea of multiple initialization as in PoseLib, but I am not sure if it can resolve the convergence issue in our case.

@ahojnnes ahojnnes enabled auto-merge (squash) October 28, 2024 08:48
@ahojnnes ahojnnes merged commit fc69be7 into colmap:main Oct 28, 2024
16 checks passed
@B1ueber2y B1ueber2y deleted the fix/undistortion branch October 28, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0