# OpenCV

> A free library of tools for working with images and video. Python calls it cv2.

**Field:** Artificial Intelligence  
**Category:** Robotics & Vision  
**Also known as:** Open Source Computer Vision Library, cv2, opencv-python

## Think of it like

It is like a big toolbox for photos. Each tool does one job, like cut, blur or find edges.

## Definition

OpenCV is a free, open source library of computer vision tools. It has thousands of ready-made functions for images and video. They can resize, crop, blur, find edges, track motion or run a trained model. It is written in C++ and is often used from Python, where you import it as cv2. Robots, phone apps and factory cameras all use it.

## Example

Jack's robot uses OpenCV to read each camera frame, shrink it, and turn it grey. Then his model looks for red cups.

## Example code

```python
import cv2
img = cv2.imread("cup.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 200)
cv2.imwrite("edges.jpg", edges)
```

Read a photo, turn it grey, find the edges, then save the result.

## Why it matters

Most vision projects need the same basic steps. OpenCV gives them ready-made, so you can start on the real problem.

## Common mistake

Forgetting that OpenCV loads colour photos in blue, green, red order. Shown in another tool, a red cup can look blue.

## Three principles

- **Ready-made tools.** Resize, blur, edges and more.
- **C++ inside.** Fast code under a Python wrapper.
- **Free to use.** Open source, even for business.

## Related terms

- [Computer Vision](https://learn.benibix.com/term/ai/computer-vision)
- [Object Detection](https://learn.benibix.com/term/ai/object-detection)
- [Python](https://learn.benibix.com/term/development/python)
- [Robot Operating System (ROS)](https://learn.benibix.com/term/ai/robot-operating-system)
- [Open Source Software](https://learn.benibix.com/term/development/open-source)

![Four small frames in a row joined by arrows: a colour photo of a cup, the same photo in grey, a black frame with white edge lines, and the cup outlined with a box.](https://learn.benibix.com/diagrams/ai6-opencv.svg)

---

Source: https://learn.benibix.com/term/ai/opencv
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
