From 4775610f16ab29aab0b58447c71fcf1365bec097 Mon Sep 17 00:00:00 2001 From: Pau Gargallo Date: Wed, 28 Jan 2015 13:32:32 +0100 Subject: [PATCH] Update images' GPS after reconstrucion. Former-commit-id: e10f2362c42e9390cf012ebb9d374948be01c64f --- run.pl | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/run.pl b/run.pl index 94119556..951d6e00 100755 --- a/run.pl +++ b/run.pl @@ -30,6 +30,7 @@ if(!File::Spec->file_name_is_absolute($BIN_PATH_REL)){ require "$BIN_PATH_ABS/ccd_defs.pl"; $BIN_PATH = $BIN_PATH_ABS."/bin"; +$OPENSFM_PATH = $BIN_PATH_ABS."/src/OpenSfM"; my %objectStats = { count => 0, @@ -70,7 +71,7 @@ sub parseArgs { $args{"--resize-to"} = "3000"; $args{"--start-with"} = "resize"; - $args{"--end-with"} = "pmvs"; + $args{"--end-with"} = "gpsAlign"; $args{"--cmvs-maxImages"} = 100; @@ -96,25 +97,23 @@ sub parseArgs { } } if($ARGV[$i] eq "--start-with"){ - if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs"){ - $args{$ARGV[$i]} = $ARGV[$i+1]; + if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs" || $ARGV[$i+1] eq "gpsAlign"){$args{$ARGV[$i]} = $ARGV[$i+1]; } else { - die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\""; + die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\", \"gpsAlign\""; } } if($ARGV[$i] eq "--end-with"){ - if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs"){ + if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs" || $ARGV[$i+1] eq "gpsAlign"){ $args{$ARGV[$i]} = $ARGV[$i+1]; } else { - die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\""; - } + die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\", \"gpsAlign\""; } } if($ARGV[$i] eq "--run-only"){ - if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs"){ + if($ARGV[$i+1] eq "resize" || $ARGV[$i+1] eq "getKeypoints" || $ARGV[$i+1] eq "match" || $ARGV[$i+1] eq "bundler" || $ARGV[$i+1] eq "cmvs" || $ARGV[$i+1] eq "pmvs" || $ARGV[$i+1] eq "gpsAlign"){ $args{"--start-with"} = $ARGV[$i+1]; $args{"--end-with"} = $ARGV[$i+1]; } else { - die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\""; + die "\n invalid parameter for \"".$ARGV[$i]."\": ".$ARGV[$i+1]."\n\t valid values are \"resize\", \"getKeypoints\", \"match\", \"bundler\", \"cmvs\", \"pmvs\", \"gpsAlign\""; } } if($ARGV[$i] eq "--matcher-threshold"){ @@ -207,17 +206,17 @@ sub parseArgs { print "\n if \"--resize-to orig\" is used it will use the images without resizing"; print "\n "; - print "\n --start-with: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\">"; + print "\n --start-with: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\"|\"gpsAlign\">"; print "\n default: resize"; print "\n will start the sript at the specified step"; print "\n "; - print "\n --end-with: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\">"; - print "\n default: pmvs"; + print "\n --end-with: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\"|\"gpsAlign\">"; + print "\n default: gpsAlign"; print "\n will stop the sript after the specified step"; print "\n "; - print "\n --run-only: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\">"; + print "\n --run-only: <\"resize\"|\"getKeypoints\"|\"match\"|\"bundler\"|\"cmvs\"|\"pmvs\"|\"gpsAlign\">"; print "\n will only execute the specified step"; print "\n equal to --start-with --end-with "; print "\n "; @@ -639,6 +638,10 @@ sub pmvs { run("\"$BIN_PATH/pmvs2\" pmvs/ option-0000"); system("cp -Rf \"$jobOptions{jobDir}/pmvs/models\" \"$jobOptions{jobDir}-results\""); + + if($args{"--end-with"} ne "pmvs"){ + gpsAlign(); + } } sub gpsAlign { @@ -649,18 +652,19 @@ sub gpsAlign { chdir($jobOptions{jobDir}); # Create opensfm working folder - mkdir($jobOptions{jobDir}/opensfm); + mkdir("opensfm"); # Convert bundle.out to opensfm - run("\"$OPENSFM_PATH/bin/import_bundler\" . --list ../list.txt --bundleout ../bundle/bundle.out"); + run("\"$OPENSFM_PATH/bin/import_bundler\" opensfm --list list.txt --bundleout bundle/bundle.out"); # Align reconstruction.json - run("\"$OPENSFM_PATH/bin/align\" ."); + run("\"$OPENSFM_PATH/bin/align\" opensfm"); # Write corrected GPS to images - run("\"$OPENSFM_PATH/bin/update_geotag\" ."); + run("\"$OPENSFM_PATH/bin/update_geotag\" opensfm"); } + parseArgs(); prepareObjects(); @@ -673,6 +677,7 @@ switch ($args{"--start-with"}) { case "bundler" { bundler(); } case "cmvs" { cmvs(); } case "pmvs" { pmvs(); } + case "gpsAlign" { gpsAlign(); } } print "\n";