Compile MATLAB bindings for OpenCV

asked 2014-02-28 04:09:50 -0600

updated 2014-02-28 05:57:28 -0600

I am trying to compile the MATLAB bindings for OpenCV 3.0, i.e. the current build from Github. I keep getting the following errors:

CMake Error at /opencv/modules/matlab/compile.cmake:47 (message):
  Failed to compile createCalibrateDebevec:
  In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’:

  error: ‘Ptr_CalibrateDebevec’ was not declared in this scope

This occurs for multiple files. I found this thread, Issue 3445, which discusses a couple of remedies, viz. adding some typedefs to the bridge.hpp file, but that results in even more errors while compiling. I also found this thread which suggested removing the problematic .cpp files and compiling. This resulted in error-free compilation followed by the usual make install. However, calling any OpenCV function from inside MATLAB now results in errors such as:

If = cv.dft(I, 'flags', cv.DFT_COMPLEX_OUTPUT);
Error using dft
cv::exception caught:
/home/xxx/opencv-master/modules/core/src/dxt.cpp:1760: error: (-215)
type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2
in function dft

Another error example:

im_denoise = cv.fastNlMeansDenoising(im_noise, 18);
Error using fastNlMeansDenoising
cv::exception caught:
error: (-215) almost_dist2weight_[0] == fixed_point_mult_ in function

Any help on how to resolve these issues is much appreciated!

edit retag flag offensive close merge delete


about the 1st error: please check, if your I variable is float type (i.e, if you loaded an image with imread, you'd have to convert it to CV_32F or similar before applying dft )

this seems to be a quite 'normal' or legit opencv error, you'd face the same situation in c++ or python.

berak gravatar imageberak ( 2014-02-28 04:24:05 -0600 )edit

How exactly would I convert a MATLAB image to CV_32F?

rdasgupta gravatar imagerdasgupta ( 2014-02-28 04:31:03 -0600 )edit

oh dear, if i only knew ;(

it's src.convertTo(dst,typeflag) in c++, so the matlab syntax might look like:

dst = cv.convertTo(src, cv.CV_32F)

(again, can't test, so pure speculation )

berak gravatar imageberak ( 2014-02-28 04:34:33 -0600 )edit

It seems that data type is not the problem. All the generated .m files corresponding to the Matlab bindings are just comments. There is no actual code in them. Apparently the compilation did not go properly, and the problem remains. :(

rdasgupta gravatar imagerdasgupta ( 2014-02-28 04:36:41 -0600 )edit

hmm, ok. can't help then, sorry.

berak gravatar imageberak ( 2014-02-28 04:38:59 -0600 )edit

hallo! I have the very same problem here. Did you find any solution in the end?

rick1987 gravatar imagerick1987 ( 2014-04-09 04:22:00 -0600 )edit