OpenCV 5.0 is a significant update to the popular open-source library for computer vision, designed to enable applications to process images and videos. This version introduces a redesigned deep neural network engine, extended support for ONNX models, and integrated functionality for vision-language models.
OpenCV is used in sectors such as robotics, industrial inspection, medicine, augmented reality, autonomous driving, and AI-based image analysis. The library provides essential tools for object recognition, image processing, and video analysis.
- Updated DNN Engine: The main novelty is the DNN engine, which now better supports dynamic shapes, subgraphs, and modern ONNX features, covering over 80% of the ONNX specification.
- Support for Multimodal Models: OpenCV 5.0 includes components for the inference of vision-language models, allowing the processing of images combined with linguistic outputs.
- Performance Improvements: The new DNN engine offers competitive performance on CPUs, with improvements in image processing operations.
- New Data Types: The version introduces additional data types such as bfloat16, uint32, uint64, int64, and support for boolean matrices.
- Removal of Obsolete Features: The C API and support for OpenVX have been removed, while G-API and the classic ML module have been moved to opencv_contrib.
- New Features: Included is a multi-view calibration pipeline, improvements for mesh and point cloud processing, and support for PLY and OBJ formats.
This guide will show you how to install and configure OpenCV 5.0 to make the most of its new features.
Prerequisites
- Operating System: Compatible with supported versions of Windows, Linux, or macOS
- Hardware: Multi-core CPU for optimal support of the new DNN engine
- Software:
- C++17 or later
- Python 3.6 or later
- ONNX Runtime (optional, for advanced ONNX model support)
- NVIDIA GPU and related drivers (optional, for GPU acceleration with ONNX Runtime)
- Additional Libraries: OpenCV 5.0 requires specific system libraries for compilation and execution
Procedure to Upgrade to OpenCV 5.0
By the end of this guide, you will have upgraded your OpenCV installation to version 5.0, leveraging the new features of the DNN engine and improved APIs.
- Update the operating system and dependencies:
- On Windows:
- Install CMake.
- On Windows:
- Download OpenCV 5.0:
- Run git clone https://github.com/opencv/opencv.git.
- Switch to the OpenCV directory with cd opencv.
- Run git checkout 5.0.0 to select version 5.0.0.
- Compile and install OpenCV 5.0:
- Create a build directory with mkdir build.
- Run cmake -D CMAKEBUILDTYPE=RELEASE -D CMAKEINSTALLPREFIX=/usr/local ...
- Run make -j$(nproc) to compile OpenCV.
- Install OpenCV with sudo make install.
- Verify the installation:
- Open a terminal and type python3 to start the Python interpreter.
- Import OpenCV with import cv2.
- Verify the version with print(cv2.version). You should see 5.0.0.
Verification and Troubleshooting
By the end of this guide, you will be able to test the correct operation of OpenCV 5.0 and resolve any common issues.
Functionality Test
- Installation Verification: Open a terminal and type the following command to verify that OpenCV 5.0 is correctly installed:
The command should return "5.0.0" or a later version.python -c "import cv2; print(cv2.version)" - Test of the New DNN Engine: Run a simple test script to verify the operation of the new DNN engine. Ensure that the engine automatically selects the new or classic engine based on needs.
import cv2 net = cv2.dnn.readNetFromONNX("model.onnx") blob = cv2.dnn.blobFromImage("image.jpg", 1.0, (300, 300), (104.0, 177.0, 123.0)) net.setInput(blob) output = net.forward() print(output) - Test of Multimodal Features: Verify support for multimodal models by running a script that uses a model combining images and language.
import cv2 net = cv2.dnn.readNetFromVLM("model.onnx") blob = cv2.dnn.blobFromImage("image.jpg", 1.0, (300, 300), (104.0, 177.0, 123.0)) net.setInput(blob) output = net.forward() print(output)
By the end of this guide, you will have a complete overview of the new features introduced by OpenCV 5.0 and be ready to leverage them in your computer vision work.
Educational Summary
- DNN Module: OpenCV 5.0 introduces a new inference engine with improved support for ONNX, subgraphs, and dynamic shapes.
- Multimodal Models: Support for models that combine images and language, such as image descriptions or answers to visual questions.
- Removal of Legacy APIs: Elimination of the C API and legacy functions, with OpenVX removed and G-API moved to opencv_contrib.
- New Features: Multi-view calibration pipeline, support for mesh and point cloud, and improvements in reliable estimation.
- Requirements: C++17 and Python 3.6 or later required, with removal of support for Python 2.
Call to Practice
To further explore the novelties of OpenCV 5.0, consult the official announcement and start experimenting with the new features in your computer vision project.
Editorial Note and Disclaimer
The guides and content published on GoYou are the result of independent research and analysis activities, for informational, educational, and in-depth purposes.
GoYou does not constitute a journalistic publication nor an editorial product under Law No. 62/2001 and does not provide real-time information.
The GoYou project does not provide professional, technical, legal, or financial advice and disclaims any liability for the misuse of the information published.
In the Crypto sector, every investment involves risks: readers are invited to always inform themselves autonomously before making any decision.