Introduction to OpenCV
Discover the world's most popular open-source computer vision library, used by millions of developers for image and video processing.
What is OpenCV?
OpenCV (Open Source Computer Vision Library) is an open-source library of programming functions aimed at real-time computer vision. Originally developed by Intel in 1999, it has become the de facto standard for computer vision tasks with over 2,500 optimized algorithms.
OpenCV supports Python, C++, Java, and JavaScript. It runs on Windows, Linux, macOS, Android, and iOS, making it one of the most versatile CV libraries available.
Core Modules
imgproc
Image processing: filtering, geometric transformations, color space conversions, histograms, and morphological operations.
objdetect
Object detection using Haar cascades, HOG descriptors, and QR/barcode detection.
videoio
Video capture and writing. Read from cameras, video files, or image sequences.
dnn
Deep neural network module for running pre-trained models from TensorFlow, PyTorch, ONNX, and Caffe.
Why OpenCV?
| Feature | OpenCV | Pillow | scikit-image | TorchVision |
|---|---|---|---|---|
| Speed | Fastest (C++ core) | Moderate | Moderate | Fast (GPU) |
| Video Support | Excellent | None | Limited | Limited |
| Real-time | Yes | No | No | Yes (GPU) |
| DNN Inference | Built-in | No | No | Built-in |
| Algorithms | 2,500+ | Basic | Good | DL-focused |
| License | Apache 2.0 | MIT-like | BSD | BSD |
A Quick Example
import cv2
# Read an image
img = cv2.imread("photo.jpg")
# Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Display the image
cv2.imshow("Grayscale", gray)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.cvtColor(img, cv2.COLOR_BGR2RGB) when needed.
Lilly Tech Systems