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

Unexpected error from parallel_stereo using mapprojected images since 3.2.1 #409

Closed adehecq closed 10 months ago

adehecq commented 10 months ago

Describe the bug When I run parallel_stereo on a pair of mapprojected pinhole cameras, I get the following error:

The DEM used for map projection is different from the one provided on the command line.

I'm using version 3.2.1-alpha-2023-07-25-x86_64-Linux. Running the same command using the previous version I had (3.1.1-alpha-2022-08-02-x86_64-Linux) does not return any error. The error also does not seem to show up for a different case with a different input DEM.

I checked the metadata of the input images, for both of them, the DEM_FILE tag is the same as the input DEM in the command, i.e. "dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif"

To Reproduce The full command is

parallel_stereo --threads-multiprocess 8 --threads-singleprocess 16 --processes 2 --alignment-method none \
--stereo-algorithm 2 --corr-tile-size 5000 --corr-memory-limit-mb 55000 --corr-kernel 7 7 --xcorr-threshold 2 \
--save-left-right-disparity-difference \
img1.map.tif img2.map.tif img1_cam.tsai img2_cam.tsai outPrefix \
dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif --stop-point 5

The input images are ~2GB each but I can share them if useful to reproduce the error.

Expected behavior The command should proceed without error.

Your Environment (please complete the following information):

NASA Ames Stereo Pipeline 3.2.1-alpha Build ID: 97b1980a Build date: 2023-07-25

Built against: NASA Vision Workbench 3.2.1-alpha Build ID: 567ac71f USGS ISIS 7.1.0 Boost C++ Libraries 1.72.0 GDAL 3.5.3 | 20221027

Full traceback

--> Setting number of processing threads to: 4 Stereo file ./stereo.default could not be found. Will use default settings and command line options only. num_stereo_pairs,1 Using session: pinholemappinhole The DEM used for map projection is different from the one provided on the command line. Traceback (most recent call last): File "/home/adehecq/bin/StereoPipeline-3.2.1-alpha-2023-07-25-x86_64-Linux/libexec/parallel_stereo", line 898, in settings = run_and_parse_output("stereo_parse", args, sep, opt.verbose) File "/home/adehecq/bin/StereoPipeline-3.2.1-alpha-2023-07-25-x86_64-Linux/libexec/asp_system_utils.py", line 298, in run_and_parse_output raise Exception('Failed executing: ' + " ".join(call))

Thank you!

oleg-alexandrov commented 10 months ago

I cannot reproduce the issue. There's a chance I introduced some inconsistency with previously created data, maybe, but I am not sure how. My own tests were passing after I messed up recently with logic when it comes to mapprojection.

I will suggest making a crop of your DEM to save time, and then run the following recipe, and see what you get. This is the same thing as you wrote to me, but just with all work done at the same time. I will also suggest using the latest build, just in case:

mapproject dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif img1.tif img1_cam.tsai img1.map.tif

mapproject dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif img2.tif img2_cam.tsai img2.map.tif

parallel_stereo --threads-multiprocess 8 --threads-singleprocess 16 --processes 2 --alignment-method none \ --stereo-algorithm 2 --corr-tile-size 5000 --corr-memory-limit-mb 55000 --corr-kernel 7 7 --xcorr-threshold 2 \ --save-left-right-disparity-difference \ img1.map.tif img2.map.tif img1_cam.tsai img2_cam.tsai outPrefix \ dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif --stop-point 5

On Wed, Aug 30, 2023 at 5:03 AM Amaury Dehecq @.***> wrote:

Describe the bug When I run parallel_stereo on a pair of mapprojected pinhole cameras, I get the following error:

The DEM used for map projection is different from the one provided on the command line.

I'm using version 3.2.1-alpha-2023-07-25-x86_64-Linux. Running the same command using the previous version I had (3.1.1-alpha-2022-08-02-x86_64-Linux) does not return any error. The error also does not seem to show up for a different case with a different input DEM.

I checked the metadata of the input images, for both of them, the DEM_FILE tag is the same as the input DEM in the command, i.e. "dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif"

To Reproduce The full command is

parallel_stereo --threads-multiprocess 8 --threads-singleprocess 16 --processes 2 --alignment-method none \ --stereo-algorithm 2 --corr-tile-size 5000 --corr-memory-limit-mb 55000 --corr-kernel 7 7 --xcorr-threshold 2 \ --save-left-right-disparity-difference \ img1.map.tif img2.map.tif img1_cam.tsai img2_cam.tsai outPrefix \ dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif --stop-point 5

The input images are ~2GB each but I can share them if useful to reproduce the error.

Expected behavior The command should proceed without error.

Your Environment (please complete the following information):

  • OS: Linux 4.18.0-425.13.1.el8_7.x86_64
  • ASP Version:

NASA Ames Stereo Pipeline 3.2.1-alpha Build ID: 97b1980 https://github.com/NeoGeographyToolkit/StereoPipeline/commit/97b1980ad3dc3627c8dd5c77583e21544d7eb785 Build date: 2023-07-25

Built against: NASA Vision Workbench 3.2.1-alpha Build ID: 567ac71f USGS ISIS 7.1.0 Boost C++ Libraries 1.72.0 GDAL 3.5.3 | 20221027

Thank you!

— Reply to this email directly, view it on GitHub https://github.com/NeoGeographyToolkit/StereoPipeline/issues/409, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDU3GNOFSPQX5MDNJVFZ3XX4TX7ANCNFSM6AAAAAA4EM34WI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

adehecq commented 10 months ago

Thanks Oleg for checking this.

First of all, I tested with the latest release (3.3.0) and I have the same issue. After making a lot of different tests where I could not reproduce my error, I finally found the problem! It's because in the path to my external DEM, there is a double slash (//) somewhere. If I remove this double slash, the error goes away... What is strange is that the double slash is used consistently between the mapproject and parallel_stereo calls, so one of them must treat it differently since version 3.2.1.

oleg-alexandrov commented 10 months ago

This makes sense. I found in the code the part where the double slash was replaced with a single slash and wiped that code. Double slashes are not pretty, but if the user insists on having them, that's their problem. :)

The funny thing is that the problematic code is very old. It was not triggered so far because it is only recently the check for exact DEM match between mapproject and stereo was introduced.

oleg-alexandrov commented 10 months ago

I also made the error message more helpful. Now it says:

The DEM used for map projection is different from the one provided on the command line. Left image DEM: path//dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif Right image DEM: path/dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif Command line DEM: path/dem_GLODEM_RussianArctic_30m_epsg3413_filled.tif

adehecq commented 10 months ago

Hi Oleg,

Haha, I don't insist on having double slashes, but they tend to appear a lot depending on whether or not I have a trailing slash at the end of the arguments to my own wrappers. I've added some checks internally to avoid them, but I'm handling hundreds of paths within this script so it's not bulletproof. In any case, I was actually gonna suggest to print the DEM paths along with the error, it helps understanding what went wrong! Thanks for all the edits!