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
492 stars 173 forks source link

rpc distortion + floating rpc's #300

Closed jchollingsworth closed 1 year ago

jchollingsworth commented 4 years ago

When converting tsai distortion camera to rpc with convert_pinhole_model, the RPC output coefficients were all 1's or 0's, which means they won't float unless their precision is manually updated. Not a big deal, but thought I'd point it out, as it's not necessarily useful to output these to values which won't float.

In addition, I noticed that my tsai distortions all defaulted to a 1's and o's in my RPC distortion model. I'm not sure if this is because convert_pinhole_model rounds to whole numbers, an so decimal values of k1, k2, p1, p2 are rounded to 0...? Not sure.... maybe you could check this.

Also, it would be good to be able to include an option like --penalty-weight (from cam2rpc), whereby we can suppress higher-order RPC coefficients.

Cheers, J

ScottMcMichael commented 4 years ago

Could you post the input camera models and command line calls where you see this happening?

jchollingsworth commented 4 years ago

I have uploaded the files here: https://drive.google.com/open?id=0B9agI6whXP-oczJvLWYwRFZMYm8 (I also sent you a separate link to directly download the tarball).

If you download everything there, you should be able to run launch_ba.sh directly from the download folder and reproduce the problem I had.

The launch script simply contains 2 parts:

  1. converts the pinhole tsai cameras to rpc (using convert_pinhole_model)... so you can see how that's performing. (manually update the precision of the 1's and 0's so they can be floated later).
  2. bundle_adjust run for the relevant images, and rpc cameras... I currently share the distortion parameters (though eventually I want to solve individually, as I think each image has its own unique warp). I also use heights-from-dem (dem file is thus included), which forces the height values to keep close to the reference. I also use some dense matches I generate earlier on, using stereo_tri. I don't include the script, only the actual matches (which are located in ba1/ba1-*.matches).

Hopefully everything should make sense.

Finally, I add a directory: b1_bad_output This contains the camera outputs following bundle_adjust when I ran it. The RPC distortion coefficients look reasonable... but the undistortion coefficients are wrong.

jchollingsworth commented 4 years ago

Just a small additional... ... I get the same problem with the failure of bundle_adjust to solve the undistortion coeffs even when I let it run to convergence (I suddenly wondered if that could have been a problem, but it isn't).

Here's a snippet of the output from ba... you can see the error is high with the undistortion approximation: RPC undistortion approximation mean pixel error is 11.5888 and max pixel error is 43.0923. Writing output model: Pinhole camera: Camera Center: Vector3(-2.34099e+06,-4.68511e+06,3.6364e+06) Rotation Matrix: Q Intrinsics: focal: Vector2(4950,4950) offset: Vector2(2972,2311) pixel pitch: 1 u direction: Vector3(1,0,0) v direction: Vector3(0,1,0) w direction: Vector3(0,0,1) Distortion Model: RPC rpc_degree = 3 image_size = 5944 4622 distortion_num_x = 1e-25 1.00606 1e-25 1e-25 1e-25 1e-25 1e-25 1e-25 1e-25 1e-25 distortion_den_x = 1 1e-25 1e-25 1e-25 1e-25 1e-25 -8.23979e-14 3.60032e-14 -1.44859e-13 9.40226e-14 distortion_num_y = 1e-25 1e-25 1.00536 1e-25 1e-25 1e-25 1e-25 1e-25 1e-25 1e-25 distortion_den_y = 1 1e-25 1e-25 1e-25 1e-25 1e-25 -1.13802e-13 6.62899e-14 -6.82518e-14 3.20568e-14 undistortion_num_x = 0 1 0 0 0 0 0 0 0 0 undistortion_den_x = 1 0 0 0 0 0 0 0 0 0 undistortion_num_y = 0 0 1 0 0 0 0 0 0 0 undistortion_den_y = 1 0 0 0 0 0 0 0 0 0

oleg-alexandrov commented 1 year ago

I think this got fixed as it was reported separately at some point.