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
478 stars 168 forks source link

incorrect IP matches when running Bundle adjust with mapprojected data #341

Closed Adabian closed 2 years ago

Adabian commented 2 years ago

I am a beginner of ASP, recently i am trying to build DEM through this software. I use LROC NAC images with different illumination conditions and i want to run bundle adjust for each pairs at first. In this step, I will often meet this situations,it fail when i use original images(unmapprojected images) only.This step reports error:VW Error:Expected 2 cameras but crn has 0.I check that and find ip numbers does not reach the min matches(30).In the ASP book, I find that we can add ip matches for mapprojected images and use --mapprojected data option for bundle_adjust. Well,i add 5 ip for mapprojected images,after i run ba for original images use the option above,i check .match in Stereo_gui and it's not correct in original images. Another thing makes me confused is that it doesn't report errors during ba.I am not sure how to check if the ba process is accurate. Should i check this profile run_final_residuals_loss_function_raw_pixels.txt? How much residual is qualified? Here are my commands: 1.mapporject ref_dem.tif A.cub A_proj.tif mapporject ref_dem.tif B.cub B_proj.tif 2.stereo_gui A_proj.tif B_proj.tif run/run ( i add 5 ip match) 3.bundle_adjust A.cub B.cub --datum Moon --min-matches 1 -o run/run --mapprojected-data ' A_proj.tif B_proj.tif ref_dem.tif' 4.stereo_gui A.cub B.cub run/run ( the ip matches do not match each other in original images) Hope u to point out my mistake .Thanks a lot.

oleg-alexandrov commented 2 years ago

I just performed this exercise, and it works for me. I will suggest you make sure you save the matches at step 2. You can also try to read them back from disk after quitting the GUI, still before step 3, as:

stereo_gui A_proj.tif B_proj.tif run/run-A_proj__B_proj.match

Then, hopefully at step 3 the matches will be used from disk. Then, after step 3 you can try to see if the matches were unprojected properly with:

stereo_gui A.cub B.cub run/run-A__B.match

before going to step 4.

Note that if you already have the match file run/run-A__B.match or the one named run/run-A_proj__B_proj.match, then bundle adjustment won't create them, so they need to be deleted if you want to retry this option. This can be a little confusing, and I just added a note about this to the doc.

I just made a change to the GUI to remind the user to save the matches, but that should not affect what you are doing.

If still no luck, let me know.

On Wed, Oct 13, 2021 at 11:06 PM Adabian @.***> wrote:

I am a beginner of ASP, recently i am trying to build DEM through this software. I use LROC NAC images with different illumination conditions and i want to run bundle adjust for each pairs at first. In this step, I will often meet this situations,it fail when i use original images(unmapprojected images) only.This step reports error:VW Error:Expected 2 cameras but crn has 0.I check that and find ip numbers does not reach the min matches(30).In the ASP book, I find that we can add ip matches for mapprojected images and use --mapprojected data option for bundle_adjust. Well,i add 5 ip for mapprojected images,after i run ba for original images use the option above,i check .match in Stereo_gui and it's not correct in original images. Another thing makes me confused is that it doesn't report errors during ba.I am not sure how to check if the ba process is accurate. Should i check this profile run_final_residuals_loss_function_raw_pixels.txt? How much residual is qualified? Here are my commands: 1.mapporject ref_dem.tif A.cub A_proj.tif mapporject ref_dem.tif B.cub B_proj.tif 2.stereo_gui A_proj.tif B_proj.tif run/run ( i add 5 ip match) 3.bundle_adjust A.cub B.cub --datum Moon --min-matches 1 -o run/run --mapprojected-data ' A_proj.tif B_proj.tif ref_dem.tif' 4.stereo_gui A.cub B.cub run/run ( the ip matches do not match each other in original images) Hope u to point out my mistake .Thanks a lot.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NeoGeographyToolkit/StereoPipeline/issues/341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDU3HUEODCWPDGDIRVXDDUGZXORANCNFSM5F62GV6Q . 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.

Adabian commented 2 years ago

Hi,oleg I tried again and it was still not correct.The version of mine is 2.6.1. I posted my mapprojected images IP matches below. clipboard

There were 8 IP matches i manually added. after step 4, i checked the run-A__B.match clipboard2

I checked each IP matches and not matched. It seems that --mapprojected option does not work. Well, the transform from mapprojected space to image space is not clear for me. Would the format of mapprojected image(.tif) influence the transform?

oleg-alexandrov commented 2 years ago

I see.

When you run bundle adjustment and stereo (in fact, you can skip stereo for now), you should look carefully everywhere in the log (what it prints in the terminal) about whether it writes new match files or uses an existing (cached) match file. It should reuse matches. I hope it does not get confused somehow and creates its own matches.

The transform from mapprojected space to image space is the following. For each mapprojected pixel (i, j), its longitude and latitude is found, and from there the xyz position on the ground is found using the DEM, then xyz is projected into the camera. In short, you go from ground pixel to image pixel.

You can also try ASP 3.0.0, your version is kind of old, though I am not sure if we fixed anything there.

If no luck, you can share with me all your data (.cub files, mapprojected file, DEM file, the two match files) and I will take a look. This should be reproducible on a very small clip so one does not need to share a 1 GB cub file.

I hope you also wipe any existing directories if trying this again.

And I just repeated the map projection and bundle adjustment logic (no stereo) and it again works. Here's what bundle adjustment prints out for me, and hopefully you can compare with your own log.

bundle_adjust --datum D_MOON --min-matches 1 -o run/run M134980177LE.cal.echo.cub M1160064736LE.cal.echo.cub --mapprojected-data 'M134980177LE.cal.echo.map.tmp.tif M1160064736LE.cal.echo.map.tmp.tif tmp.tif'
Loading DEM: tmp.tif --> Using cached match file: run/run-M134980177LE.cal.echo.map.tmpM1160064736LE.cal.echo.map.tmp.match Reading: run/run-M134980177LE.cal.echo.map.tmpM1160064736LE.cal.echo.map.tmp.match Saving 2 matches. Writing: run/run-M134980177LE.cal.echo__M1160064736LE.cal.echo.match

Then I verified that the new match files aligned well with the original images.