Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install OpenCV on Debian 10 Linux - DesignLinux

May 29 2020
designlinux 0 Comments
How to Install OpenCV on Debian 10 Linux

OpenCV (Open Source Computer Vision Library) is an open source computer vision library with bindings for C++, Python, and Java and supports all major operating systems. In this tutorial, we will show you how to install OpenCV on Debian 10 system.

OpenCV can be deployed on various platforms, including Windows, Linux, Android, iOS, etc. The OpenCV installation is quite simple.

Prerequisites#

Before starting installation, make sure you are logged in as root or sudo user.

Install OpenCV from Debian Repository#

Debian standard repositories includes OpenCV Python module. Run the following command to install the OpenCV packages:

sudo apt update
sudo apt install python3-opencv

It will also install the all necessary packages. Verify OpenCV installation by checking version, type:

python3 -c "import cv2; print(cv2.version)"
3.2.0

Install OpenCV from the Source#

If you would prefer the latest version of OpenCV library, you can get it directly from the source. Perform the following steps to install the latest OpenCV version from the source:

1. Install dependencies#

Run the following command to install required 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

2. Clone repositories#

Next, clone OpenCV and OpenCV contrib repositories using 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

Currently, while writing this tutorial, the latest stable version is 4.3.0.

3. Create build directory#

Now, create a temporary build directory and navigate to inside it:

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

Use the CMake command to configure the OpenCV build:

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

It should return output as below:

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

4. Start compilation#

Execute the below command to start the compilation process:

make -j4

Ensure that here in -j option you should provide number of processor as per your system. You can find number of processor by typing nproc.

Depending on your system resources, compilation process may take few minutes.

5. Install OpenCV libraries#

To install OpenCV libraries, type:

sudo make install
...
-- Installing: /usr/local/share/opencv4/samples/python/video_threaded.py
-- Installing: /usr/local/share/opencv4/samples/python/video_v4l2.py
-- Installing: /usr/local/share/opencv4/samples/python/watershed.py

6. Verify installation#

To verify the installation issue the below command, it will show OpenCV version.

pkg-config --modversion opencv4
4.3.0

Conclusion#

This tutorial covered multiple ways to install OpenCV on your Debian 10 server.

If you have any questions or feedback, feel free to comment below.

Related

Tags: debian, opencv, python

How to Install VirtualBox on Ubuntu 20.04

Prev Post

Uname Command in Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 2
  • 573
  • 1,055,345

DesignLinux.com © All rights reserved

Go to mobile version