To use OpenCV from Matlab as integrated by the Mathworks, you will need to write your OpenCV calls in C++ and/or CUDA, using MEX. This works on Linux, Mac and Windows.
Type in Matlab:
Select “Computer Vision System Toolbox OpenCV Interface by MathWorks Computer Vision System Toolbox Team” and install.
Note: the examples require particular compilers depending on Matlab version and operating system.
Examples directory contains Computer Vision Toolbox examples from the Mathworks. Find the Matlab OpenCV example directory, in Matlab:
The examples below assume you’re starting from this directory. See the README.txt in each directory for compilation details. Some examples require a CUDA GPU.
Foreground Detector: build example
cd ForegroundDetector mexOpenCV backgroundSubtractorOCV.cpp
If the example fails to compile due to compiler mismatch, follow the instructions given in the error message.
Run the OpenCV Matlab demo:
You will see a Video Player window pop up with cars driving by, with the cars detected outlined in white rectangles.