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

ipmatch of 3 image/vwip files does not create all pairwise matches, overwrites first pairing each time #333

Closed AndrewAnnex closed 3 years ago

AndrewAnnex commented 3 years ago

Describe the bug Ipmatch when given 3 images and vwip files (aka img1.tif img1.vwip img2.tif img2.vwip img3.tif img3.vwip) does not appear to properly export all 3 pairwise combination match files as indicated in the documentation for ipmatch. Note that this is with the "--debug-image" flag enabled. It appears to use the same filenames for each pair and overwrites the results each iteration.

For each iteration, I can see that the different pairwise matches are correctly computed (text in stdout for "Matching between ..." is correct), but for each iteration the same .match filename and debug filename is used, overwriting the results from the previous pairwise comparison.

To Reproduce Steps to reproduce the behavior:

  1. run ipfind on 3 images
  2. run ipmatch img1.tif img1.vwip img2.tif img2.vwip img3.tif img3.vwip --debug-image
  3. look for 3 different .match files/debug images in the directory

Expected behavior expected 3 match files and debug images for each pair.

Error Logs, Terminal Captures, Screenshots here is the full stdout for the run, the file names are long but I believe I had everything correctly laid out (and yes I need more ip points for the ctx image)

(asp_may_2021) ➜  ctx_hirise_gcps ipmatch ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized.vrt ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized.vwip ./ESP_037267_1890_RED.mos_hijitreged.norm_normalized.vrt ./ESP_037267_1890_RED.mos_hijitreged.norm_normalized.vwip ./ESP_037834_1890_RED.mos_hijitreged.norm_normalized.vrt ./ESP_037834_1890_RED.mos_hijitreged.norm_normalized.vwip --debug-image --ransac-constraint homography
Matching between ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized.vrt (4867 points) and ./ESP_037267_1890_RED.mos_hijitreged.norm_normalized.vrt (145925 points).
Using distance metric: L2
Found 121 putative matches before duplicate removal.
Found 104 putative matches.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 34 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 22 of output inliers.
        --> Homography: Matrix3x3((-21.0932,2.74049,52781.8)(-2.64117,-21.3181,105557)(2.20767e-07,-2.59292e-07,1))
Found 23 final matches.
Writing match file: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.match
Writing debug image: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.tif
Matching between ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized.vrt (4867 points) and ./ESP_037834_1890_RED.mos_hijitreged.norm_normalized.vrt (166644 points).
Using distance metric: L2
Found 80 putative matches before duplicate removal.
Found 77 putative matches.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 25 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 16 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 10 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 6 of output inliers.
        --> Homography: Matrix3x3((-17.1943,2.31412,44661)(-2.4439,-19.4716,98863.2)(1.6531e-06,1.64339e-06,1))
Found 9 final matches.
Writing match file: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.match
Writing debug image: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.tif
Matching between ./ESP_037267_1890_RED.mos_hijitreged.norm_normalized.vrt (145925 points) and ./ESP_037834_1890_RED.mos_hijitreged.norm_normalized.vrt (166644 points).
Using distance metric: L2
Found 31426 putative matches before duplicate removal.
Found 27929 putative matches.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 9309 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 6206 of output inliers.
RANSAC was unable to find a fit that matched the supplied data.
Attempting RANSAC with 4137 of output inliers.
        --> Homography: Matrix3x3((0.814059,-0.00853383,1961.99)(0.00385591,0.906979,2259.37)(4.89025e-09,4.74579e-09,1))
Found 6084 final matches.
Writing match file: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.match
Writing debug image: ./B03_010644_1889_XN_08N001W_P02_001902_1889_XI_08N001W_map_ba_align_6_0-DRG_normalized__ESP_037267_1890_RED.mos_hijitreged.norm_normalized.tif

Your Environment (please complete the following information):

oleg-alexandrov commented 3 years ago

I put a fix. I also fixed a related issue for this tool when one specifies a non-empty --output-prefix. Now the behavior is just like for bundle_adjust, the match file gets written to output_prefix-img_iimg_j.match when the prefix is specified. If it is not specified, the match file is img_iimj_j.match. The debug image follows the same naming convention.

Our daily build can't be published because our web server is dead, but at some point this fix will make it to the public.

oleg-alexandrov commented 3 years ago

Andrew, thank you.