Install OpenCV in Ubuntu using APT package manager
Step 1 : Update Package List
To make sure we are getting the latest version of OpenCV, update the package list using apt update command.
sudo apt update -y
Step 2: Install OpenCV
Once repositories are up to date, we will install opencv using apt install command.
sudo apt install python3-opencv
Step 3 : Verify installation
Once, installation is done, verify installation using print(cv2.__version__) command in python shell.
To open python shell, first type python3 in your terminal.
python3
Once python3 shell is opened, print version number of opencv using following command.
import cv2
print(cv2.__version__)
How to Install OpenCV in Ubuntu?
OpenCV is a powerful and versatile library widely used for real-time computer vision tasks. It’s commonly used in applications like image and video processing, object detection, facial recognition, and more. Recent versions of Ubuntu come with pre-built OpenCV packages available through the apt package manager.
Table of Content
- 1. Install OpenCV in Ubuntu using APT package manager
- Step 1 : Update Package List
- Step 2: Install OpenCV
- Step 3 : Verify installation
- 2. Install OpenCV in Ubuntu by Compiling from sources
- Step 1 : Installing dependencies
- Step 2 : download opencv source
- Step 3 : Navigate to opencv directory and making configuration
- Step 4: Compiling and building packages for installation
- Step 5: Installing openCV
- Step 6 : Verify installation
For some reason, if you prefer a different version than what’s available in the repositories, or you’re using an older version of Ubuntu that doesn’t have OpenCV pre-built in it’s repository, in this article we will discuss two methods for installing OpenCV in Ubuntu.