NeoGeographyToolkit / StereoPipeline

The NASA Ames Stereo Pipeline is a suite of automated geodesy & stereogrammetry tools designed for processing planetary imagery captured from orbiting and landed robotic explorers on other planets.
Apache License 2.0
479 stars 169 forks source link

RPC distortion and camera center #247

Closed oleg-alexandrov closed 5 years ago

oleg-alexandrov commented 5 years ago

The RPC lens distortion model assumes the origin to be at pixel (0, 0) rather than at the image optical center. This does not make it less expressive, but makes it trickier to interpret the result. It may be helpful to make it more compatible with our other distortion models which use the optical center. For now, the convert_pinhole_model tool should still convert any camera model to RPC distortion with no issue though.

ValentinSchmittDeer commented 2 years ago

Hello,

Such a thing may be interesting. I wanted to create a direct conversion from Brown-Conrady (or Photometrix) to lens distortion RPC (DRPC). All basic coefficients (Ki, Pi) of these standard models can be decomposed to DRPC numerator except the offset. If it is so, it would be useful to know the polynomial order convention (list of power order) since it depends on libraries. Hence, if it would be possible to manage a distortion center coordinate (Xs, Ys), we could replace the RPC approximation by an equivalence and make use of coefficients equal to 0: Xd=X-Xs Xu=(0 + X.1 + Yd.0 + ... + Xd2.(P1+2.P1) + Xd.Yd.(2.P2) + ... + Xd3.(K1) +Xd.Yd**2.(K1) ...) / 1

Thank you

oleg-alexandrov commented 2 years ago

You can read some of the code to see how Brown Conrady distortion is handled vs RPC distortion, by comparing, for example:

https://github.com/visionworkbench/visionworkbench/blob/master/src/vw/Camera/LensDistortion.cc#L388

vs

https://github.com/visionworkbench/visionworkbench/blob/master/src/vw/Camera/LensDistortion.cc#L696

Note that for Brown-Conrady the undistortion is given by a formula, so the distortion has to invert that nonlinear function, while for RPC we fit RPC polynomials for both distortion and distortion.

The AdjustableTsaiLensDistortion, also in there, is how things are done more traditionally in the computer vision community. There exist radial and tangential distortion, and it is the distortion operation which is given by a formula, and then undistortion has to invert that.

On Mon, Oct 18, 2021 at 10:20 AM ValentinSchmittDeer < @.***> wrote:

Hello,

Such a thing may be interesting. I wanted to create a direct conversion from Brown-Conrady (or Photometrix) to lens distortion RPC (DRPC). All basic coefficients (Ki, Pi) of these standard models can be decomposed to DRPC numerator except the offset. If it is so, it would be useful to know the polynomial order convention (list of power order) since it depends on libraries. Hence, if it would be possible to manage a distortion center coordinate (Xs, Ys), we could replace the RPC approximation by an equivalence and make use of coefficients equal to 0: Xd=X-Xs Xu=(0 + X.1 + Yd.0 + ... + Xd2.(P1+2.P1) + Xd.Yd.(2.P2) + ... + Xd3.(K1) +Xd.Yd**2.(K1) ...) / 1

Thank you

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/NeoGeographyToolkit/StereoPipeline/issues/247#issuecomment-945993396, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDU3D5GRBG47YXPOXW77LUHRJOTANCNFSM4G7LWM6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ValentinSchmittDeer commented 2 years ago

Thank you very much for your answer. I saw that the principal point is already used as coordinate offset with RPC distortion and the polynomial order is easy to figure out. I also found exactly what I what I was seeking in the code about the TSAI model.

Personally, I thing that the documentation might need to be adjusted in the section Frame camera / Pinhole model / Overview. The equation gives a good idea of the implementation but it misses some entering or outgoing formulas like this one: https://github.com/visionworkbench/visionworkbench/blob/672f7f8205cbdc60c5f8eec598bff74cfe943f5e/src/vw/Camera/LensDistortion.cc#L310

Thank you

oleg-alexandrov commented 2 years ago

Thanks, good points. I modified the Tsai distortion formula to add the shift which was missing at the end.

There's more to be done, in fact some very careful work needs to be done to cross-reference these formulas with the code and literature references, which I don't have time for now. I added a blurb however referring the reader to the right code, should somebody wish to get to the bottom of things.

On Tue, Oct 19, 2021 at 2:21 AM ValentinSchmittDeer < @.***> wrote:

Thank you very much for your answer. I saw that the principal point is already used as coordinate offset with RPC distortion and the polynomial order is easy to figure out. I also found exactly what I what I was seeking in the code about the TSAI model.

Personally, I thing that the documentation might need to be adjusted in the section Frame camera / Pinhole model / Overview. The equation gives a good idea of the implementation but it misses some entering or outgoing formulas like this one:

https://github.com/visionworkbench/visionworkbench/blob/672f7f8205cbdc60c5f8eec598bff74cfe943f5e/src/vw/Camera/LensDistortion.cc#L310

Thank you

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/NeoGeographyToolkit/StereoPipeline/issues/247#issuecomment-946525042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDU3AYOUNDA2Z7AYD6LQLUHU2CJANCNFSM4G7LWM6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.