# OpenCV - Matlab bindings are not working

I took the trouble to install OpenCV by building the libraries myself, as instructed in this link:

http://docs.opencv.org/trunk/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation

After all this hard work, it was disappointing to get this error message for using imshow:

“Error using cv.imshow Attempt to execute SCRIPT imshow as a function: D:\OpenCV\Builds\modules\matlab+cv\imshow.m”

If you have a solution, please let me knw.

Thanks,

Bharath

edit retag close merge delete

I am having the same issues. Have you found a solution yet? I was able to pull up the help 'help cv.imshow' but when trying to execute the function I received the same error as you.

( 2014-01-02 12:55:40 -0500 )edit

Same issue. In my case, it does not appear the mex files are being built, so the .m file is just the help. Is there a way to build the mex files separately?

( 2014-01-11 19:10:59 -0500 )edit

I have the same issue. I did find out that, for me, some functions do have an accompanying mex-file like add. This function does work (after I added the path to my cv build). Anybody find a solution yet?

( 2014-06-03 06:19:54 -0500 )edit

Sort by » oldest newest most voted

Hi, I submitted the patch. There is also a separate bug with the cv.m file. If you open up the m-file in MATLAB you will see two errors. For some reason the constants KAZE and AKAZE are not being assigned to anything and MATLAB doesn't like this. I just assign these constants to zero because I do not use any CV modules that need these constants. Java seems to have a similar problem with AKAZE: https://github.com/Itseez/opencv/pull/2822

more

I forgot about that one, thanks.

( 2014-06-04 04:40:23 -0500 )edit

I got the same error due to the fact that my mex files were missing. In order to get the mex files you need to compile the latest OpenCV from source. Make sure CMake does not give any errors. Then I compiled things with Visual Studio. This did not work due to Ptr_DenseOpticalFlow not being defined. Thus I had to implement a fix found here: https://github.com/Itseez/opencv/pull/2783.

-53  #include <opencv2/video/tracking.hpp>
...
-80  typedef cv::Ptr<DenseOpticalFlow> Ptr_DenseOpticalFlow;
...
-458 // ---------------------------   Ptr_DenseOpticalFlow   -------------------
-459 Bridge& operator=(const Ptr_DenseOpticalFlow& ) { return *this; }
-460 Ptr_DenseOpticalFlow toPtrDenseOpticalFlow() { return Ptr_DenseOpticalFlow(); }


Then I could compile the opencv_matlab module.

Note that this compilation took a long time to complete so be patient!

If all fails you could also try using pre-compiled mex files, found at the end of this post: http://seevisionc.blogspot.nl/2014/03/compiling-opencv-30-with-matlab-support.html

more

I had the same problem. In addition to making sure you are doing a release build, also double check that matlab has a compiler set up properly. In matlab type: mex -setup

more

Official site

GitHub

Wiki

Documentation