hey viewer, we're moving!

We are currently transitioning to a new web system, so we are not updating this wikisite anymore.

The public part of the new web system is available at http://www.ira.disco.unimib.it


From Irawiki

Jump to: navigation, search

Thanks to Kota Yamaguchi for this awesome Matlab Library



Extremely easy installation procedure (requires OpenCV and Matlab)

Clone the git repo

git clone git://github.com/kyamagu/mexopencv.git

Compile it

cd mexopencv
make MATLABDIR=/path/to/ur/Matlab


Extremely easy to use

Pick your function

Go to this page and choose the function you need.


ORB feature matching

im1 = imread('img1.png');
im2 = imread('img2.png');
[kpts1,descs1] = cv.ORB(im1);
[kpts2,descs2] = cv.ORB(im2);
matcher = cv.DescriptorMatcher('BruteForce-Hamming');
matches = matcher.match(descs2);
im = cv.drawMatches(im1,kpts1,im2,kpts2,matches);

Write your OpenCV function

If the OpenCV function you need is not in the list of the availabe ones, just write your own. The mexFunction is very simple

#include "mexopencv.hpp"
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
    // Check arguments
    if (nrhs!=2 || nlhs>1)
        mexErrMsgIdAndTxt("myfunc:invalidArgs","Wrong number of arguments");
    // Convert MxArray to cv::Mat and cv::Size
    cv::Mat src = MxArray(prhs[0]).toMat(), dst;
    cv::Size ksize = MxArray(prhs[1]).toSize();
    // Use your favorite OpenCV function
    cv::blur(src, dst, ksize);
    // Convert cv::Mat back to mxArray*
    plhs[0] = MxArray(dst);
Personal tools