Skip to content

openCV installation

Jaroslaw Karwowski edited this page Jun 5, 2020 · 1 revision

openCV installation script

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev libgtkglext1-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python3-dev
cd ~/Downloads
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.5.zip # or newer version if exists (check wiki on github)
unzip opencv.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/3.4.5.zip
unzip opencv_contrib.zip
sudo apt-get install python-pip && pip install --upgrade pip

Omitted some python-related stuff (env setup) from the links below:


cd ~/Downloads/opencv-3.4.5
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib-3.4.5/modules -D BUILD_EXAMPLES=ON ..
make -j4
sudo make install
sudo ldconfig
pkg-config --modversion opencv
cd ~/Downloads
rm -r opencv-3.4.5 opencv_contrib-3.4.5 opencv_contrib.zip opencv.zip
Clone this wiki locally