OpenCV
OpenCV is an open-source computer vision library providing classical (non-deep-learning) image processing algorithms, plus tooling to work with deep learning CV models.
OpenCV (Open Source Computer Vision Library) is a widely used open-source library of classical computer-vision algorithms — image filtering, edge detection, feature matching, camera calibration — written in C++ with bindings for Python and other languages. It predates the deep learning era and is distinct from a CNNCNN (Convolutional Neural Network)A CNN is a neural network built around the convolution operation, which encodes locality and translation invariance for processing images efficiently.: OpenCV's classical algorithms are hand-engineered, not learned, though it's commonly used alongside deep learning models for preprocessing images (resizing, color conversion) or running inference.
How it works
The library is a C++ core with thin language bindings; in Python
everything hangs off cv2 and images are plain NumPy arrays. Two
details trip up nearly everyone: cv2.imread returns channels in
BGR order rather than RGB, and arrays are indexed
(height, width, channels) while most function arguments take sizes as
(width, height). The algorithms themselves are deterministic and
hand-designed — cv2.Canny for edges, cv2.warpAffine for geometric
transforms, ORB or SIFT for keypoint matching, cv2.VideoCapture for
stream I/O. The dnn module additionally loads trained models from ONNX
and similar formats, which makes OpenCV a dependency-light path to
inferenceInferenceInference is using a trained model to generate output, as opposed to training — for LLMs, an inherently sequential, token-by-token process with its own performance engineering. when a full
PyTorchPyTorchPyTorch is the dominant deep learning framework in both research and production, providing tensor computation, GPU dispatch, and automatic differentiation. install is unwarranted.
When it breaks
- Color-space bugs are silent: feeding BGR arrays to a model trained on RGB costs accuracy without raising anything.
- Failures surface late.
cv2.imreadreturnsNonefor a missing or unreadable file instead of raising, so the real error appears downstream as a confusingNoneTypecrash. - Classical feature detection and matching degrade sharply under lighting changes, motion blur, and low-texture surfaces — exactly the cases learned features handle better.
- The
dnnmodule trails mainstream frameworks in operator coverage and GPUGPU (Graphics Processing Unit)GPUs, originally built for rendering graphics, turned out to be extremely well-suited to the parallel matrix multiplications deep learning requires. support; treat it as a deployment convenience, not a training stack.
See also: CNNCNN (Convolutional Neural Network)A CNN is a neural network built around the convolution operation, which encodes locality and translation invariance for processing images efficiently.
Learn more: Computer Vision · OpenCV official docs
CNN (Convolutional Neural Network)
A CNN is a neural network built around the convolution operation, which encodes locality and translation invariance for processing images efficiently.
AlexNet
AlexNet is the 2012 deep convolutional network that won the ImageNet competition by a wide margin, sparking the deep learning boom.