In this tutorial you will learn how to install OpenCV 4 on Ubuntu 18.04. The OpenCV4 is more further optimizations, C++11 support, more compact modules and many improvements to the Deep Neural Network(DNN) module.
First thing you need to do is openning your terminal. Alternatively, you may also SSH into your vps.
# Update your system and clean it.
# Install the developer tools:
Next, Install a handful of image and video I/O libraries.
# These libraries enable us to load image from disk as well as read video file.
Install GTK for our GUI backend.
sudo apt-get install libgtk-3-dev
Followed by installing two packages which contain mathematical optimizations for OpenCV:
sudo apt-get install libatlas-base-dev gfortran python3-dev
From there, let’s unzip the archives:
Download the latest pip:
Now let’s run CMake to configure the OpenCV 4 build:
cd opencv # the opencv path.
Now ready to compile OpenCV 4:
Note: In the
make command above, the
-j8 argument specifies that I have 8 cores cpu for compilation. You should update the command to use the number of cores on your environment for faster compile.
And from there, let’s install OpenCV :
sudo make install