Skip to content

Instantly share code, notes, and snippets.

@pranny
Last active August 29, 2015 14:19
Show Gist options
  • Save pranny/2c899b643d5bda258f11 to your computer and use it in GitHub Desktop.
Save pranny/2c899b643d5bda258f11 to your computer and use it in GitHub Desktop.
Shell Script to do Sfm in OpenMVG
#!/bin/sh
# @author Pranav Prakash <pranny@gmail.com>
#
# this script is for easy use of OpenMVG
#
# usage : ./OpenMVG.sh image_dir output_dir
#
# image_dir is the input directory where images are located
# output_dir is where the project must be saved
#
# if output_dir is not present script will create it
#
# indicate the openMVG binary directory (must be changed)
BIN=/Users/pranav/workspace/openmvg/openMVG_Build/software/SfM/Release
PMVSBIN=/Users/pranav/workspace/CMVS-PMVS/binariesWin-Linux/mac_osx_fat
# indicate the openMVG camera sensor width directory (must be changed)
CAMERA_SENSOR_WIDTH_DIRECTORY=/Users/pranav/workspace/openmvg/openMVG/src/software/SfM/cameraSensorWidth
if [ $# -ne 2 ]
then
echo "Usage ./openmvg.sh image_dir output_dir"
exit 1
fi
INPUT_DIR=$1
OUTPUT_DIR=$2
CAMERA_FILE_PARAM=$CAMERA_SENSOR_WIDTH_DIRECTORY/cameraGenerated.txt
echo "Using input dir : \'$INPUT_DIR\'"
echo " output_dir : \'$OUTPUT_DIR\'"
# 0. Clean the output directory. Necessary to do computations everytime
rm -rf ${OUTPUT_DIR}/*
# 1. Intrisics analysis
${BIN}/openMVG_main_CreateList -f 767 -i ${INPUT_DIR} -d $CAMERA_FILE_PARAM -o ${OUTPUT_DIR}/matches
# 2. Compute matches
${BIN}/openMVG_main_computeMatches -i ${INPUT_DIR} -o ${OUTPUT_DIR}/matches -e -r 0.8 -p 0.01 -g f
# 3. Do reconstruction
${BIN}/openMVG_main_IncrementalSfM -i ${INPUT_DIR} -m ${OUTPUT_DIR}/matches -o ${OUTPUT_DIR}/outReconstruction -d 0 -c 1
# 4.
${BIN}/openMVG_main_openMVG2PMVS -i ${OUTPUT_DIR}/outReconstruction/SfM_output -o ${OUTPUT_DIR}/outReconstruction/SfM_output
# 5. Do PMVS
${PMVSBIN}/pmvs2 ${OUTPUT_DIR}/outReconstruction/SfM_output/PMVS/ pmvs_options.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment