-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_opencv.sh
52 lines (41 loc) · 1.85 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
# -------------------------------------------------------------------- |
# SCRIPT OPTIONS |
# ---------------------------------------------------------------------|
OPENCV_VERSION='4.1.0.25' # Version to be installed
OPENCV_CONTRIB='YES' # Install OpenCV's extra modules (YES/NO)
VENV_PATH="env" # Python Virtual environment path
# -------------------------------------------------------------------- |
echo "Update existing packages"
sudo apt-get -y update && sudo apt-get upgrade
echo "Install CMake"
sudo apt-get -y install build-essential cmake pkg-config
echo "Install some I/O packages to load various image file formats from disk"
sudo apt-get -y install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev
echo "Install some I/O packages to load various video file formats"
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get -y install libxvidcore-dev libx264-dev
echo "Install GTK dev library for highgui"
sudo apt-get -y install libfontconfig1-dev libcairo2-dev
sudo apt-get -y install libgdk-pixbuf2.0-dev libpango1.0-dev
sudo apt-get -y install libgtk2.0-dev libgtk-3-dev
echo "Optimise OpenCV operations"
sudo apt-get -y install libatlas-base-dev gfortran
echo "Install HDF5 datasets and Qt GUIs"
sudo apt-get -y install libhdf5-dev libhdf5-serial-dev libhdf5-103
sudo apt-get -y install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
echo "Install Python header files"
sudo apt-get -y install python3-dev
echo "Create venv if required"
if [ ! -d $VENV_PATH]
then
python3 -m venv $VENV_PATH
fi
echo "Activating venv"
source $VENV_PATH/bin/activate
echo "Install OpenCV"
if [$OPENCV_CONTRIB == "YES"]
then
pip install opencv-contrib-python==$OPENCV_VERSION
elif [$OPENCV_CONTRIB == "NO"]
pip install opencv-python==$OPENCV_VERSION
fi