Skip to content

Instantly share code, notes, and snippets.

@carlosb1
Created February 19, 2016 08:50
Show Gist options
  • Save carlosb1/5fd42b360620370f5e36 to your computer and use it in GitHub Desktop.
Save carlosb1/5fd42b360620370f5e36 to your computer and use it in GitHub Desktop.
#!/bin/bash
OPENMVG_SFM_BIN="/home/carlos/c-workspace/openMVG_Build/Linux-x86_64-RELEASE"
# Indicate the openMVG camera sensor width directory
CAMERA_SENSOR_WIDTH_DIRECTORY="/home/carlos/c-workspace/openMVG/src/openMVG/exif/sensor_width_database"
CAMERA_SENSORS_FILE="$CAMERA_SENSOR_WIDTH_DIRECTORY/sensor_width_camera_database.txt"
OPENMVG_SFMINIT_IMAGE_LISTING="$OPENMVG_SFM_BIN/openMVG_main_SfMInit_ImageListing"
OPENMVG_COMPUTE_FEATURES="$OPENMVG_SFM_BIN/openMVG_main_ComputeFeatures"
OPENMVG_COMPUTE_MATCHES="$OPENMVG_SFM_BIN/openMVG_main_ComputeMatches"
OPENMVG_GLOBAL_SFM="$OPENMVG_SFM_BIN/openMVG_main_GlobalSfM"
OPENMVG_COMPUTESFM_DATACOLOR="$OPENMVG_SFM_BIN/openMVG_main_ComputeSfM_DataColor"
OPENMVG_COMPUTE_STRUCTURE_FROM_KNOWN_POSES="$OPENMVG_SFM_BIN/openMVG_main_ComputeStructureFromKnownPoses"
OPENMVG_EXPORT_COMMAND="$OPENMVG_SFM_BIN/openMVG_main_openMVG2MVE2"
ARGS=2
#Parse arguments
if [ "$#" -lt "$ARGS" ]
then
echo "Usage: `basename $0` [-mve_recons [filename.json]] input_folder output_dir"
exit $E_BADARGS
fi
if [ $1 == "-mve_recons" ]
then
output_dir=$2
reconstruction_dir="$output_dir"
filename_json="$reconstruction_dir/robust.json"
if [ "$#" == "3" ]
then
filename_json=$3
fi
OPENMVG_PARAMS_RECONSTR="-i $filename_json -o $reconstruction_dir/MVE"
$OPENMVG_EXPORT_COMMAND $OPENMVG_PARAMS_RECONSTR
exit 0
fi
ARGS=2
if [ "$#" -lt "$ARGS" ]
then
echo "Usage: `basename $0` [-mve_recons] input_folder output_dir"
exit $E_BADARGS
fi
input_folder=$1
output_dir=$2
#Check parameters
if [ ! -d "$output_dir" ]; then
echo "Target directory doesn't exist"
echo "Creating new directory..."
mkdir -p $output_dir
fi
if [ ! -d "$input_folder" ]; then
echo "First argument is not an input folder"
exit $E_INCORRECT_FOLDER
fi
reconstruction_dir="$output_dir/reconstruction"
matches_dir="$output_dir/matches"
if [ ! -d "$matches_dir" ]; then
echo "matches directory doesn't exist"
echo "Creating new directory..."
mkdir -p $matches_dir
fi
#OPENMVG_PARAMS_SFMINIT="-i $input_folder -o $matches_dir -d $CAMERA_SENSORS_FILE"
OPENMVG_PARAMS_SFMINIT="-i $input_folder -o $matches_dir -f 4992"
#Changing feature extractor
OPENMVG_PARAMS_COMPUTE_FEATURES="-i $matches_dir/sfm_data.json -o $matches_dir -m AKAZE_MLDB"
OPENMVG_PARAMS_COMPUTE_MATCHES="-i $matches_dir/sfm_data.json -o $matches_dir -g e"
#execute commands
$OPENMVG_SFMINIT_IMAGE_LISTING $OPENMVG_PARAMS_SFMINIT
$OPENMVG_COMPUTE_FEATURES $OPENMVG_PARAMS_COMPUTE_FEATURES
$OPENMVG_COMPUTE_MATCHES $OPENMVG_PARAMS_COMPUTE_MATCHES
if [ ! -d "$reconstruction_dir" ]; then
echo "reconstruction directory doesn't exist"
echo "Creating new directory..."
mkdir -p $reconstruction_dir
fi
OPENMVG_PARAMS_GLOBALSFM="-i $matches_dir/sfm_data.json -m $matches_dir -o $reconstruction_dir"
OPENMVG_PARAMS_DATACOLOR="-i $reconstruction_dir/sfm_data.json -o $reconstruction_dir/colorized.ply"
OPENMVG_PARAMS_KNOWPOSES="-i $reconstruction_dir/sfm_data.json -m $matches_dir -f $matches_dir/matches.e.txt -o $reconstruction_dir/robust.json"
OPENMVG_PARAMS_ROBUST_DATACOLOR="-i $reconstruction_dir/robust.json -o $reconstruction_dir/robust_colorized.ply"
$OPENMVG_GLOBAL_SFM $OPENMVG_PARAMS_GLOBALSFM
$OPENMVG_COMPUTESFM_DATACOLOR $OPENMVG_PARAMS_DATACOLOR
$OPENMVG_COMPUTE_STRUCTURE_FROM_KNOWN_POSES $OPENMVG_PARAMS_KNOWPOSES
$OPENMVG_COMPUTESFM_DATACOLOR $OPENMVG_PARAMS_ROBUST_DATACOLOR
OPENMVG_PARAMS_RECONSTR="-i $reconstruction_dir/robust.json -o $reconstruction_dir/MVE"
$OPENMVG_EXPORT_COMMAND $OPENMVG_PARAMS_RECONSTR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment