1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > matlab调用opencv的函数

matlab调用opencv的函数

时间:2024-06-03 12:09:28

相关推荐

matlab调用opencv的函数

由于工作需要,需要使用Matlab 中的mexFunction调用C++程序, 该 mex function里又要用到opencv中的lib,所以在编译mex的时候,需要将opencCv的lib加到matlab的环境中。

系统环境: win XP matalb: matalb a

c++ compiler: visual studio

首先先设定matlab所选定的compiler:

1. matlab command: mex -setup

(C:\Users\xxx\AppData\Roaming\MathWorks\MATLAB\Ra\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++ SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0

[0] None

Compiler: 1

Please verify your choices:

Compiler: Microsoft Visual C++ 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++ require

that Microsoft Visual Studio 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\Ra\mexopts.bat

From template: C:\PROGRA~1\MATLAB\Ra\bin\win64\mexopts\msvc90opts.bat

Done . . .

**************************************************************************

2. 修改mexopt.bat

由于opencv所放置的路径为: D:\Program Files\OpenCV2.1\vc所以修改mexopts.bat(路径可以通过在Matlab中输入mex -v 得到),请参考,红色字体为添加和修改的部分:

set OPENCVDIR=D:\Program Files\OpenCV2.1\vc

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 cv210d.lib HighGUI210d.lib cxcore210d.lib

3. build mex: mex xxx.cppfrom:/ykaitao/item/4f2d4ad0b31760332b35c786

/shaoxiaohu1/article/details/8287637

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。