程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> Compile C++ code in Matlab with OpenCV support

Compile C++ code in Matlab with OpenCV support

編輯:C++入門知識

Compile C++ code in Matlab with OpenCV support


Provides a function named as “mex_opencv(src)”


The code

function mex_opencv(src)

ARC = 'x64';

BIN_PATH = ['D:libscv.4.10', ARC ,'c12.0in'];
INC_OPT = '-ID:libscv.4.10includeopencv ';
INC_OPT = [INC_OPT, '-ID:libscv.4.10include '];

LIB_PATH = ['D:libscv.4.10', ARC ,'c12.0lib'];
LIBS = ' ';


LIBS_ORG = dir([LIB_PATH, '*.lib']);
for i = 1:numel(LIBS_ORG)
  CUR_LIB = strtrim(LIBS_ORG(i).name);
  if (CUR_LIB(end-4)~='d')
    LIBS = [LIBS, '-l', CUR_LIB, ' '];
  end
end

LIB_OPT = ['-L', LIB_PATH, ' ', LIBS];


% Add boost support
INC_OPT = [INC_OPT, ' ', '-ID:libsoost.57.0 '];
LIB_OPT = [LIB_OPT, ' ', '-LD:libsoost.57.0stages12.0', ARC, ' '];


compile_cmd = ['mex -v -O ', INC_OPT, LIB_OPT, src];
eval(compile_cmd);

PATH_STR = getenv('PATH');
if (numel(strfind(PATH_STR, 'cv'))==0)
  setenv('PATH', [BIN_PATH, ';', PATH_STR]);
end

end

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved