Trouble generating Matlab bindings using latest OpenCV 3.4.0 software

asked 2018-02-09 20:31:17 -0600

sid311 gravatar image

Hello,

I'm trying to install the new OpenCV source files on Windows along with the latest opencv_contribute using CMake but keep running into this error:

CMake Warning at C:/OpenCV/opencv_contrib-master/modules/matlab/CMakeLists.txt:77 (message): Your compiler is 64-bit but your version of Matlab is 32-bit. To build Matlab bindings, please switch to a 32-bit compiler. Call Stack (most recent call first): C:/OpenCV/opencv_contrib-master/modules/matlab/CMakeLists.txt:90 (warn_mixed_precision)

However, I know I am using a 64-bit version of Matlab:

image description

Here are the paths I am using: image description

I had to manually find the paths for the libmat, libmex, and libmx DLLs, but the rest were found by CMake. Not sure if those are correct.

Here are my setup details:

  • CMake 3.10.2 using Visual Studio 15 2017 Win64 (as seen in one of the screenshots above)
  • OpenCV 3.4.0 and OpenCV_Contribute 3.4.0 (assumed, latest build from GitHub)
  • Matlab 2017b, C++ compiler set as Microsoft Visual C++ 2017, Computer Vision System Toolbox OpenCV Interface installed (v 17.2.1.0)
  • Python 3.6.4 64 bit
  • Windows 10 Pro 64 bit

Did I have to create the opencv_contribute modules first using CMake? I have set the path to the opencv_contribute modules in CMake.

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

Comments

I think the issue is the way the CMake files determine what architecture of Matlab is installed.

In the Cmake file ''OpenCVFindMatlab.cmake', line 139:

set(ARCHITECTURES_ "maci64" "maci" "glnxa64" "glnx64" "sol64" "sola64" "win32" "win64" )

I think the function automatically sets MATLAB_ARCH=win32 in the 'CMakeVars.txt' file if it finds a 'win32' folder in the Matlab install directory.

So I removed "win32" from the function parameters:

set(ARCHITECTURES_ "maci64" "maci" "glnxa64" "glnx64" "sol64" "sola64" "win64" )

The option 'BUILD_opencv_matlab' appears in the configuration options window of CMake. I check the option and click on the 'Configure' button and now receive the following in the output window:

sid311 gravatar imagesid311 ( 2018-02-09 22:07:55 -0600 )edit

(Sorry, ran out of characters)

Matlab:                        YES
mex:                         C:/Program Files/MATLAB/R2017b/bin/mex.bat
Compiler/generator:          Working

Note: both win32 and win64 directories are created when installing Matlab 64bit.

Will build and report back later on how everything went.

sid311 gravatar imagesid311 ( 2018-02-09 22:10:38 -0600 )edit

Seems to work for the most part except I do get one failed project.

Output from Visual Studio:

72>  Failed to compile CamShift: CamShift.cpp

72>Done building project "opencv_matlab.vcxproj" -- FAILED.

Not sure how to resolve this error. Or if it even matters. How to check if Matlab files are correctly built?

sid311 gravatar imagesid311 ( 2018-02-14 01:11:59 -0600 )edit

Building the opencv_matlab project by itself gives these errors:

Severity    Code    Description Project File    Line    Suppression State
Error   C2039   'type': is not a member of 'cv::DataType<Scalar>'   opencv_matlab`  C:\OpenCV\build\modules\matlab\CUSTOMBUILD  1   

Error   C2065   'type': undeclared identifier   opencv_matlab   C:\OpenCV\build\modules\matlab\CUSTOMBUILD  1   

Error   C2664   'cv::Mat::Mat(cv::Mat &&)': cannot convert argument 1 from  opencv_matlab   C:\OpenCV\build\modules\matlab\CUSTOMBUILD  1
sid311 gravatar imagesid311 ( 2018-02-14 01:14:34 -0600 )edit