Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the official MATLAB computer vision toolbox actually OpenCV?

I can't help but notice that the MATLAB documentation for the Computer Vision toolbox has a very familiar feel, as if it is a re-write of the OpenCV docs and examples.

This is the MATLAB toolbox doc: http://www.mathworks.co.uk/products/computer-vision/

This is the opencv doc: http://docs.opencv.org/

Now I currently don't have MATLAB so I can't really check. Does anyone know if it is actually MEX OpenCV?

Cheers

like image 854
QED Avatar asked Jul 30 '14 17:07

QED


1 Answers

MATLAB for the most part uses OpenCV libraries underneath the hood for their CV toolbox. However, I would like to note that the Computer Vision Toolbox also implements some functionality that is independent of the OpenCV libraries but a good majority of what the toolbox provides uses OpenCV functionality. As quoted by Amro in his comment below:

Like many other areas, MATLAB wraps well-known libraries in an easy to use format (think BLAS/LAPACK, FFTW, SparseSuite, just to name a few!). So while MATLAB does make use of OpenCV in its CVST toolbox, it adds many other algorithms not found in OpenCV (either implemented in M-code or a lower-level language).

In addition, you are certainly able to interface OpenCV code with MATLAB if you have code already written in this platform and would like to interface that with MATLAB if you are developing MATLAB products and want to take full advantage of OpenCV. See this link for more details (courtesy of Amro): http://www.mathworks.com/discovery/matlab-opencv.html

Some of the MEX functions that called in the Computer Vision toolbox that ultimately get run call OpenCV C++ methods in the end. Inside the folder of where MATLAB is installed, if you actually take a look at the bin/os/ folder where os is the operating system you're using (for me, it's maci64), you'll see a libopencv folder. In this folder, you will see a lot of dynamically linked libraries that are basically those from OpenCV to which the MATLAB MEX functions that are part of the CV toolbox access in the end.

To navigate here in MATLAB, type this into the MATLAB command prompt:

>> cd (matlabroot)/bin/

.. then go into the folder that is for your operating system, then finally go to the libopencv folder.

You will also see what version of OpenCV is being used when calling the functions in the OpenCV library and the version number is appended at the end of each of the files. As such, if you want to use OpenCV for any of your MEX functions, perhaps the easiest thing would be to use the version that is pre-loaded into MATLAB to escape any compilation / setup headaches. With this, make sure you access the appropriate documentation for this version of OpenCV.

As such, for those functions in the toolbox that do use OpenCV, it's really a three step process:

  1. The Computer Vision Toolbox provides MATLAB wrappers for you to call your functions.
  2. Inside these MATLAB wrappers, there may be some pre-processing steps which then get passed to a MEX function. There may be functions in the CV toolbox in MATLAB where you're just calling a MEX function directly and the MATLAB wrapper may just include the doc string of what function you are calling.
  3. Inside the MEX code, they are calling OpenCV functions from the OpenCV libraries which then spit out the results you need. Now, I'm not quite sure which MATLAB CV functions are calling OpenCV functions themselves, but I do know that a good majority of the MATLAB CV toolbox does call OpenCV under the hood.
like image 62
rayryeng Avatar answered Sep 30 '22 09:09

rayryeng