YouTube Icon

Code Playground.

How to Install OpenCV on Debian 10 Linux


How to Install OpenCV on Debian 10 Linux

OpenCV (Open Source Computer Vision Library) is an open-source PC vision library and has ties for C++, Python, and Java. It is utilized for a huge scope of utilizations, including clinical picture examination, sewing road see pictures, reconnaissance video, distinguishing and perceiving faces, following moving items, extricating 3D models, and considerably more. 

OpenCV can exploit multi-center handling and highlights GPU quickening for ongoing activity. 

This instructional exercise, tells the best way to introduce OpenCV on Debian 10, Buster. For a great many people, the simplest method to introduce OpenCV on Debian is to introduce it utilizing the able bundle the board instrument. In the event that you need to introduce the most recent stable adaptation of OpenCV from source, look down to the Installing OpenCV from the Source part of this instructional exercise. 

Pick one of the establishment choices that works best for you. 

Install OpenCV from the Debian Repository

The OpenCV Python module is accessible from the standard Debian vault. At the hour of composing, the standard Debian stores incorporate OpenCV adaptation 3.2, which is obsolete. 

To introduce OpenCV Python module, enter: 

sudo apt update
sudo apt install python3-opencv

The order above will introduce all bundles important to run OpenCV. 

To confirm the establishment, import the cv2 module and print the OpenCV adaptation: 

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

On the off chance that you need to introduce OpenCV with Python 2 ties, introduce the python-opencv bundle. 

Installing OpenCV from the Source

Building the OpenCV library from source is the suggested method of introducing OpenCV. It will be streamlined for your specific framework, and you will have full oversight over the assemble alternatives. 

To introduce the most recent OpenCV variant from the source, play out the accompanying advances: 

Introduce the required and discretionary conditions: 

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

Clone the OpenCV's and OpenCV contrib storehouses with the accompanying orders: 

mkdir ~/opencv_build && cd ~/opencv_build
git clone
git clone

At the hour of composing, the default form in the github archives is rendition 4.2.0. In the event that you need to introduce a more seasoned rendition of OpenCV, compact disc to both opencv and opencv_contrib indexes and run git checkout <opencv-version> 

Once the download is finished, make an impermanent form catalog, and explore to it: 

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

Set up the OpenCV work with CMake: 

    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_build/opencv_contrib/modules \

At the point when the CMake fabricate framework is concluded, you will see something like underneath: 

-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/opencv_build/opencv/build

Alter the - j banner as indicated by your processor. On the off chance that you don't have a clue about the quantity of centers your processor, you can discover it by composing nproc. 

The gathering may take a few minutes or more, contingent upon your framework design. When done, you will see something like underneath: 

[100%] Linking CXX executable ../../bin/example_tutorial_imgcodecs_imwrite
[100%] Built target example_tutorial_goodFeaturesToTrack_Demo
[100%] Built target example_tutorial_imgcodecs_imwrite
sudo make install
-- Installing: /usr/local/share/opencv4/samples/python/
-- Installing: /usr/local/share/opencv4/samples/python/
-- Installing: /usr/local/share/opencv4/samples/python/

To check whether OpenCV has been introduced effectively, enter the accompanying order and you should see the OpenCV variant: 

pkg-config --modversion opencv4
python3 -c "import cv2; print(cv2.__version__)"


We have given both of you various approaches to introduce OpenCV on Debian 10. The technique you pick relies upon your prerequisites and inclinations. Despite the fact that introducing the bundled form from the Ubuntu archive is simpler, building OpenCV from source gives you greater adaptability, and it ought to be your first choice when introducing OpenCV. 

On the off chance that you have any inquiries or criticism, don't hesitate to remark underneath.