-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbuild.sh
executable file
·118 lines (100 loc) · 3.17 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#! /bin/bash
# Save current dir
BASEDIR=${PWD}
echo ${BASEDIR}
# Pretty formatting.
# See http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
# Test for installed libraries
printf "${GREEN}Checking for libraries... \n${NC}"
names=( NumPy SciPy Cython Scikit-Learn OpenCV ImageIO Matplotlib)
libs=( numpy scipy cython sklearn cv2 imageio matplotlib)
nlibs=$[${#names[@]}-1]
for i in $(seq 0 ${nlibs})
do
n=${names[$i]}
l=${libs[$i]}
printf "${GREEN} $n...${NC}"
if python2 -c "import $l" > /dev/null
then
printf "${GREEN}Found. \n${NC}"
else
printf "${RED}\n *** Importing $n failed. Please install $n. *** \n${NC}"
exit 1
fi
done
# Check if libviso exists
if [ -e libviso2.zip ]
then
printf "${GREEN} Found libviso2.zip. Compiling python wrapper... \n${NC}"
unzip -o libviso2.zip -d pcaflow/extern/libviso2/
cd pcaflow/extern/libviso2/python
rm libvisomatcher.so
# Compile
python2 setup.py build_ext --inplace
cd ../../
ln -sf libviso2/python/libvisomatcher.so .
printf "${GREEN} Finished compiling libviso2 python wrapper. \n${NC}"
else
printf "${RED}\n Could not find libviso2.zip (see readme for details).\n"
read -p "Do you want to use PCA-Flow with A-KAZE features? (Y/n)" -n 1 uselibviso
printf "${NC}"
if [ "${uselibviso}" == "n" ]
then
printf "\n${RED}Quiting...${NC}\n"
cd ${BASEDIR}
exit 1
fi
fi
cd ${BASEDIR}
# Check for principal components
printf "${GREEN}Checking for principal components... ${NC}"
if [ -e data/ ] && \
[ -e data/COV_KITTI.npy ] && \
[ -e data/COV_SINTEL.npy ] && \
[ -e data/COV_SINTEL_SUBLAYER.npy ] && \
[ -e data/PC_U.npy ] && \
[ -e data/PC_V.npy ]
then
printf "${GREEN}Found. \n${NC}"
else
printf "\n${RED}"
read -p "Principal components not found. Download (filesize 484 MBytes)? (Y/n)" -n 1 downloadpc
printf "${NC}"
if [ "${downloadpc}" == "n" ]
then
printf "${RED}Continuing without download. Please provide your own principal components. \n${NC}"
else
printf "${GREEN}Downloading principal components... \n${NC}"
curl https://files.is.tue.mpg.de/jwulff/pcaflow/principal_components.zip > principal_components.zip
printf "${GREEN}Extracting principal components into data/... \n${NC}"
mkdir -pv data/
unzip -o principal_components.zip -d data/
printf "${GREEN}Done.\n${NC}"
fi
fi
# Check for internal libraries
printf "${GREEN}Building internal parts... \n${NC}"
printf "${GREEN} Building pygco... \n${NC}"
cd pcaflow/extern
cd gco_python
rm pygco.so
make
cd ..
ln -sf gco_python/pygco.so .
cd ${BASEDIR}
printf "${GREEN} done. \n${NC}"
printf "${GREEN} Building IRLS solver... \n${NC}"
cd pcaflow/solver/cython
rm RobustQuadraticSolverCython.so
if [[ "$OSTYPE" == "linux"* ]]; then
python2 setup_linux.py build_ext --inplace
elif [[ "$OSTYPE" == "darwin"* ]]; then
python2 setup_osx.py build_ext --inplace
fi
cd ..
ln -fs cython/RobustQuadraticSolverCython.so .
cd ${BASEDIR}
printf "${GREEN} done. \n${NC}"