-
Notifications
You must be signed in to change notification settings - Fork 0
/
opencv_pi.sh
110 lines (94 loc) · 3.29 KB
/
opencv_pi.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
CUDA=0
GSTREAMER=1
FFMPEG=1
QT5=1
CONTRIB=1
version=3.3.0
apt-get update
apt-get upgrade
echo "-----Installing Dependenices----"
apt-get -y install build-essential cmake pkg-config unzip git wget #libgtk-3-dev
echo "-----Installing Python libraries----"
apt-get -y install python-dev python-numpy
echo "-----Installing Image libraries----"
apt-get -y install libtiff5-dev libjasper-dev libpng12-dev libjpeg-dev
echo "-----Installing Linear Algebra libraries----"
apt-get -y install libatlas-base-dev gfortran libeigen3-dev swig libtbb-dev yasm liblapacke-dev libatlas-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
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 libtheora-dev \
libvorbis-dev libxvidcore-dev libswresample-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 [ $CONTRIB -eq 1 ]
then
apt-get -y install libprotobuf-dev protobuf-compiler
apt-get -y install libgoogle-glog-dev libgflags-dev libhdf5-serial-dev
cmake_contrib=-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
fi
# Optional Dependencies
# apt-get -y install libopenexr-dev zlib1g-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 ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=OFF \
$cmake_gstreamer \
$cmake_ffmpeg \
$cmake_contrib \
-D BUILD_opencv_java=OFF \
-D BUILD_EXAMPLES=OFF ..
#-D BUILD_TBB=ON \
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"