OpenDroneMap-ODM/install.sh

338 wiersze
9.5 KiB
Bash
Czysty Zwykły widok Historia

2010-10-30 11:49:56 +00:00
#!/bin/bash
set -o nounset
set -o errexit
2010-11-02 16:11:07 +00:00
2010-11-03 00:55:48 +00:00
echo
echo " created by Daniel Schwarz/daniel.schwarz@topoi.org"
2011-06-14 17:26:57 +00:00
echo " released under Creative Commons/CC-BY"
2011-06-14 17:30:05 +00:00
echo " Attribution"
2010-11-03 00:55:48 +00:00
echo
2010-11-09 23:40:25 +00:00
echo " if the script doesn't finish properly"
echo " (i.e. it doesn't print \"script finished\" at the end)"
2010-11-03 00:55:48 +00:00
echo " please email me the content of the logs folder"
echo
2010-11-03 17:49:42 +00:00
echo
echo " - script started - `date`"
2010-10-30 11:49:56 +00:00
## dest base path
2011-11-02 13:10:11 +00:00
TOOLS_PATH="$PWD"
## paths for the tools
TOOLS_BIN_PATH="$TOOLS_PATH/bin"
TOOLS_INC_PATH="$TOOLS_PATH/include"
TOOLS_LIB_PATH="$TOOLS_PATH/lib"
TOOLS_SRC_PATH="$TOOLS_PATH/src"
TOOLS_LOG_PATH="$TOOLS_PATH/logs"
TOOLS_PATCHED_PATH="$TOOLS_PATH/patched_files"
2011-11-02 13:10:11 +00:00
## loacal dest paths
2011-11-02 13:10:11 +00:00
LIB_PATH="/usr/local/lib"
INC_PATH="/usr/local/include"
## source paths
2011-11-02 13:10:11 +00:00
BUNDLER_PATH="$TOOLS_SRC_PATH/bundler"
CMVS_PATH="$TOOLS_SRC_PATH/cmvs"
PMVS_PATH="$TOOLS_SRC_PATH/pmvs"
CLAPACK_PATH="$TOOLS_SRC_PATH/clapack"
VLFEAT_PATH="$TOOLS_SRC_PATH/vlfeat"
PARALLEL_PATH="$TOOLS_SRC_PATH/parallel"
PSR_PATH="$TOOLS_SRC_PATH/PoissonRecon"
GRACLUS_PATH="$TOOLS_SRC_PATH/graclus"
## executables
2011-11-02 13:10:11 +00:00
EXTRACT_FOCAL="$TOOLS_BIN_PATH/extract_focal.pl"
MATCHKEYS="$TOOLS_BIN_PATH/KeyMatch"
MATCHKEYSFULL="$TOOLS_BIN_PATH/KeyMatchFull"
BUNDLER="$TOOLS_BIN_PATH/bundler"
BUNDLE2PVMS="$TOOLS_BIN_PATH/Bundle2PMVS"
CMVS="$TOOLS_BIN_PATH/cmvs"
PMVS="$TOOLS_BIN_PATH/pmvs2"
GENOPTION="$TOOLS_BIN_PATH/genOption"
VLSIFT="$TOOLS_BIN_PATH/vlsift"
PARALLEL="$TOOLS_BIN_PATH/parallel"
PSR="$TOOLS_BIN_PATH/PoissonRecon"
VLSIFT_TO_LOWESIFT="$TOOLS_BIN_PATH/convert_vlsift_to_lowesift.pl"
## get sys vars
2010-10-30 11:49:56 +00:00
ARCH=`uname -m`
2010-11-09 23:40:25 +00:00
CORES=`grep -c processor /proc/cpuinfo`
2010-11-03 17:49:42 +00:00
## prevents different (localized) output
LC_ALL=C
2010-11-03 00:55:48 +00:00
## removing old stuff
2011-10-08 19:24:30 +00:00
sudo rm -Rf "$TOOLS_BIN_PATH"
sudo rm -Rf "$TOOLS_INC_PATH"
sudo rm -Rf "$TOOLS_LIB_PATH"
sudo rm -Rf "$TOOLS_SRC_PATH"
sudo rm -Rf "$TOOLS_LOG_PATH"
2010-11-03 00:55:48 +00:00
## create needed directories
2010-11-09 23:40:25 +00:00
mkdir -p "$TOOLS_BIN_PATH"
mkdir -p "$TOOLS_INC_PATH"
mkdir -p "$TOOLS_LIB_PATH"
mkdir -p "$TOOLS_SRC_PATH"
mkdir -p "$TOOLS_LOG_PATH"
2010-11-03 00:55:48 +00:00
## output sys info
2010-11-09 23:40:25 +00:00
echo "System info:" > "$TOOLS_LOG_PATH/sysinfo.txt"
uname -a > "$TOOLS_LOG_PATH/sysinfo.txt"
2010-11-03 00:55:48 +00:00
## install packages
2010-10-30 11:49:56 +00:00
echo
2010-11-09 23:40:25 +00:00
echo " > installing required packages"
2010-10-30 11:49:56 +00:00
2010-11-09 23:40:25 +00:00
echo " - updating"
2014-05-22 13:16:46 +00:00
sudo apt-get update --assume-yes > "$TOOLS_LOG_PATH/apt-get_get.log" 2>&1
2010-11-09 23:40:25 +00:00
echo " - installing"
2010-11-03 20:25:57 +00:00
sudo apt-get install --assume-yes --install-recommends \
build-essential cmake g++ gcc gFortran perl ruby rubygems git \
curl wget \
unzip \
imagemagick jhead \
libjpeg-dev libboost-dev libgsl0-dev libx11-dev libxext-dev liblapack-dev \
libzip-dev \
2011-11-02 13:10:11 +00:00
libcv-dev libcvaux-dev \
2014-05-22 13:16:46 +00:00
> "$TOOLS_LOG_PATH/apt-get_install.log" 2>&1
2014-05-22 13:16:46 +00:00
sudo gem install parallel > /dev/null 2>&1
2010-10-30 11:49:56 +00:00
2010-11-09 23:40:25 +00:00
echo " < done - `date`"
2010-11-03 00:55:48 +00:00
## downloading sources
2010-10-30 11:49:56 +00:00
echo
2010-11-09 23:40:25 +00:00
echo " > getting the sources"
2010-11-03 02:36:02 +00:00
2010-11-09 23:40:25 +00:00
## getting all archives if not already present; save them to .tmp and rename them after download
while read target source
do
if [ ! -f "$target" ] ; then
echo " - getting $source"
curl --progress-bar --location -o "$target.tmp" "$source"
mv "$target.tmp" "$target"
echo " - finished $target"
echo
else
echo " - already downloaded $source"
fi
2010-11-09 23:40:25 +00:00
done <<EOF
parallel.tar.bz2 http://ftp.gnu.org/gnu/parallel/parallel-20100922.tar.bz2
clapack.tgz http://www.netlib.org/clapack/clapack-3.2.1-CMAKE.tgz
bundler.zip http://phototour.cs.washington.edu/bundler/distr/bundler-v0.4-source.zip
2010-11-09 23:40:25 +00:00
PoissonRecon.zip http://www.cs.jhu.edu/~misha/Code/PoissonRecon/Version2/PoissonRecon.zip
vlfeat.tar.gz http://www.vlfeat.org/download/vlfeat-0.9.13-bin.tar.gz
2013-05-15 12:37:08 +00:00
cmvs.tar.gz http://www.di.ens.fr/cmvs/cmvs-fix2.tar.gz
2014-04-28 16:01:45 +00:00
graclus.tar.gz http://smathermather.github.io/BundlerTools/patched_files/src/graclus/graclus1.2.tar.gz
2010-11-09 23:40:25 +00:00
EOF
echo " < done - `date`"
2010-11-03 00:55:48 +00:00
2010-11-03 02:36:02 +00:00
## unzipping sources
2010-10-30 11:49:56 +00:00
echo
2010-11-03 00:55:48 +00:00
echo " - unzipping sources"
2010-10-30 11:49:56 +00:00
2010-11-09 23:40:25 +00:00
for i in *.tar.bz2 ; do
2014-05-22 13:16:46 +00:00
tar xjf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
2010-11-09 23:40:25 +00:00
done
for i in *.tgz *.tar.gz ; do
2014-05-22 13:16:46 +00:00
tar xzf "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
2010-11-09 23:40:25 +00:00
done
for i in *.zip ; do
2014-05-22 13:16:46 +00:00
unzip "$i" > "$TOOLS_LOG_PATH/extract_$i.log" 2>&1 &
2010-11-09 23:40:25 +00:00
done
2010-10-30 11:49:56 +00:00
2010-11-03 00:55:48 +00:00
wait
2010-11-09 23:40:25 +00:00
2011-11-02 13:10:11 +00:00
mv -f graclus1.2 "$GRACLUS_PATH"
mv -f clapack-3.2.1-CMAKE "$CLAPACK_PATH"
mv -f vlfeat-0.9.13 "$VLFEAT_PATH"
mv -f bundler-v0.4-source "$BUNDLER_PATH"
mv -f parallel-20100922 "$PARALLEL_PATH"
mv -f PoissonRecon "$PSR_PATH"
2011-11-02 13:10:11 +00:00
mv -f cmvs "$CMVS_PATH"
2010-10-30 11:49:56 +00:00
2011-10-08 19:24:30 +00:00
echo " < done - `date`"
## copying patches
echo
echo " - copying patches"
2011-11-22 12:52:47 +00:00
echo
2011-10-08 19:24:30 +00:00
for file in `find $TOOLS_PATCHED_PATH -type f -print` ; do
cp $file $TOOLS_PATH/${file/$TOOLS_PATCHED_PATH/.}
2011-10-08 19:24:30 +00:00
done
echo " < done - `date`"
2010-10-30 11:49:56 +00:00
2010-11-03 17:49:42 +00:00
# building
2010-10-30 11:49:56 +00:00
echo
2010-11-11 19:21:29 +00:00
echo " - building"
echo
2010-10-30 11:49:56 +00:00
sudo chown -R `id -u`:`id -g` *
2014-05-23 15:40:51 +00:00
#sudo chmod -R 777 *
2010-10-30 11:49:56 +00:00
2010-11-09 23:40:25 +00:00
2011-11-02 13:10:11 +00:00
echo " > graclus"
cd "$GRACLUS_PATH"
if [ "$ARCH" = "i686" ]; then
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=32"
fi
if [ "$ARCH" = "x86_64" ]; then
sed -i "$GRACLUS_PATH/Makefile.in" -e "11c\COPTIONS = -DNUMBITS=64"
fi
echo " - cleaning graclus"
2014-05-22 13:16:46 +00:00
make clean > "$TOOLS_LOG_PATH/graclus_1_clean.log" 2>&1
2011-11-02 13:10:11 +00:00
echo " - building graclus"
2014-05-22 13:16:46 +00:00
make -j > "$TOOLS_LOG_PATH/graclus_2_build.log" 2>&1
2011-11-02 13:10:11 +00:00
mkdir "$TOOLS_INC_PATH/metisLib"
cp -f "$GRACLUS_PATH/metisLib/"*.h "$TOOLS_INC_PATH/metisLib/"
cp -f lib* "$TOOLS_LIB_PATH/"
echo " < done - `date`"
echo
echo " > poisson surface reconstruction "
cd "$PSR_PATH"
sed -i "$PSR_PATH/Makefile" -e "21c\BIN = ./"
echo " - building poisson surface reconstruction"
2014-05-22 13:16:46 +00:00
make -j > "$TOOLS_LOG_PATH/poisson_1_build.log" 2>&1
cp -f "$PSR_PATH/PoissonRecon" "$TOOLS_BIN_PATH/PoissonRecon"
echo " < done - `date`"
echo
echo " > parallel"
cd "$PARALLEL_PATH"
echo " - configuring parallel"
2014-05-22 13:16:46 +00:00
./configure > "$TOOLS_LOG_PATH/parallel_1_build.log" 2>&1
echo " - building paralel"
2014-05-22 13:16:46 +00:00
make -j > "$TOOLS_LOG_PATH/parallel_2_build.log" 2>&1
cp -f src/parallel "$TOOLS_BIN_PATH/"
echo " < done - `date`"
echo
echo " > clapack"
cd "$CLAPACK_PATH"
cp make.inc.example make.inc
set +e
echo " - building clapack"
2014-05-22 13:16:46 +00:00
make all -j > "$TOOLS_LOG_PATH/clapack_1_build.log" 2>&1
set -e
echo " - installing clapack"
2014-05-22 13:16:46 +00:00
make lapack_install > "$TOOLS_LOG_PATH/clapack_2_install.log" 2>&1
sudo cp -Rf INCLUDE "$INC_PATH/clapack"
echo " < done - `date`"
echo
2010-11-03 00:55:48 +00:00
echo " > vlfeat"
cd "$VLFEAT_PATH"
echo " - installing vlfeat"
if [ "$ARCH" = "i686" ]; then
2011-11-01 20:40:32 +00:00
cp -f "$VLFEAT_PATH/bin/glnx86/sift" "$TOOLS_BIN_PATH/vlsift"
cp -f "$VLFEAT_PATH/bin/glnx86/libvl.so" "$TOOLS_LIB_PATH/"
fi
if [ "$ARCH" = "x86_64" ]; then
cp -f "$VLFEAT_PATH/bin/glnxa64/sift" "$TOOLS_BIN_PATH/vlsift"
cp -f "$VLFEAT_PATH/bin/glnxa64/libvl.so" "$TOOLS_LIB_PATH/"
fi
echo " < done - `date`"
echo
2010-11-03 00:55:48 +00:00
2010-10-30 11:49:56 +00:00
echo " > cmvs/pmvs"
2011-11-02 13:10:11 +00:00
cd "$CMVS_PATH/program/main"
2010-11-02 12:43:56 +00:00
2011-11-02 13:10:11 +00:00
sed -i "$CMVS_PATH/program/main/genOption.cc" -e "5c\#include <stdlib.h>\n"
sed -i "$CMVS_PATH/program/base/cmvs/bundle.cc" -e "3c\#include <numeric>\n"
2010-11-02 12:43:56 +00:00
2011-11-02 13:10:11 +00:00
sed -i "$CMVS_PATH/program/main/Makefile" -e "10c\#Your INCLUDE path (e.g., -I\/usr\/include)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "11c\YOUR_INCLUDE_PATH =-I$INC_PATH -I$TOOLS_INC_PATH"
sed -i "$CMVS_PATH/program/main/Makefile" -e "13c\#Your metis directory (contains header files under graclus1.2/metisLib/)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "14c\YOUR_INCLUDE_METIS_PATH = -I$TOOLS_INC_PATH/metisLib/"
sed -i "$CMVS_PATH/program/main/Makefile" -e "16c\#Your LDLIBRARY path (e.g., -L/usr/lib)"
sed -i "$CMVS_PATH/program/main/Makefile" -e "17c\YOUR_LDLIB_PATH = -L$LIB_PATH -L$TOOLS_LIB_PATH"
if [ "$ARCH" = "i686" ]; then
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=32 \\\\"
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=32 ${OPENMP_FLAG}'
fi
if [ "$ARCH" = "x86_64" ]; then
sed -i "$CMVS_PATH/program/main/Makefile" -e "22c\CXXFLAGS_CMVS = -O2 -Wall -Wno-deprecated -DNUMBITS=64 \\\\"
sed -i "$CMVS_PATH/program/main/Makefile" -e '24c\ -fopenmp -DNUMBITS=64 ${OPENMP_FLAG}'
fi
echo " - cleaning cmvs"
2014-05-22 13:16:46 +00:00
make clean > "$TOOLS_LOG_PATH/cmvs_1_clean.log" 2>&1
2011-11-02 13:10:11 +00:00
echo " - building cmvs"
2014-05-22 13:16:46 +00:00
make -j > "$TOOLS_LOG_PATH/cmvs_2_build.log" 2>&1
2011-11-02 13:10:11 +00:00
echo " - make depend cmvs"
2014-05-22 13:16:46 +00:00
sudo make depend > "$TOOLS_LOG_PATH/cmvs_3_depend.log" 2>&1
2011-11-02 13:10:11 +00:00
cp -f "$CMVS_PATH/program/main/cmvs" "$CMVS_PATH/program/main/pmvs2" "$CMVS_PATH/program/main/genOption" "$TOOLS_BIN_PATH/"
cp -f "$CMVS_PATH/program/main/"*so* "$TOOLS_LIB_PATH/"
2010-11-03 17:49:42 +00:00
echo " < done - `date`"
2010-10-30 16:56:56 +00:00
echo
2010-10-30 16:36:15 +00:00
2010-11-03 00:55:48 +00:00
echo " > bundler"
cd "$BUNDLER_PATH"
sed -i "$BUNDLER_PATH/src/BundlerApp.h" -e "620c\ BundlerApp();"
echo " - cleaning bundler"
2014-05-22 13:16:46 +00:00
make clean > "$TOOLS_LOG_PATH/bundler_1_clean.log" 2>&1
echo " - building bundler"
2014-05-22 13:16:46 +00:00
make -j > "$TOOLS_LOG_PATH/bundler_2_build.log" 2>&1
cp -f "$BUNDLER_PATH/bin/Bundle2PMVS" "$BUNDLER_PATH/bin/Bundle2Vis" "$BUNDLER_PATH/bin/KeyMatchFull" "$BUNDLER_PATH/bin/KeyMatch" "$BUNDLER_PATH/bin/bundler" "$BUNDLER_PATH/bin/RadialUndistort" "$TOOLS_BIN_PATH/"
cp -f "$BUNDLER_PATH/lib/libANN_char.so" "$TOOLS_LIB_PATH/"
echo " < done - `date`"
echo
2010-11-09 23:40:25 +00:00
cd "$TOOLS_PATH"
sudo install -o `id -u` -g `id -g` -m 644 -t "$LIB_PATH" lib/*.so
2014-05-22 13:16:46 +00:00
sudo ldconfig -v > "$TOOLS_LOG_PATH/ldconfig.log" 2>&1
2010-11-03 00:55:48 +00:00
2010-11-09 23:40:25 +00:00
sudo chown -R `id -u`:`id -g` *
2014-05-23 15:40:51 +00:00
#sudo chmod -R 777 *
2014-08-31 19:09:52 +00:00
sudo chmod 700 run.pl
2010-11-03 20:25:57 +00:00
2010-11-03 17:49:42 +00:00
echo " - script finished - `date`"
2010-11-03 00:55:48 +00:00
exit