How to Install OpenCV on Debian 10 Linux

Update on:
Sep 15, 2020

OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.

Source – OpenCV

In this tutorial, we will explain the step-by-step process to install OpenCV on Debian 10 Linux.

The easiest way to installing OpenCV on Debian system is to install from Debian repository using the apt package management tool. Here we have explained the OpenCV installation process using two methods, one is using Debian repository, and another one is using source.

You can choose any methods out of these two, which works best for you.

Install OpenCV using Debian Repository

The OpenCV package is available on Debian repository, so only you need to do is to install using apt command after updating the apt package lists, as shown below:

$ sudo apt update
$ sudo apt install python3-opencv

After installation of OpenCV you can verify it by importing cv2 module and print the OpenCV version as shown below:

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

The above commands we use to install OpenCV for Python3 if you want to install OpenCV for python2 use installation command with python-OpenCV.

Install OpenCV using the source on Debian

If you want more control on OpenCV builds, go for the source installation process for OpenCV.

You can follow below steps to install the latest OpenCV using the source:

Step 1 – As we are going to build our own OpenCV on the system need to install all required dependencies on the system, you can use the following command to install OpenCV 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

Step 2 – Now make a clone of OpenCV’s and OpenCV contrib repository from git to your system.

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

The above command will install the latest available version from Github, If you want to install a different version from git hub need to enter in both OpenCV and opencv_contrib directories and run git checkout <opencv-version>

Step 3 – After completing the download of the package, create a build directory and enter into the directory, as shown below:

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

You can set up the OpenCV build using the CMake:

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

When CMake build the system, you will get the output on your screen similar to below:

Step 4 – Now start compilation process for the latest build using makes the command, as shown below:

$ make -j8

You can modify the –j parameter according to your system processor if you don’t have an idea how many processors in your system you can check it by nproc.

The compilation will take time depending on your system configuration and performance, Once it gets completed your screen will be shown output similar to below screen:

Step 5 – Now, after compile, you can install OpenCV only using the make command, as shown below:

$ sudo make install

Step 6 – You can verify the OpenCV successfully installed in your system by checking the version of installed OpenCV:

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


You learned two different ways to install OpenCV in your Debian 10 System. You can also verify the installed version of OpenCV and learn how to compile and build OpenCV from the source.

If you get any issue on OpenCV installation or having feedback, please comment below.

Related Posts

How to Install MongoDB on Debian 10 Linux

How to Install MongoDB on Debian 10 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Setup a Firewall with UFW on Debian 10 Linux

How to Setup a Firewall with UFW on Debian 10 Linux

Nowadays, a Firewall is an essential utility and property of any system for security; by default Debian Operating system having a firewall configuration tool named UFW (Uncomplicated Firewall). UFW is a user-friendly front-end tool to manage iptables firewall rules....

How to Install Eclipse IDE on Debian 10 Linux

How to Install Eclipse IDE on Debian 10 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to use for other programming language development environments such as PHP, C++, and JavaScript. You can install Eclipse IDE...

How to Install Ruby on Debian 10 Linux

How to Install Ruby on Debian 10 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it is the language behind the ultimate robust framework known as Ruby on Rails. In this tutorial, we will explain the three...

Follow Us

Our Communities

More on Debian

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!



Submit a Comment

Your email address will not be published.

15 − seven =