OpenCV 5 drops June 8th (pip version) with a DNN engine rewrite that jumps ONNX operator coverage from ~22% to over 80%. The new graph-based engine understands dynamic shapes, fuses attention patterns, and runs LLMs like Qwen 2.5 directly inside the library.
Three Engines, One API
OpenCV 5 keeps the old engine for backward compatibility. You pick at load time via the EngineType enum:
import cv2 as cv
# Default: new engine first, fallback to classic
net = cv.dnn.readNetFromONNX("model.onnx")
# Force new engine
net = cv.dnn.readNetFromONNX("model.onnx", engine=cv.dnn.ENGINE_NEW)
The classic engine (ENGINE_CLASSIC) supports non-CPU backends like CUDA and OpenVINO. The new engine (ENGINE_NEW) runs on CPU only for now but delivers fusions like FlashAttention-style attention collapsing. ENGINE_ORT wraps ONNX Runtime if built with WITH_ONNXRUNTIME=ON.
Speed Benchmarks
On an Intel Core i9-14900KS (Ubuntu 24.04), OpenCV 5's new engine beats ONNX Runtime on several models:
| Model | OpenCV 5 DNN (ms) | ONNX Runtime (ms) | Difference |
|---|---|---|---|
| XFeat | 6.56 | 8.61 | 31.25% faster |
| YOLOv8n | 10.9 | 12.15 | 11.5% faster |
| YOLOX-S | 23.46 | 25.16 | 7.24% faster |
| DINOv2 small | 23.78 | 29.58 | 24.4% faster |
| RF-DETR | 102.01 | 106.49 | 4.4% faster |
| OWLv2 | 1,090 | 1,489 | 36.6% faster |
| BiRefNet | 7,178 | 9,503 | 32.4% faster |
LLMs and VLMs Inside OpenCV
OpenCV 5 ships a native tokenizer and KV-cache for autoregressive decoding. Models like Qwen 2.5, Gemma 3, PaliGemma, and GPT-2/4 run through the same Net API as YOLO. In tests, Qwen 2.5 output matched ONNX Runtime token-for-token.
Other Improvements
- Core modernization: Retired legacy C API, added native FP16/BF16, proper 0D/1D tensors, and real logging.
- Hardware acceleration: Cleaner layer for vendor-specific kernels.
- 3D vision: ChArUco boards, multi-camera calibration, and better visualization.
- Documentation: Completely revamped, easier to navigate.
- Models validated: YOLOv8, YOLOv9, YOLOv10, DINOv2, SAM, CLIP, RT-DETR, LaMa inpainting, and more.
What's Next
GPU support in the new DNN engine and a non-CPU HAL for accelerated pre/post-processing are planned. The OpenCV team invites community testing and contributions.
Get the pip version on June 8th. For now, build from the GitHub master branch.

