Advance

How to Configure OpenCV on Debian 11

How to Configure OpenCV on Debian 11

OpenCV is a library of programming functions originally developed by Intel. The OpenCV library is open-source, cross-platform, and free to use under a BSD license. The algorithms of this library use SSE, AVX, TBB, IPP, CUDA, OpenCL for optimization and parallelization. In this article, we are going to teach you How to Configure OpenCV on Debian 11. You can visit the packages available in Eldernode if you wish to purchase a Linux VPS server.

Tutorial Configure OpenCV on Debian Linux

Recommended Article: Tutorial Setup And Configure Suricata On Debian 9

What is OpenCV?

OpenCV library supports various platforms including Windows, Linux, Android, iOS, Macintosh. It also contains more than 2500 optimized algorithms. OpenCV can be used in image filtering, face recognition, motion detection, human-computer interaction, motion tracking, motion perception, object detection, and more.

To support some OpenCV applications, there is a machine learning library that includes the following:

1. Meta algorithm

2. Mathematical Hope-Maximize Algorithm

3. Gradient trees increase

4. Support Vector Machine (SVM)

5. Nearest Neighbor Algorithm

6. Learn decision tree

7. Artificial neural network

8. Random forest

How to Install OpenCV on Debian 11

In this section, we want to teach you How to Install OpenCV on Debian 11. To do this, you must follow the steps below in order.

Note that the OpenCV Python module is available from the standard Debian repository. At the time of writing this article, standard Debian repositories include OpenCV version 4.5.3. The first step is to update the system using the following commands and then install the OpenCV Python module:

sudo apt update
sudo apt install python3-opencv

Next, to confirm the installation, enter the cv2 module and print the OpenCV version using the following command:

python3 -c "import cv2; print(cv2.__version__)"

The second way to install OpenCV is to use the source. In this method, to install the latest version of OpenCV from the source, you need to perform the following steps in order. Using the following command, you can install all the required and optional dependencies:

sudo apt install build-essential cmake git pkg-config libgtk-3-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ gfortran openexr libatlas-base-dev python3-dev python3-numpy \ libtbb2 libtbb-dev libdc1394-22-dev

After installing the required dependencies, you can clone the OpenCV and OpenCV participation repositories using the following commands:

mkdir ~/opencv_build && cd ~/opencv_build
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

Now you need to create a temporary build directory using the following commands and go to it:

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

Configure the OpenCV infrastructure by running the following command:

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 ..

Configure OpenCV on Debian 11

In this section, we are going to look at how to configure and start OpenCV. You can run the following command to start the compilation process. In the following command, you need to change the -j flag according to your processor. Note that if you do not know the number of cores of your processor, you can find it by typing nproc.

make -j2

Now it’s time to install OpenCV by executing the following command:

sudo make install

In the next step to check the success of OpenCV installation, you can easily enter the following commands:

pkg-config --modversion opencv4
python3 -c "import cv2; print(cv2.__version__)"
Recommended Article: Tutorial Install R on Debian 10

Conclusion

One of the problems for visual software developers is performing various calculations on images. Due to the high volume of information, their processing requires optimal programming. In this article, we tried to teach you How to Configure OpenCV on Debian 11.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

    Leave Your Comment

    Your email address will not be published.

    We are by your side every step of the way

    Think about developing your online business; We will protect it compassionately

    We are by your side every step of the way

    +8595670151

    7 days a week, 24 hours a day