opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.21k stars 5.73k forks source link

Problem with binding MATLAB #2181

Open bargul opened 5 years ago

bargul commented 5 years ago
System information (version)
Detailed description

I am trying to use opencv and opencv_contrib functions in MATLAB.

I followed the step in: https://github.com/opencv/opencv_contrib/tree/master/modules/matlabFirst I got a warning in CMake that files need to be compiled with 32 bit. However MATLAB releases after 2014 does not support 32 bit. So I changed line 137 of OpenCVFindMatlab.cmake file from set(ARCHITECTURES "maci64" "maci" "glnxa64" "glnx64" "sol64" "sola64" "win32" "win64" ) to set(ARCHITECTURES "maci64" "maci" "glnxa64" "glnx64" "sol64" "sola64" "win64" ). Then it configured and generated build succesfully. However, mex files are not generated.

Is the problem matlab directories?

image

saskatchewancatch commented 5 years ago

Sounds quite a bit like #1551

In versions of Matlab where 32-bit variant existed, there was a bug in the mexext.bat script which partly caused the problem in #1551 to happen.

I've confirmed this withe Matlab 2014a, but unfortunately I do not have Matlab 2019 on hand to be able to see if there's something wrong with mexext.bat in the newer versions where there is no 32-bit variant.

I strongly suspect you having to remove "win32" from that list has to do with the output returned from mexext.bat that CMake's "find Matlab" script uses.

OgreTransporter commented 4 years ago

That is indeed a bug. I have installed R2017b and R2019a here. Both have a win32 and a win64 subdirectory. The break in the loop https://github.com/opencv/opencv_contrib/blob/e6f32c6a69043456a806a4e802ee3ce7b7059c93/modules/matlab/cmake/OpenCVFindMatlab.cmake#L141 terminates the loop without checking the contents of the directory. There are a number of DLLs in the win32 directory. win32 should be removed from the list.