Combining OpenCV, C++ and Matlab MEX-functions: Not as easy I thought!

OpenCV and Matlab are my favorite tools. Recently I decided to write a C++ interface between the two to take advantage of some of the neat features of OpenCV’s C++ interface. But alas, I was met with crash after crash of Matlab. Initially, I had no clue. After doing some digging, I found some information.

Actually, I have not been able to fix my problems yet with above suggestions. I will keep posting till I find some solution.


  1. There are many things that may go wrong when you are mexing…starting from compiling issues to gateway function errors. Since matlab is crashing, you probably dont have a clu about what the error looks like. Try printing out your gateway mex function code by code adding enough number of pauses. I worked extensively with mex functions through my PhD, successfully mexed fortran code in matlab.

  2. @ Bhushan, Thanks for the advise. I Was able to solve this problem eventually. You can refer to my more recent post “Fixing the problem”.

Leave a Reply

Your email address will not be published. Required fields are marked *