matlab调用opencv函数的配置

上传人:碎****木 文档编号:220862272 上传时间:2021-12-09 格式:DOCX 页数:4 大小:16.52KB
返回 下载 相关 举报
matlab调用opencv函数的配置_第1页
第1页 / 共4页
matlab调用opencv函数的配置_第2页
第2页 / 共4页
matlab调用opencv函数的配置_第3页
第3页 / 共4页
亲,该文档总共4页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《matlab调用opencv函数的配置》由会员分享,可在线阅读,更多相关《matlab调用opencv函数的配置(4页珍藏版)》请在金锄头文库上搜索。

1、1、 首先保证 vs2021 能正确调用 opencv 函数,2、 Matlab 中选择编译器,操作如下:翻开 matlab2021,输入 mex setup,消灭如下提示: Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see :/ mathworks /support/compilers/R2021a/win32.html Please choose your compiler for building MEX-f

2、iles:Would you like mex to locate installed compilers y/n?输入 y,消灭如下提示: Select a compiler:1 Lcc-win32 C 2.4.1 in C:PROGRA1MATLABR2021asyslcc2 Microsoft Visual C+ 2021 in C:Program FilesMicrosoft Visual Studio 20210 None Compiler:输入 2,消灭如下提示:Please verify your choices:Compiler: Microsoft Visual C+ 202

3、1Location: C:Program FilesMicrosoft Visual Studio 2021 Are these correct y/n?输入 y消灭如下提示,说明成功:*Warning: MEX-files generated using Microsoft Visual C+ 2021 require that Microsoft Visual Studio 2021 run-time libraries beavailable on the computer they are run on.If you plan to redistribute your MEX-file

4、s to other MATLAB users, be sure that they have the run-time libraries.*Trying to update options file: C:Documents and SettingszhangjingApplication DataMathWorksMATLABR2021amexopts.batFromtemplate:C:PROGRA1MATLABR2021abinwin32mexoptsmsvc100opts.batDone . . .*Warning: The MATLAB C and Fortran API has

5、 changed to support MATLAB variables with more than 232-1 elements.In the near futureyou will be required to update your code to utilize the new API. You can find more information about this at: :/ mathworks /help/techdoc/matlab_external/bsflnue-1.html Building with the -largeArrayDims option enable

6、s the new API.*3、 配置一些名目在 matlab 中,输入 mex v下面会有显示:- Default options filename found in C:Documents and SettingszhangjingApplication DataMathWorksMATLABR2021a-Options file= C:Documents and SettingszhangjingApplication DataMathWorksMATLABR2021amexopts.bat-MATLABCOMPILER= C:PROGRA1MATLABR2021A= cl-Compi

7、ler flags:COMPFLAGS= /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE/D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo/MDOPTIMFLAGS= /O2 /Oy- /DNDEBUG DEBUGFLAGS= /Z7arguments=Name switch= /Fo。此处省略一些选中上面 Options file=后面的局部,右键-Open Selection,翻开 mexopts.bat找到下面局部,增加红色的局部set MATLAB=%MATLAB

8、%set VSINSTALLDIR=C:Program FilesMicrosoft Visual Studio 2021 set VCINSTALLDIR=%VSINSTALLDIR%VCrem In this case, LINKERDIR is being used to specify the location of the SDK set LINKERDIR=C:Program FilesMicrosoft SDKsWindowsv7.0Aset PATH=%VCINSTALLDIR%bin;%VCINSTALLDIR%VCPackages;%VSINSTALLDIR%Com mon

9、7IDE;%VSINSTALLDIR%Common7Tools;%LINKERDIR%bin;%MATLAB_BIN%;% PATH%set INCLUDE=%VCINSTALLDIR%INCLUDE;%VCINSTALLDIR%ATLMFCINCLUDE;%LINKERDIR%include;%INCLUDE%;D:opencvinclude;D:opencvincludeopencv;D:opencvin cludeopencv2set LIB=%VCINSTALLDIR%LIB;%VCINSTALLDIR%ATLMFCLIB;%LINKERDIR%lib;%MATLAB%externli

10、bwin32;%LIB%;D:opencvbuildx86vc10lib set MW_TARGET_ARCH=win32rem * rem Compiler parametersrem * set COMPILER=clset COMPFLAGS=/c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE/D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo/MDset OPTIMFLAGS=/O2 /Oy- /DNDEBUG set DEBUGFLAGS=/Z7set NAME_OB

11、JECT=/Forem * rem Linker parametersrem * set LIBLOC=%MATLAB%externlibwin32microsoftset LINKER=linkset LINKFLAGS=/dll /export:%ENTRYPOINT%/LIBPATH:“%LIBLOC%“ opencv_core231d.lib opencv_highgui231d.lib opencv_video231d.lib opencv_ml231d.lib opencv_legacy231d.lib opencv_imgproc231d.lib opencv_flann231d

12、.lib opencv_features2d231d.lib opencv_calib3d231d.lib opencv_objdetect231d.lib opencv_contrib231d.lib libmx.lib libmex.lib libmat.lib/MACHINE:X86 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 /mani

13、fest/incremental:NO /implib:“%LIB_NAME%.x“/MAP:“%OUTDIR%MEX_NAME%MEX_EXT%.map“set LINKOPTIMFLAGS=留意上面 include l处ib要加分号,LINKFLAGS 处各个 lib 之前要回空格在 matlab 当前名目下建立cpp 文件简洁方法,txt 改后缀为cpp,vs 翻开敲入代码,代码需要是Matlab 的C 语言接口风格,函数内部调用OpenCV 函数演示功能,简化后的代码: 程序命名为useOpenCV.cpp 保存。#include“mex.h“ #include“cv.h“ #include“highgui.h“ using namespacecv;voidmexFunction (int nlhs, mxArray *plhs, / 输出参数个数,及输出参数数组int nrhs, const mxArray *prhs) / 输入参数个数,及输入参数数组char name256;int buflens =mxG

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 教育/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号