File Exchange

image thumbnail

Matalb and OpenCV

version 1.2 (1.11 MB) by

How to Connect Matlab with OpenCV to use the different functions offered by OpenCV using mex-files.



View License

How to Connect Matlab with OpenCV to use the different functions offered by OpenCV using mex-files.

The purpose of this connections is to be able to write function in C++ using the OpenCV library to call functions that can for exemple extract feature points using SIFT/SURF or ORB algorithem or detect faces that are on an image ...

To use this functionality you need to have some knowledge about C++ and also how the mex compiler of Matlab work.

Comments and Ratings (16)

peng wang


Myraj (view profile)

Hi sir
I'm using matlab r2015a, opencv 2.4.13 and visual studio 2013

I can't connect matlab with opencv by following steps that you put, please help!!!

Karel Lebeda

I expected an actual wrapper...

Rose Ann Haft

This file doesn't seem to be working with 2014 or 2015 versions. Is there an update or suggestions of how to make this compatible?

jose verdugo

hi,i'm using Matlab2012b-64bit, VS2010-Ultimate, and openCV 2.3

when running mex displayimage.cpp i got this eror :

displayimage.cpp(5) : fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
  C:\PROGRA~1\MATLAB\R2012B\BIN\MEX.PL: Error: Compile of 'displayimage.cpp' failed.
Error using mex (line 206)
Unable to complete successfully.

please help me kind sir and thanks in advance

BIREM Merwan


For "sehreen" try to read carefully the file that show how to connect OpenCv with Matlab.

For "imran" I try my self using 32bit version and it is working well unfonutly i didn't try it using the 64bit version but we can try if you want and try to fix this problem.

best regards Merwan


Corey (view profile)

Can you explain what the difference is between this library?:


imran (view profile)


I am working on a project which consist to control two FireWire Cameras simultaneously. I am looking for a toolkit which allow controlling two cameras simultaneously in Matlab. I see OpenCV in Matlab but I don't know How to Install OpenCV in Matlab.

I'm using 64-bit Matlab, Open CV 2.4.9 and Microsoft SDK 7.1

Can you help me to install OpenCV in Matlab because I don't understand too the tutorial.

How to create MEX file

kind regards


Can anyone plz tellme the detailed procedure of how to connect the matlab with opencv and run the functions of opencv in matlab.

BIREM Merwan

Did you modify the "mexopts.bat" file ??


rana (view profile)

hey .. i am using matlab 2013a and opencv2.4.5 .. i obtained this error
'displayImage.cpp(5) : fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory '
i can't include any header,, is that because a configuration to visual studio 2012 is necessary?


I am using Matalb2012b-64bit, VS2010-Professional, and OpenCV 2.4.5.

During the compilation I got the following error:

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xutility(287) : error C2582: 'operator '='....

Adding _SECURE_SCL=1 to COMPFLAGS into mexopts.bat file solved this problem for me.




BIREM Merwan

I didn't try to connect OpenCV with Matlab-2012, but i think it's possible (with the appropriate compiler and version of OpenCV) ...

Fernando Sato

Does this tutorial works on MATLAB 2012a?



A new PDF file added to help and guid the user on how to connect Matlab and OpenCV


Start with : "How to connect Matlab with OpenCV on Windows7.pdf"

MATLAB Release
MATLAB 7.11 (R2010b)

Inspired by: Image Processing with GUIDE

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video