This repository has been archived by the owner on Feb 25, 2019. It is now read-only.
forked from zk00006/OpenTLD
-
Notifications
You must be signed in to change notification settings - Fork 14
/
compile.m
181 lines (161 loc) · 5.29 KB
/
compile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
% Copyright 2011 Zdenek Kalal
%
% This file is part of TLD.
%
% TLD is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% TLD is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with TLD. If not, see <http://www.gnu.org/licenses/>.
% Compiles mex files
clc; clear all; cd mex;
% BEFORE EXECUTION:
% Check prefix and files lines if they correspond to your system.
% (Un)comment as necessary.
% Logic to distinguish between octave and Matlab on Windows
% changes by https://github.com/a432511
if ispc
disp('PC');
include = ' -IC:\OpenCV2.2\include\opencv\ -IC:\OpenCV2.2\include\';
libpath = 'C:\OpenCV2.2\lib\';
files = dir([libpath '*.lib']);
lib = [];
if exist('OCTAVE_VERSION','builtin')
disp('octave');
for i = 1:length(files),
file = files(i).name;
ind = index(file,'.');
file = substr(file, 1, ind - 1);
lib = [lib ' -l' file];
end
%disp(lib);
eval(['mex -v' include ' -L' libpath ' lk.cpp' lib]);
mex -c tld.cpp
mex fern.cpp tld.o
mex linkagemex.cpp
mex bb_overlap.cpp
mex warp.cpp
mex distance.cpp
else
disp('matlab');
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
eval(['mex lk.cpp -O' include lib]);
mex -O -c tld.cpp
mex -O fern.cpp tld.obj
mex -O linkagemex.cpp
mex -O bb_overlap.cpp
mex -O warp.cpp
mex -O distance.cpp
end
elseif ismac
disp('Mac');
% [bilderbuchi] Please test this again. Also, octave if possible
%
% Tested on MacOs 10.6.7
% with matlab R2010a maci64
% with g++ (GCC) 4.0.1 (Apple Inc. build 5494)
%
% brew install opencv
%
% prefix = '/opt/local/'; %zdenek's prefix (opencv2.2?)
prefix = '/usr/local/'; % /opt/local -> /usr/local
include = [' -I' prefix 'include/' ' -I' prefix 'include/opencv/'];
libpath = [prefix 'lib/'];
files = dir([libpath 'libopencv*.dylib']);
lib = [];
if exist('OCTAVE_VERSION','builtin')
disp('octave');
%for i = 1:length(files), %parser not working I think. look in the unix section.
% file = files(i).name;
% file = substr(file, 4, length(file) - 9);
% lib = [lib ' -l' file];
%end
lib = ' -lopencv_core -lopencv_imgproc -lopencv_video'; %Is this opencv 2.2?
eval(['mex lk.cpp' include ' -L' libpath lib]);
mex -c tld.cpp
mex fern.cpp tld.o
mex linkagemex.cpp
mex bb_overlap.cpp
mex warp.cpp
mex distance.cpp
else
disp('matlab')
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
%lib = ' -lopencv_core -lopencv_imgproc -lopencv_video';
eval(['mex lk.cpp -O' include ' -L' libpath lib]);
mex -O -c tld.cpp
mex -O fern.cpp tld.o
mex -O linkagemex.cpp
mex -O bb_overlap.cpp
mex -O warp.cpp
mex -O distance.cpp
end
elseif isunix
disp('Unix');
% Tested on Ubuntu maverick (10.10)
% with matlab R2010a glnx86
% with gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
%
% apt-get install libcv-dev libhighgui-dev
%
%[bilderbuchi]:
% Also tested on Ubuntu maverick (10.10)
% with matlab R20009a glnx86 (replaced ~ with dummy variables, don't expect performance impact)
% with gcc 4:4.4.4-1ubuntu2
% with opencv 2.1.0-2
%
% Also runs with (self-compile) octave 3.4 (possibly with 3.2 now, too)
% Tracking doesn't work, though
prefix = '/usr/'; %OpenCV 2.1 libraries
%prefix = '/usr/local'; %OpenCV 2.2 libraries?
include = [' -I' prefix 'include/opencv/' ' -I' prefix 'include/']; %OpenCV 2.1 libraries
libpath = [prefix 'lib/']; %OpenCV 2.1 libraries
files = [dir([libpath 'libcv.so']) dir([libpath 'libcxcore.so'])]; %OpenCV 2.1 libraries
%files = dir([libpath 'libopencv*.so.2.2']); %OpenCV 2.2 libraries?
lib = [];
if exist('OCTAVE_VERSION','builtin')
disp('octave');
%mkoctfile has a more picky syntax than matlab-mex concerning included libraries
for i = 1:length(files)
file = files(i).name;
ind=index(file,'.'); %Find first occurence of . to correctly parse filenames like libopencv.so.2.2
file = substr(file, 4, ind-4);
lib = [lib ' -l' file];
end
% lib=' -lcv -lcxcore'; %hard-coded library arguments
disp(lib);
eval(['mex -v lk.cpp ' include ' -L' libpath lib]);
mex -c tld.cpp
mex fern.cpp tld.o
mex linkagemex.cpp
mex bb_overlap.cpp
mex warp.cpp
mex distance.cpp
else
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
disp(lib);
% -O is default option for mex in Matlab
eval(['mex lk.cpp ' include lib]);
mex -c tld.cpp
mex fern.cpp tld.o
mex linkagemex.cpp
mex bb_overlap.cpp
mex warp.cpp
mex distance.cpp
end
end
cd ..
disp('Compilation finished.');