In this article, we will have explained the necessary steps to install and configure OpenCV on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
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.
Install OpenCV on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
Step 2. Install OpenCV.
- Install OpenCV from Source
First, Install the required and optional dependencies:
Next, Create a directory which will hold the repositories and clone both OpenCV’s:
Once the download is completed create a temporary build directory, and switch to it:
Then, Configure the OpenCV build with the following CMake command:
Now Start the compilation process by running the following command. Modify the -j flag according to your processor. If you do not know the number of cores your processor you can find it by typing nproc. My system has 4 cores, so I am using the -j4 flag:
Install OpenCV with:
Next steps, Create symlink opencv4.pc file to the /usr/share/pkgconfig directory and run ldconfig to rebuild the libraries cache:
Check the OpenCV version:
To enable the Python cv2 module run:
- Install OpenCV from the CentOS Repository
Install the OpenCV packages using following command:
Once the installation is completed you can verify it by running:
Congratulation, you have learned how to install and configure OpenCV on CentOS 7. If you have any question, please leave a comment below.