MATLAB and OpenCV

Using OpenCV with MATLAB

MATLAB® and OpenCV are complementary tools for algorithm development, image and video analysis, and vision system design. MATLAB provides integration with OpenCV through the OpenCV C++ API.

By integrating OpenCV with MATLAB, you can:

Use and explore current research algorithms, whether they are implemented in MATLAB or OpenCV

Use OpenCV algorithms with the convenience of the data access, image acquisition, and visualization capabilities in MATLAB

Use MATLAB to explore, analyze, and debug designs that incorporate OpenCV algorithms

Using OpenCV with MATLAB Highlights

MATLAB OpenCV Interface

The OpenCV interface makes it easy to bring single functions and entire OpenCV-based C++ projects into MATLAB using MEX. The OpenCV interface provides:

Prebuilt OpenCV binaries that eliminate the need to compile and build OpenCV

Build script to create OpenCV based MEX-files

Data type conversions between MATLAB and OpenCV

Examples to help you get started with common workflows such as feature detection and extraction, image processing, and motion estimation

You can get started using this quick command line example:

% After installing support package
>> mexOpenCV detectORBFeatures.cpp
% Then call this function in MATLAB just like any other MATLAB command
>> im = imread(‘cameraman.tif’);
>> keypoints = detectORBFeatures(im);

Full details about installing the OpenCV support package and this example are explained in detail in the Using OpenCV with MATLAB video. This video includes instructions for downloading the support package, understanding and using the syntax, and exploration of examples included in the download.

Computer Vision with MATLAB

MATLAB and Computer Vision System Toolbox™ offer functionality not available in OpenCV. The toolbox provides algorithms for object detection, image recognition, and 3D lidar processing. Interactive apps such as the Camera Calibration App and Image Labeling App can save significant time when developing image algorithms.

MATLAB has new capabilities in deep learning for computer vision including access to the latest deep learning models, and training acceleration using multiple GPUs, the cloud, or clusters. You can convert your models to CUDA code with GPU Coder™. Generated CUDA code runs models up to 7x faster than TensorFlow.