-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_opencv.sh
executable file
·62 lines (46 loc) · 1.33 KB
/
build_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
#!/bin/bash
# Settings
OPENCV_VERSION=3.4.1
BUILD_TYPE=Debug
INSTALL_DIR=/usr/local
SOURCE_DIR=/vagrant
echo OPENCV_VERSION=$OPENCV_VERSION
echo BUILD_TYPE=$BUILD_TYPE
echo INSTALL_DIR=$INSTALL_DIR
#read -n 1 -s -r -p "Press any key to continue"
echo
echo
####################################################################
# Don't modify the following
####################################################################
START_DIR=`pwd`
source install_opencv_prereqs.sh
cd $SOURCE_DIR
# OpenCV Installation
echo
echo "Installing OpenCV..."
if [ ! -d local ]; then
mkdir local
fi
cd local
if [ ! -d opencv-$OPENCV_VERSION ]; then
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip
unzip $OPENCV_VERSION.zip
fi
cd opencv-$OPENCV_VERSION
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ..
make && sudo make install
echo "Setting up OpenCV environment ..."
echo "#!/bin/sh" > opencv.sh
echo "if [[ -e \$PKG_CONFIG_PATH ]]; then" >> opencv.sh
echo " export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$INSTALL_DIR/lib/pkgconfig" >> opencv.sh
echo "else" >> opencv.sh
echo " export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig" >> opencv.sh
echo "fi" >> opencv.sh
sudo mv opencv.sh /etc/profile.d/opencv.sh
echo "ENV_FILE=/etc/profile.d/opencv.sh"
echo
cd $START_DIR
echo "Installing OpenCV DONE"