Skip to content

Instantly share code, notes, and snippets.

@donghee
Created August 21, 2021 18:59
Show Gist options
  • Select an option

  • Save donghee/f929969bb4022946eed3f898e5d06d52 to your computer and use it in GitHub Desktop.

Select an option

Save donghee/f929969bb4022946eed3f898e5d06d52 to your computer and use it in GitHub Desktop.
install-OpenCV4.sh
#!/bin/sh
# Shell script for installing openCV 4.5.3 in ubuntu 18.04
# Run it as:
# >> chmod +x install-OpenCV4.sh.sh
# >> yes | sudo ./install-OpenCV4.sh.sh
apt install build-essential cmake git pkg-config libgtk-3-dev
apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev
apt install libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev
apt install python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv/
git checkout 4.5.3
cd ~
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib/
git checkout 4.5.3
cd ~/opencv/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
make -j1
make install
pkg-config --modversion opencv4
python3 -c "\
import cv2
print(cv2.__version__)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment