Table of Contents
Was this article helpful?

2  out of  2 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install OpenCV on CentOS 7

Last Updated: Mon, Oct 23, 2017
CentOS System Admin

OpenCV, also known as Open Source Computer Vision Library, is an open source cross-platform computer vision algorithm library. Nowadays, OpenCV is being widely used in all kind of visual processing areas, such as facial recognition, gesture recognition, human-computer interaction, Object identification, motion tracking, etc.

OpenCV can be deployed on various platforms, including Windows, Linux, Android, iOS, etc. In this article, I will show you how to compile and install OpenCV 3.3.0, the latest stable release of OpenCV at the time I wrote this article, on the CentOS 7 x64 operating system.


Step 1: Install dependencies for OpenCV

Use the following commands to install all required dependencies for compiling OpenCV:

yum groupinstall "Development Tools" -y

yum install cmake gcc gtk2-devel numpy pkconfig -y

Step 2: Download the OpenCV 3.3.0 archive

Download and uncompress OpenCV 3.3.0 archive as below:




Step 3: Compile and install OpenCV 3.3.0

Use the following commands to compile and install OpenCV, and compiled OpenCV files will be saved in the /usr/local directory.

cd opencv-3.3.0

mkdir build

cd build



make install

Step 4: Configure required variables

In addtion to compiling and installing files, you need to specify path info for pkgconfig and OpenCV:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/

echo '/usr/local/lib/' >> /etc/


Step 5 (optional): Run tests

To test your OpenCV installation, you can download extra test data from OpenCV extra repository:


git clone

export OPENCV_TEST_DATA_PATH=/root/opencv_extra/testdata

In the cmake build directory, you will find several test executables named in the same kind of format opencv_test_*. Run any one you are interested in to perform a test. For example:

cd /root/opencv-3.3.0/build/bin



This concludes the tutorial. Thanks for reading.

Want to contribute?

You could earn up to $600 by adding new articles.