View License

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

» Watch video

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.11 MB File ID: #25009 Version: 1.1




12 Aug 2009 (Updated )

C2Mat allows OpenCV data structures to be transferred between C++ and Matlab.

| Watch this File

File Information

C2Mat is a simple wrapper library that allows OpenCV data structures to be transferred between C++ and Matlab. It lets a program to combine the speed of OpenCV with the power of Matlab.

Your program and a Matlab window will run in separate threads. Using a COM interface, Matlab allows external programs (such as C2Mat) to access it. Using C2Mat to send text commands from your program will have the same effect as typing them in to the Matlab window. If you want to transfer data between your program and Matlab, calling the appropriate C2Mat command will allow you to copy the data (such as an IplImage) between your program's memory space and the Matlab workspace.

Some examples:
for(Sint32 i=0;i<10;i++)

//Send numbers to Matlab and square them

//Retrieve the numbers from Matlab
Sint32 *numbers2=engine->getSint32("numbers2");

//Send an IplImage to Matlab

//Blur it
engine->evalString("blurredIm=imfilter(im,fspecial('average', 15));");

//Return the result

Other examples are included in the .zip file. The main project homepage for C2Mat is

Another related program you might want to check out is "C/C++ and Matlab types convertor", available from Matlab Central.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Visual C++ (but probably could be compiled with GCC with little effort)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
17 Aug 2009 1.1

* Added explicit multithreading support, by providing lock() and unlock() functions for critical sections
* Improved implicit multithreading performance
* Minor documentation and commenting fixes

Contact us