OpenCV

OpenCV – Open Source Computer Vision Library

The best-known library for computer vision and image and video processing, with thousands of algorithms and a Python API.

ActiveBeginnerv5.1.0.95Apache-2.0Computer Vision & Image Processing

Official documentationTry the examples

Basic information

NameOpenCV
Full nameOpenCV – Open Source Computer Vision Library
CategoryComputer Vision & Image Processing
DeveloperThe OpenCV foundation and its community
Release year2000
Official websitegithub.com/opencv/opencv-python
GitHub repositoryopencv/opencv-python
Official documentationNot specified
Package on PyPIopencv-python
LicenseApache-2.0 (PyPI license)
Project statusActive Had a release in the last 12 months
Latest version17 November 2026 (version 5.1.0.95)
Programming languageC++, Python
Operating systemsMacOS, POSIX, Unix, Windows (as declared by the package on PyPI)
Required Python version>=3.6
Difficulty levelBeginner

Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)

Overview

OpenCV covers reading images and video, colour conversion, filters, edge and feature detection and matching, geometric calibration and tracking, and a dnn module for running trained models in formats such as ONNX.

It is used for preprocessing before deep learning and in real-time camera applications. The opencv-python package on PyPI is the official pre-built package for Python, and opencv-python-headless is for servers without a GUI.

When to choose it? Choose it for classical image and video processing and real-time applications.

Uses

Main uses

  • Reading and processing images and video
  • Reading and processing images and video
  • Filters and edge and feature detection
  • Filters and edge and feature detection
  • Running trained models through the dnn module
  • Running trained models through the dnn module
  • Calibration and tracking
  • Calibration and tracking

Scientific fields

  • Computer vision
  • Computer vision
  • Robotics
  • Robotics
  • Industry and surveillance
  • Industry and surveillance

Suitable project types

  • A real-time camera app
  • A real-time camera app
  • Preprocessing training images
  • Preprocessing training images

Research applications

  • Preparing images and evaluating classical processing methods
  • Preparing images and evaluating classical processing methods

Image processingObject detection

Technical features

A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".

CPU supportSupported
GPU supportPartial or through an add-onCUDA modules are available when OpenCV is built from source with CUDA, not in the default pip packages.
CUDA compatibilityPartial or through an add-on
Distributed training or computingNot supported
Automatic differentiation (Autodiff)Not supported
Model deploymentSupported
Pre-trained modelsPartial or through an add-onThe dnn module runs externally trained models.
Supported data typesNumPy arrays for images (uint8, float32...)
Integration with other librariesNumPy, Pillow, Albumentations, ultralytics
Flexibility (editorial estimate)High
Performance (editorial estimate)High
Community (editorial estimate)Huge
Documentation quality (editorial estimate)Official documentation and tutorials

Installation and running

Shell
pip install opencv-python
pip install opencv-python-headless

Install only one of the two packages; headless is for servers without a GUI.

Compatibility: Python >=3.6 — according to the package data on PyPI, checked on 21 November 2026

Compatibility: Python >=3.6 — according to the package data on PyPI, checked on 21 November 2026

Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.

Code examples

Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.

BeginnerEdge and contour detection with OpenCVRun and tested

Goal: Converting an image to grayscale, detecting edges and counting shapes.

Python — example.py
import cv2, numpy as np

img = np.zeros((200, 300, 3), dtype=np.uint8)
cv2.rectangle(img, (20, 20), (90, 90), (255, 255, 255), -1)
cv2.circle(img, (160, 100), 40, (0, 255, 0), -1)
cv2.ellipse(img, (250, 150), (30, 20), 0, 0, 360, (0, 0, 255), -1)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 50, 150)
contours, _ = cv2.findContours(gray, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
print("Edge pixels:", int((edges > 0).sum()))
print("Number of shapes:", len(contours))
print("Areas:", sorted(int(cv2.contourArea(c)) for c in contours))

Code explanation

We draw three shapes on a black image, then apply the Canny filter to detect edges and findContours to extract and count the outer contours. Remember that OpenCV stores channels in BGR order.

Requirements

Shell
pip install opencv-python-headless numpy

How to run

Save the code in a file example.py then run it:

Shell
python example.py

Output recorded during testing

Edge pixels: 712
Number of shapes: 3
Areas: [1884, 4900, 4912]

This example was actually run and tested on 21 November 2026 on a CPU — opencv-python-headless 5.1.0.95, numpy 2.5.5, python 3.13.18

Example page

All OpenCV examples in the Code Explorer

Pros

  • Huge coverage of vision algorithms
  • Fast and suited to real-time applications

Limitations

  • Images are in BGR order by default (a common source of bugs)
  • CUDA support needs a build from source

References and verification

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/opencv-python/

    Checked on: 21 November 2026 — version checked: 5.1.0.95 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://github.com/opencv/opencv-python

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/opencv/opencv-python

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/opencv-python/

    Checked on: 21 November 2026 — version checked: 5.1.0.95 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://github.com/opencv/opencv-python

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/opencv/opencv-python

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

History of verified versions

VersionRelease dateChecked on
5.1.0.9517 November 202621 November 2026

Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.

Report information that needs updating