How to Compile and Install OpenCV 3.3.0 on CentOS 7
The Open Source Computer Vision Library, commonly referred to as OpenCV, is a versatile and cross-platform library designed for computer vision applications. It is extensively adopted in various visual processing fields such as facial recognition, gesture tracking, interaction between humans and computers, object detection, motion analysis, and more.
OpenCV supports multiple operating systems including Windows, Linux, Android, and iOS. This guide explains the process of compiling and installing OpenCV version 3.3.0 — the most current stable release at the time of writing — on a CentOS 7 x64 system.
Requirements
- An active CentOS 7 x64 server instance.
- Access to the server as the root user.
- The server should be fully updated with the latest stable packages.
Step 1: Installing the Required Dependencies
Execute the following commands to install all necessary packages for compiling OpenCV:
yum groupinstall "Development Tools" -y
yum install cmake gcc gtk2-devel numpy pkconfig -y
Step 2: Fetching the OpenCV 3.3.0 Archive
Download and extract the OpenCV 3.3.0 source archive using these commands:
cd
wget https://github.com/opencv/opencv/archive/3.3.0.zip
unzip 3.3.0.zip
Step 3: Compiling and Installing OpenCV
Use the instructions below to build and install OpenCV. The resulting files will be stored in the /usr/local
directory:
cd opencv-3.3.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=DEBUG -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install
Step 4: Setting Up Environment Variables
After installation, some environment variables must be configured for pkgconfig and OpenCV to work correctly:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
echo '/usr/local/lib/' >> /etc/ld.so.conf.d/opencv.conf
ldconfig
Step 5 (Optional): Running Validation Tests
To verify your OpenCV setup, you can retrieve supplementary test data from the OpenCV extras repository and run the test binaries:
cd
git clone https://github.com/opencv/opencv_extra.git
export OPENCV_TEST_DATA_PATH=/root/opencv_extra/testdata
Navigate to the bin
directory inside the OpenCV build folder and execute one of the available test binaries, such as:
cd /root/opencv-3.3.0/build/bin
ls
./opencv_test_photo
Conclusion
By following this guide, you have successfully compiled and installed OpenCV 3.3.0 on a CentOS 7 system. With the required dependencies in place and environment variables properly configured, your system is now ready for a wide range of computer vision applications. Whether you are working on facial recognition, object tracking, or gesture detection, this setup provides a stable foundation to build and test OpenCV-powered projects. You can now confidently begin developing visual processing solutions tailored to your specific needs on a robust Linux platform.