-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·250 lines (217 loc) · 11.6 KB
/
install.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
# Run: $ curl -fsSL http://bit.ly/OpenCV-Latest | [optirun] bash -s /path/to/download/folder
# Install libeigen3-dev: http://launchpadlibrarian.net/356350632/libeigen3-dev_3.3.4-4_all.deb
# Run: sudo ln -s /usr/lib/nvidia-387/libnvcuvid.so /usr/lib/libnvcuvid.so
# Run: sudo ln -s /usr/lib/nvidia-387/libnvcuvid.so.1 /usr/lib/libnvcuvid.so.1
set -e
RESET='\033[0m'
COLOR='\033[1;32m'
function msg {
echo -e "${COLOR}$(date): $1${RESET}"
}
function fail {
msg "Error : $?"
exit 1
}
function mcd {
mkdir -p "$1" || fail
cd "$1" || fail
}
if [ -z "$1" ]; then
msg "No Download Path Specified"
fi
# Script
msg "Installation Started"
INSTALL_PATH="/usr/local/opencv"
msg "OpenCV will be installed in $INSTALL_PATH"
DOWNLOAD_PATH=$1
msg "OpenCV will be downloaded in $DOWNLOAD_PATH"
CUDA_PATH="/usr/local/cuda"
msg "Updating system before installing new packages."
sudo add-apt-repository -y ppa:jonathonf/ffmpeg-3 || fail
sudo apt -y update || fail
sudo apt -y upgrade || fail
sudo apt -y dist-upgrade || fail
sudo apt -y autoremove || fail
sudo apt -y autoclean || fail
msg "Installing build tools."
sudo apt install -y \
build-essential \
cmake \
git \
|| fail
msg "Installing GUI components."
sudo apt install -y \
libharfbuzz-dev \
libvtk6-dev \
python-vtk6 \
qt5-default \
|| fail
msg "Installing media I/O componenets."
sudo apt install -y \
libavresample-dev \
libgdal-dev \
libgphoto2-dev \
libjasper-dev \
libjpeg-dev \
libopenexr-dev \
libpng-dev \
libtiff5-dev \
libwebp-dev \
zlib1g-dev \
|| fail
msg "Installing video I/O components."
sudo apt install -y \
libavcodec-dev \
libavformat-dev \
libdc1394-22-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libswscale-dev \
libtheora-dev \
libv4l-dev \
libvorbis-dev \
libx264-dev \
libxine2 \
libxine2-dev \
libxvidcore-dev \
yasm \
|| fail
msg "Installing Streaming Components."
sudo apt install -y \
gstreamer1.0-doc \
gstreamer1.0-libav \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-tools \
libgstreamer1.0-0 \
libgstreamer1.0-dev \
libgstreamer-plugins-bad1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-dev \
|| fail
msg "Installing Linear Algebra and Parallelism libs."
sudo apt install -y \
libboost-all-dev \
libfftw3-dev \
libfftw3-mpi-dev \
libmpfr-dev \
libopenblas-dev \
libsuperlu-dev \
libtbb-dev \
|| fail
msg "Installing LAPACKE libs."
sudo apt install -y \
checkinstall \
liblapacke-dev \
|| fail
msg "Installing SFM components."
sudo apt install -y \
libatlas-base-dev \
libgflags-dev \
libgoogle-glog-dev \
libsuitesparse-dev \
|| fail
msg "Installing Python."
sudo apt install -y \
pylint \
python-dev \
python-numpy \
python-tk \
python3-dev \
python3-numpy \
python3-tk \
|| fail
msg "Installing JDK."
sudo apt install -y \
ant \
default-jdk \
|| fail
msg "Installing Docs."
sudo apt install -y doxygen || fail
msg "All deps installed. Continuing with installation"
# Downloading
cd $DOWNLOAD_PATH
REPOS="ceres-solver,https://ceres-solver.googlesource.com/ceres-solver
opencv,https://github.com/opencv/opencv.git
opencv_contrib,https://github.com/opencv/opencv_contrib.git
opencv_extra,https://github.com/opencv/opencv_extra.git"
for repo in $REPOS; do
IFS=","
set $repo
if [[ -D$1 && -x $1 ]]; then
msg "Updating $1 Repo."
cd $1
git pull || fail
cd ..
else
msg "Downloading $1 Package"
git clone $2 || fail
fi
done
msg "Configuring Ceres Solver."
mcd ceres-solver/build
cmake \
-DCMAKE_C_FLAGS="-fPIC" \
-DCMAKE_CXX_FLAGS="-fPIC" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SHARED_LIBS=ON \
.. || fail
msg "Making Ceres Solver."
make -j $(($(nproc)+1)) || fail
make -j $(($(nproc)+1)) test || fail
msg "Installing Ceres Solver."
sudo make -j $(($(nproc)+1)) install || fail
cd $DOWNLOAD_PATH
sudo rm -rf opencv/build || fail
mcd opencv/build || fail
# Configuring make
msg "Configuring OpenCV Make"
cmake \
-DBUILD_EXAMPLES=ON \
-DBUILD_OPENCV_JAVA=OFF \
-DBUILD_OPENCV_JS=ON \
-DBUILD_OPENCV_NONFREE=ON \
-DBUILD_OPENCV_PYTHON=ON \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \
-DCMAKE_LIBRARY_PATH=$CUDA_PATH/lib64/stubs/ \
-DCUDA_CUDA_LIBRARY=$CUDA_PATH/lib64/stubs/libcuda.so \
-DCUDA_FAST_MATH=ON \
-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_PATH \
-DENABLE_CCACHE=ON \
-DENABLE_FAST_MATH=ON \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_TESTS=ON \
-DOPENCV_EXTRA_MODULES_PATH=$DOWNLOAD_PATH/opencv_contrib/modules/ \
-DOPENCV_ENABLE_NONFREE=ON \
-DOPENCV_TEST_DATA_PATH=$DOWNLOAD_PATH/opencv_extra/testdata/ \
-DWITH_CUBLAS=ON \
-DWITH_CUDA=ON \
-DWITH_FFMPEG=ON \
-DWITH_GDAL=ON \
-DWITH_GSTREAMER=ON \
-DWITH_LIBV4L=ON \
-DWITH_NVCUVID=ON \
-DWITH_OPENCL=ON \
-DWITH_OPENGL=ON \
-DWITH_QT=ON \
-DWITH_TBB=ON \
-DWITH_V4L=ON \
-DWITH_VTK=ON \
-DWITH_XINE=ON \
.. || fail
# Making
msg "Building OpenCV."
make -j $(($(nproc)+1)) || fail
make -j $(($(nproc)+1)) test || fail
msg "Installing OpenCV"
sudo make -j $(($(nproc)+1)) install || fail
sudo ldconfig || fail
# Finished
msg "Installation finished for OpenCV"
msg "Please Add $INSTALL_PATH/lib/pythonX.X/dist-packages/ to your PYTHONPATH"