Ask Your Question
2

OpenCV - Matlab bindings are not working

asked 2013-12-04 21:53:57 -0500

Bharath gravatar image

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:

I = imread('cameraman.tif'); cv.imshow(I);

“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 flag offensive close merge delete

Comments

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.

demarlio25 gravatar imagedemarlio25 ( 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?

krleon gravatar imagekrleon ( 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?

toby gravatar imagetoby ( 2014-06-03 06:19:54 -0500 )edit

3 answers

Sort by » oldest newest most voted
1

answered 2014-06-03 19:04:36 -0500

daferna2 gravatar image

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

edit flag offensive delete link more

Comments

I forgot about that one, thanks.

toby gravatar imagetoby ( 2014-06-04 04:40:23 -0500 )edit
1

answered 2014-06-03 07:04:28 -0500

toby gravatar image

updated 2014-06-03 08:08:57 -0500

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.

Basically I had to add the following lines to 'OpenCV-build'\modules\matlab\src:

-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(); }
-461 operator Ptr_DenseOpticalFlow() { return toPtrDenseOpticalFlow(); }

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

edit flag offensive delete link more
1

answered 2014-07-29 14:02:27 -0500

Steve Krawczyk gravatar image

updated 2014-07-29 14:07:44 -0500

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2013-12-04 21:53:57 -0500

Seen: 1,238 times

Last updated: Jul 29 '14