-
Notifications
You must be signed in to change notification settings - Fork 0
/
opencv4.sh
126 lines (109 loc) · 3.77 KB
/
opencv4.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
CUDA=0
GSTREAMER=1
FFMPEG=1
QT5=1
CONTRIB=1
version=4.0.1
apt-get update
apt-get upgrade
echo "-----Installing Dependenices----"
apt-get -y install build-essential cmake pkg-config unzip git wget \
gcc-6 g++-6 libgtk-3-dev
echo "-----Installing Python libraries----"
apt-get -y install python-dev python-numpy
echo "-----Installing Image libraries----"
apt-get -y install libtiff-dev libpng-dev libjpeg-dev zlib1g-dev libwebp-dev
echo "-----Installing Linear Algebra libraries----"
apt-get -y install libatlas-base-dev gfortran libeigen3-dev swig libtbb-dev yasm liblapacke-dev libopenblas-dev
echo "-----Installing camera related libraries----"
apt-get -y install libv4l-dev libdc1394-22-dev
if [ $QT5 -eq 1 ]
then
echo "-----Installing QT5 libraries----"
apt-get -y install qtbase5-dev libqt5opengl5-dev
else
echo "-----Installing QT4 libraries-----"
apt-get -y install libqt4-dev libqt4-opengl-dev
fi
if [ $FFMPEG -eq 1 ]
then
echo "-----Installing ffmpeg libraries-----"
apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libfaac-dev libmp3lame-dev libtheora-dev \
libvorbis-dev libxvidcore-dev libswresample-dev libavresample-dev libx264-dev
cmake_ffmpeg=-DWITH_FFMPEG=ON
else
cmake_ffmpeg=-DWITH_FFMPEG=OFF
fi
if [ $GSTREAMER -eq 1 ]
then
echo "-----Installing gstreamer libraries-----"
apt-get -y install libgstreamer1.0-0 libgstreamer1.0-dev gstreamer1.0-tools libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-libav
cmake_gstreamer=-DWITH_GSTREAMER=ON
else
cmake_gstreamer=-DWITH_GSTREAMER=OFF
fi
if [ $CUDA -eq 1 ]
then
apt-get -y install libglew-dev
cmake_cuda=-DWITH_CUDA=ON" "
cmake_cuda+=-DENABLE_FAST_MATH=1" "
cmake_cuda+=-DCUDA_FAST_MATH=1" "
cmake_cuda+=-DWITH_CUBLAS=1" "
cmake_cuda+=-DCUDA_ARCH_BIN=5.0,5.2,6.0,6.1
else
cmake_cuda=-DWITH_CUDA=OFF
fi
if [ $CONTRIB -eq 1 ]
then
apt-get -y install libprotobuf-dev protobuf-compiler
apt-get -y install libgoogle-glog-dev libgphoto2-dev libgflags-dev libhdf5-serial-dev
cmake_contrib=-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
fi
# Optional Dependencies
# apt-get -y install libopenexr-dev libgphoto2-dev libmp3lame-dev
# apt-get -y install python-tk libvtk5-qt4-dev
#version="$(wget -q -O - http://sourceforge.net/projects/opencvlibrary/files/opencv-unix | egrep -m1 -o '\"[0-9](\.[0-9]+)+' | cut -c2-)"
echo "-------Downloading OpenCV" $version "at " $HOME "------"
cd $HOME
mkdir OpenCV
cd OpenCV
wget -U=agent -O opencv-$version.zip https://github.com/Itseez/opencv/archive/"$version".zip
unzip opencv-$version.zip
if [ $CONTRIB -eq 1 ]
then
echo "-------Downloading OpenCV contrib library-----"
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout $version
cd ..
fi
echo "------Installing OpenCV" $version "------"
cd opencv-$version
mkdir build
cd build
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_ENABLE_NONFREE=ON \
$cmake_gstreamer \
$cmake_ffmpeg \
$cmake_cuda \
$cmake_contrib \
-DBUILD_opencv_java=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D CMAKE_C_COMPILER=gcc-6 \
-D CMAKE_CXX_COMPILER=g++-6 \
-D BUILD_EXAMPLES=OFF ..
make -j"$(nproc)"
make install
echo "-------Setting paths------"
sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
ldconfig
sh -c 'echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH" >> /etc/bash.bashrc'
echo "OpenCV" $version " is ready to be used"