Build MEX-Files for OpenCV Interface
Use the OpenCV Interface files to integrate your OpenCV C++ code into MATLAB® and build MEX-files that call OpenCV functions.
The mexOpenCV
interface utility functions convert data between OpenCV
and MATLAB. These functions support CPP-linkage only.
The Computer Vision Toolbox™ Interface for OpenCV in MATLAB API supports OpenCV version 4.2.0, 4.5.0 and 4.7.0.
Create MEX-File from OpenCV C++ file
This example creates a MEX-file from a wrapper C++ file and then tests the newly
created file. The example uses the OpenCV template matching algorithm wrapped in a C++
file, which is located in the example/TemplateMatching
folder.
Change your current working folder to the
example/TemplateMatching
folder:cd(fullfile(fileparts(which('mexOpenCV')),'example',filesep,'TemplateMatching'))
Create the MEX-file from the source file:
mexOpenCV matchTemplateOCV.cpp
Run the test script, which uses the generated MEX-file:
testMatchTemplate
Create Your Own OpenCV MEX-files
Call the mxArray
function with your source
file.
mexOpenCV
yourfile.cpp
For help creating MEX files, at the MATLAB command prompt, type:
help mexOpenCV
Run OpenCV Examples
Each example subfolder in the Computer Vision Toolbox Interface for OpenCV in MATLAB support package contains all the files you need to run the example. To run
an example, you must call the mexOpenCV
function with one of the
supplied source files.