OpenCV, or Open Computer Vision Library, is a collection of image processing and machine learning programming libraries. This series focuses more on Real-Time image processing. Originally developed and supported by Intel, it is now supported by Willow Garage and Itseez. OpenCV is a multi-platform library supported by Windows, Linux, Mac OS, iOS, and Android operating systems. It also has a programming interface in C, C ++, Python, Java, and MATLAB languages. In this article, we are going to teach you to step by step How to Install and Use OpenCV on AlmaLinux 8.4. You can visit the packages available in Eldernode if you wish to purchase a Linux VPS server.
Table of Contents
How to Configure OpenCV on AlmaLinux
Introduction to OpenCV
OpenCV is an open-source library for computer vision. The purpose of OpenCV design is to process tasks, especially for real-time applications. OpenCV can also work with multi-core processors.
If you want to get more automated optimization on Intel architectures, you can purchase Intel Integrated Performance Primitive libraries (IPPs) that include low-level optimized routines in many algorithmic areas. OpenCV automatically applies the appropriate IPP at runtime if the library is installed.
One of the goals of OpenCV is to provide an easy-to-use computer vision infrastructure so that people can build their relatively complex vision programs quickly. The OpenCV library includes more than 500 functions on a variety of vision topics, from factory product review to medical imaging, security, user interface, camera tuning, robotics, and binocular vision.
Because there has always been a close relationship between computer vision and machine learning, OpenCV also includes an MLL (Machine Learning Library). This sub-library focuses on statistical pattern recognition and categorization.
Applications of OpenCV include the following:
1. Image filter
2. Face recognition system
3. Motion Detection
4. Human-Computer Interaction (HCI)
5. Mobile Robotics
6. Understand movement
7. Object identification
8. Division and diagnosis
9. Stereo depth vision: Depth perception from 2 cameras
10. Structure of Motion (SFM)
11. Motion tracking
12. Augmented Reality
Installing OpenCV on AlmaLinux 8.4
After being fully acquainted with OpenCV and its capabilities in the previous section, we now want to discuss how to install OpenCV on AlmaLinux 8.4. To do this, you must perform the following steps in order.
In the first step, you must use the following commands to update the system:
sudo dnf update
sudo dnf install epel-release
sudo dnf install opencv opencv-devel opencv-python
Then you can install the necessary tools and dependencies by executing the following command:
sudo dnf install git gcc gcc-c++ cmake3 qt5-qtbase-devel python3 python3-devel python3-pip cmake python3-devel python3-numpy gtk2-devel libpng-devel jasper-devel openexr-devel libwebp-devel libjpeg-turbo-devel libtiff-devel tbb-devel libv4l-devel eigen3-devel freeglut-devel mesa-libGL mesa-libGL-devel boost boost-thread boost-devel gstreamer1-plugins-base
Now it’s time to clone the OpenCV contrib and OpenCV repositories using the following commands:
mkdir -p ~/opencv_build && cd ~/opencv_build
git clone https ://github.com/opencv/opencv.git
git clone https ://github.com/opencv/opencv_contrib.git
How to Configure and Use OpenCV on AlmaLinux 8.4
In the previous section, you were able to successfully install OpenCV. Now we want to teach you How to Configure and Use OpenCV on AlmaLinux 8.4. To do this, use the following command to create a temporary directory and go to that list:
cd ~/opencv_build/opencv && mkdir build && cd build
Now it’s time to configure the OpenCV build using the commands:
cmake3 -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
Finally, you can start the compilation process using the following command:
sudo make install
Note the important point below. You must create a symlink opencv4.pc file in the /usr/share/pkgconfig directory using the following command. Then you need to run ldconfig to restore the library cache.
sudo ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/ sudo ldconfig
You can now install OpenCV using the following command by checking the installed OpenCV version:
pkg-config --modversion openc
In the last step, you can use the following command to enable Python cv2 modules:
python3 -c "import cv2; print(cv2.__version__)"
As mentioned earlier, OpenCV library algorithms use SSE, AVX, TBB, IPP, CUDA, and OpenCL for optimization and parallelization. It also has a machine learning section for clustering and classifying data. In this article, we tried to introduce you to How to Install and Use OpenCV on AlmaLinux 8.4.