Support more distortion parameters #25
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request add a "Radial" camera model which has k1,k2 distortion parameters into camera.py. Jacobians of this camera are implemented.
Several changes are made in lm_optimizer.py, perspective_fields.py, utils.py, geocalib.py and cameras.py to support arbitrary number of distortion parameters, instead of only one k1 parameter.
The only thing I'm not sure about is the change in the Jacobian of the up vectors in perspective_fields.py. The old code seems to be heavily based on the assumption that there is only k1 and used some tricks to simplify the computation, like torch.diag_embed. My change is derived from Eq(9) from scratch, and it could produce the same result as the original code on the testing image.
However, when I compare the values of the computed Jacobian (J_dist) and the original Jacobian (J_k1), I noticed their values become different after the first iteration, the direction seems correlated, for example (1.2, 1.0) vs (1.0, 0.8). I'm not sure if this is because there is a constant different between them which was discarded in the original implementation.
Could you help take a look at my implementation? I think this change can benefit the user community who wants to use more complicated cameras (SimpleRadial couldn't handle the fisheye examples).
Thank you so much!
Ruibin