-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-opencv.sh
151 lines (127 loc) · 4.1 KB
/
install-opencv.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
#!/bin/bash
######################################
# INSTALL OPENCV ON UBUNTU OR DEBIAN #
######################################
if [ ! -z $1 ] && ([ $1 = '-h' ] || [ $1 = '--help' ]); then
echo '
#*****************************************************************#
# Usage: #
# $ source install-dlib.sh #
# (Set up for building in current directory) #
# #
# $ WORK=<dir_name> source install-dlib.sh #
# (Set up for building in another directory <dir_name>) #
#*****************************************************************#'
return 0 2>/dev/null || exit 0
fi
#### Pre-defined color code
Red='\033[0;31m'
Black='\033[0;30m'
Dark_Gray='\033[1;30m'
Red='\033[0;31m'
Light_Red='\033[1;31m'
Green='\033[0;32m'
Light_Green='\033[1;32m'
Brown_Orange='\033[0;33m'
Yellow='\033[1;33m'
Blue='\033[0;34m'
Light_Blue='\033[1;34m'
Purple='\033[0;35m'
Light_Purple='\033[1;35m'
Cyan='\033[0;36m'
Light_Cyan='\033[1;36m'
Light_Gray='\033[0;37m'
White='\033[1;37m'
NC='\033[0m'
##########################
#### Pre-defined functions for printing messages
function RUN {
echo -e "${Yellow}$*${NC}"
$*
return $?
}
function INFO {
echo -e "${Light_Cyan}$*${NC}"
}
function ERROR {
echo -e " ${Red}$*${NC}"
}
function COMMAND {
echo -e " ${Yellow}$*${NC}"
}
################################################
if [ -z $WORK ]; then WORK=$PWD;fi
INFO "Step 1. Update Ubuntu/Debian"
RUN sudo apt-get -y update
RUN sudo apt-get -y upgrade
RUN sudo apt-get -y dist-upgrade
RUN sudo apt-get -y autoremove
INFO ""
INFO ""
INFO "Step 2. Install dependencies"
INFO ""
INFO "Step 2a. Install Build Tools"
RUN sudo apt-get install -y build-essential cmake
INFO ""
INFO ""
INFO "Step 2b. Install GUI dependencies"
RUN sudo apt-get install -y qt5-default libvtk6-dev
INFO ""
INFO ""
INFO "Step 2c. Install Media dependencies"
RUN sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev
INFO ""
INFO ""
INFO "Step 2d. Install Video dependencies"
RUN sudo apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev
INFO ""
INFO ""
INFO "Step 2e. Install Linear Algebra and parallelism"
RUN sudo apt-get install -y libtbb-dev libeigen3-dev
INFO ""
INFO ""
INFO "Step 2f. Install Python dependencies"
RUN sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
INFO ""
INFO ""
INFO "Step 2g. Install Java dependencies"
RUN sudo apt-get install -y ant default-jdk
INFO ""
INFO ""
INFO "Step 2h. Install Documentation dependencies"
RUN sudo apt-get install -y doxygen
INFO ""
INFO ""
INFO "Step 2i. Install optional dependencies"
RUN sudo apt-get install -y libprotobuf-dev protobuf-compiler
RUN sudo apt-get install -y libgoogle-glog-dev libgflags-dev
RUN sudo apt-get install -y libgphoto2-dev libhdf5-dev
RUN sudo apt-get install -y unzip wget
INFO ""
INFO ""
INFO "Step 3. Clone OpenCV from repository"
RUN git clone https://github.com/opencv/opencv.git
RUN cd $WORK/opencv
RUN git checkout 3.3.1
INFO ""
INFO ""
INFO "Step 4. Build and install OpenCV"
RUN mkdir $WORK/opencv/build
RUN cd $WORK/opencv/build
RUN cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..
var=$(nproc)
RUN make -j$var
RUN sudo make install
RUN sudo ldconfig
INFO ""
INFO ""
INFO "==================================================================="
INFO "Installation is completed."
INFO "==================================================================="
INFO ""
INFO "Go to the following folder to find the executables"
COMMAND "#cd $WORK/opencv/build/bin"
INFO "Run an example, e.g:"
COMMAND "#./cpp-example-image ../../samples/data/lena.jpg"
COMMAND "#./cpp-example-image ../../samples/data/fruits.jpg"
COMMAND "#./cpp-example-facedetect"