OpenCV: Instalation (v3.x)

by Antonio / 2018-10-01
Tags: #opencv


Using a Ubuntu/Debian-based OS, it is needed to install the required packages for the compilation, for this, open a console and paste:

sudo apt-get update
sudo apt-get install build-essential cmake git libgtk2.0-dev           \
    pkg-config libavcodec-dev libavformat-dev libswscale-dev           \
    python-dev  python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev \
    libtiff-dev libdc1394-22-dev


Download the source code and compile:

cd ~
tar -xzf 3.4.3.tar.gz
cd opencv-3.4.3/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install


antonio@mint:~$ python

>>> import cv2
>>> cv2.__version__

If the above code gives an error it means the instalation was not done correctly and a verification of the first steps is needed.