MATLABでmex -setupしたときの一例とこれにOpenCVライブラリを追加する方法
mex -setup
>> mex -setup Please choose your compiler for building external interface (MEX) files: Would you like mex to locate installed compilers [y]/n? y Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2007b\sys\lcc [2] Microsoft Visual C++ 2005 in C:\Program Files\Microsoft Visual Studio 8 [3] Microsoft Visual C++ .NET 2003 in C:\Program Files\Microsoft Visual Studio .NET 2003 [0] None Compiler: 2 Please verify your choices: Compiler: Microsoft Visual C++ 2005 Location: C:\Program Files\Microsoft Visual Studio 8 Are these correct?([y]/n): y *************************************************************************** Warning: MEX-files generated using Microsoft Visual C++ 2005 require that Microsoft Visual Studio 2005 run-time libraries be available on the computer they are run on. If you plan to redistribute your MEX-files to other MATLAB users, be sure that they have the run-time libraries. You can find more information about this at: http://www.mathworks.com/support/solutions/data/1-2223MW.html *************************************************************************** Trying to update options file: C:\Documents and Settings\\Application Data\MathWorks\MATLAB\R2007b\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2007b\bin\win32\mexopts\msvc80opts.bat Done . . .
コンソールの問いかけは以下のとおり.
OpenCVライブラリをMEXから利用する方法
mexopts.batを編集する.General parameters節にあるINCLUDEとLIBを拡張すればよいから,次のように追記する.
set INCLUDE=C:\Program Files\OpenCV\cv\include;C:\Program Files\OpenCV\cxcore\include;C:\Program Files\OpenCV\otherlibs\highgui;%INCLUDE% set LIB=C:\Program Files\OpenCV\lib;%LIB%
MEXファイルからDLLに静的リンクするときには,次のとおりに記述しておく.
#pragma comment(lib, "cv.lib") #pragma comment(lib, "cxcore.lib") #pragma comment(lib, "highgui.lib")