Install OpenCV On CentOS 7

Install OpenCV On CentOS 7

Insight: Install OpenCV On CentOS 7

OpenCV or Open Source Computer Vision Library is an open source computer vision library. OpenCV is a cross platform library.

In this tutorial, we will show you the easy way to install OpenCV on CentOS 7.

Tutorial To Install OpenCV On CentOS 7

One of the method to install OpenCV is to install it from the CentOS Repository. At the time of writing, the version in the repositories is 2.4.5 and it is outdated too.

Run the following command to install the OpenCV packages.

sudo yum install opencv opencv-devel opencv-python

To check whether installation has gone smoothly or not, Run the following command to verify it.

pkg-config --modversion opencv

You can also install OpenCV from source. One of the advantage of installing OpenCV from this method is that you can install the latest available version.

Run the following command to install the required dependencies:

sudo yum install epel-release git gcc gcc-c++ cmake3 qt5-qtbase-devel python python-devel python-pip cmakesudo yum install python-devel numpy python34-numpy gtk2-devel libpng-devel jasper-devel openexr-devel libwebp-develsudo yum install libjpeg-turbo-devel libtiff-devel  libdc1394-devel tbb-devel eigen3-devel gstreamer-plugins-base-develsudo yum install freeglut-devel mesa-libGL mesa-libGL-devel  boost boost-thread boost-devel libv4l-devel

Create a directory  where you can store the the repositories and can clone the both OpenCV’s and OpenCV contrib repositories:

 mkdir ~/opencv_build && cd ~/opencv_buildgit clone clone

Now create a temporary build directory and move into it.

cd ~/opencv_build/opencv && mkdir build && cd build

Run the Cmake comand to configure.

    -D CMAKE_INSTALL_PREFIX=/usr/local\
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \

Now, You need to start the compilation process by running the following command.

sudo make install Now create symlink opencv4.pc file to the /usr/share/pkgconfig directory. Run the command to rebuild the libraries cache.
sudo ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/
sudo ldconfig

Now, You can check the OpenCV version:

pkg-config --modversion opencv4