2010年8月30日 星期一

A list of Janine Jansen - Mendelssohn Violin Concerto

繼上一篇"a list of Janine Jansen", 這次再多加 Mendelssohn Violin Concerto(孟德爾頌:小提琴協奏曲)

Mendelssohn Violin Concerto, Janine Jansen 1-4


Mendelssohn Violin Concerto, Janine Jansen 2-4


Mendelssohn Violin Concerto, Janine Jansen 3-4


Mendelssohn Violin Concerto, Janine Jansen 4-4

2010年8月3日 星期二

在matlab環境編譯mex + opencv library

由於工作的需要, 所以需要將別人所寫好的mex funtion重編一次;;;但是該mex function裡面有用到opencv的lib, 所以在編譯mex的時候, 需要將opencv的lib也一起加到matlab的環境中.

系統環境: win 7
matalb: matalb 2010a
c++ compiler: visual studio 2008

首先先設定matlab所選定的compiler:

1. matlab command: mex -setup
(C:\Users\xxx\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat 為預設的mex option file)

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] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2008 require
that Microsoft Visual Studio 2008 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.
***************************************************************************

Trying to update options file: C:\Users\xxx\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2010a\bin\win64\mexopts\msvc90opts.bat
Done . . .
**************************************************************************

2. 修改mexopt.bat
由於opencv所放置的路徑為: C:\Program Files\OpenCV-2.1.0\vs2008
所以修改mexopts.bat檔, 請參考.
主要修改的有:
set OPENCVDIR=C:\Program Files\OpenCV-2.1.0\vs2008
set MATLAB=%MATLAB%
set VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0
set VCINSTALLDIR=%VSINSTALLDIR%\VC
rem In this case, LINKERDIR is being used to specify the location of the SDK
set LINKERDIR=C:\Program Files\\Microsoft SDKs\Windows\v6.0A\
set PATH=%VCINSTALLDIR%\bin\amd64;%LINKERDIR%\bin\x64;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%MATLAB_BIN%;%PATH%
set INCLUDE=%LINKERDIR%\include;%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\VCPackages;%INCLUDE%;%OPENCVDIR%\include\opencv
set LIB=%LINKERDIR%\LIB\x64;%VCINSTALLDIR%\LIB\amd64;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%MATLAB%\extern\lib\win64;%LIB%;%OPENCVDIR%\lib;%OPENCVDIR%\bin
...略...
set LINKFLAGS=/dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map" cv210.lib HighGUI210.lib cxcore210.lib

3. build mex: mex -c xxx.cpp