1 % This cppmake.m is for MATLAB
2 % Function: compile c++ files which rely on OpenCV for Matlab using mex
3 % Modified by Jessica
4 % Date : 2014-9-10
5 % HomePage: http://www.cnblogs.com/lukylu/
6 % Email : wanglu@innomotion.biz
7
8 % Matlab and C++ mixed programming(dependent on opencv library)
9 % First step(before exeuting this program): use "mex -setup" to choose your c/c++ compiler
10 clear all;
11
12 % Get the architecture of this computer
13 is_64bit = strcmp(computer,‘MACI64‘) || strcmp(computer,‘GLNXA64‘) || strcmp(computer,‘PCWIN64‘);
14
15
16 %----------------------------------------------------------------------------------------------
17 %% The configuration of compiler
18 % You need to modify this configuration according to your own path of OpenCV
19 % Notice: if your system is 64bit, your OpenCV must be 64bit!
20 out_dir=‘./‘;
21 CPPFLAGS = ‘ -O -DNDEBUG -I.\ -IF:\opencv\build\include -IF:\opencv\build\include\opencv -IF:\opencv\build\include\opencv2‘; % your OpenCV "include" path
22 LDFLAGS = ‘ -LF:\opencv\build\x86\vc10\lib‘; % your OpenCV "lib" path
23 %LIBS = ‘ -lopencv_calib3d249d -lopencv_contrib249d -lopencv_core249d -lopencv_features2d249d -lopencv_flann249d -lopencv_gpu249d -lopencv_highgui249d -lopencv_imgproc249d -lopencv_legacy249d -lopencv_ml249d -lopencv_nonfree249d -lopencv_objdetect249d -lopencv_photo249d -lopencv_stitching249d -lopencv_ts249d -lopencv_video249d -lopencv_videostab249d‘;
24 LIBS = ‘ -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_photo249 -lopencv_stitching249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249‘;
25 if is_64bit
26 CPPFLAGS = [CPPFLAGS ‘ -largeArrayDims‘];
27 end
28
29 % add your files here!!
30 compile_files = {
31 %the list of your code files which need to be compiled
32 ‘ImageCalibration.cpp‘
33 };
34 %----------------------------------------------------------------------------------------------
35
36 %----------------------------------------------------------------------------------------------
37 %% compiling
38 for k = 1 : length(compile_files)
39 str = compile_files{k};
40 fprintf(‘compilation of: %s\n‘, str);
41 str = [str ‘ -outdir ‘ out_dir CPPFLAGS LDFLAGS LIBS];
42 args = regexp(str, ‘\s+‘, ‘split‘);
43 mex(args{:});
44 end
45 fprintf(‘Congratulations, compilation successful!!!\n‘);
46 %----------------------------------------------------------------------------------------------