Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile MATLAB bindings for OpenCV

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:
  /opencv/build/modules/matlab/src/createCalibrateDebevec.cpp:
  In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’:

  /opencv/build/modules/matlab/src/createCalibrateDebevec.cpp:46:3:
  error: ‘Ptr_CalibrateDebevec’ was not declared in this scope

This occurs for multiple files. I found this thread, 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:
/home/xxx/opencv-master/modules/photo/src/fast_nlmeans_denoising_invoker.hpp:146:
error: (-215) almost_dist2weight_[0] == fixed_point_mult_ in function
FastNlMeansDenoisingInvoker

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

like image 275
Riddhiman Dasgupta Avatar asked Feb 28 '14 10:02

Riddhiman Dasgupta


1 Answers

Regarding the 'cv::exception caught' errors you get: it seems like cv is expecting the input image to be of floating point type (either single or double, 'CV_32FC1' or 'CV_64FC1' respectively).
Try converting your input image I or im_noise to floating point using im2single or im2double and see if these errors recurr.

like image 151
Shai Avatar answered Sep 30 '22 08:09

Shai