-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathINSTALL_VTrails.m
372 lines (331 loc) · 15.1 KB
/
INSTALL_VTrails.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
function INSTALL_VTrails()%
%
% INSTALL VTrails Toolkit in Matlab from the command shell:
%
% >> INSTALL_VTrails
%
% This function defines first the VTrailsToolkitRoot directory and
% dependencies for the execution of other functions. Then it will compile
% and install all the necessary libraries and mex-files.
%
% [Tested on Matlab R2016b]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Stefano Moriconi, July-2017, vtrailstoolkit@gmail.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
VTrailsToolkitRootDir = pwd;
if exist(VTrailsToolkitRootDir,'dir')
VTrailsToolkitRootDir = strcat(VTrailsToolkitRootDir,'/');
[exportSuccess,ME1] = exportVTrailsToolkitRootDir(VTrailsToolkitRootDir);
[installSuccess,ME2] = installVTrailsComponents(VTrailsToolkitRootDir);
if exportSuccess && installSuccess
disp('**************************************************************');
disp(' VTrails Toolkit Succesfully Installed! ');
disp('**************************************************************');
else
fprintf(2,'\nVTrails Toolkit has NOT been correctly installed.\nPlease Check the Exceptions (ErrorLog.mat) and\nRe-run the installer prior to using the Tooltik.\n');
exportErrorLog(VTrailsToolkitRootDir,cat(2,ME1,ME2));
end
else
fprintf(2,'\nVTrails Toolkit has NOT been installed.\nPlease Re-run the installer prior to using the Tooltik.');
end
function [exportSuccess,ME] = exportVTrailsToolkitRootDir(VTrailsToolkitRootDir)
ME = struct([]);
try
disp('--------------------------------------------------------------');
disp('Step: 0.0 - Exporting: VTRootDir: ...');
FID = fopen( strcat(VTrailsToolkitRootDir,'main/VTRootDir.m') , 'w' );
templateTXT = ['function VTrdir = VTRootDir() \n%%',...
'%% This function returns the VTrails Toolkit Root Directory\n\n',...
'VTrdir = %s; \n\n'];
VTRootDir = sprintf('%s%s%s',sprintf( '\''' ),VTrailsToolkitRootDir,sprintf( '\''' ));
fprintf(FID,templateTXT,VTRootDir);
fclose(FID);
exportSuccess = true;
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch ME
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
exportSuccess = false;
end
function [installSuccess,ME] = installVTrailsComponents(VTrailsToolkitRootDir)
%% Compiling Filtering Mex-files
installSuccess = true;
ME = struct([]);
% Step: 1.1
try
disp('Step: 1.1 - Compiling: VTF3D_computeGradients2ndOrd: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/VTF3D_computeGradients2ndOrd.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 1.2
try
disp('Step: 1.2 - Compiling: VTF3D_configTFSynthesis: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/VTF3D_configTFSynthesis.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 1.3
try
disp('Step: 1.3 - Compiling: VTF3D_eigenDecompBlock3D: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/VTF3D_eigenDecompBlock3D.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 1.4
try
disp('Step: 1.4 - Compiling: VTF3D_synthTF: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/VTF3D_synthTF.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 1.5
try
disp('Step: 1.5 - Installing: VTF3D_*: ...');
movefile( strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/*mex*') , strcat(VTrailsToolkitRootDir,'libs/') );
rmdir( strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/codegen/') , 's' );
delete( strcat(VTrailsToolkitRootDir,'libs/1_ImageFilter_MEXCompiler/gcGuiReport.mat') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
%% Compiling Connectivity Mex-files:
% Step: 2.1
try
disp('Step: 2.1 - Compiling: mxAnisoDistanceTransform4Graph: ...');
mex( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/mxAnisoDistanceTransform4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/AnisotropicFastMarching4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/UpdateNeighborhood4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/Auxillary4Graph.cpp'), ...
'-outdir', strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/') ) ;
fprintf('\nDONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
try
mex( '-DMX_COMPACT_32' ,...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/mxAnisoDistanceTransform4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/AnisotropicFastMarching4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/UpdateNeighborhood4Graph.cpp'), ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/Auxillary4Graph.cpp'), ...
'-outdir', strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/') ) ;
fprintf('\nDONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
MATLABversion = version('-release');
if str2num(MATLABversion(1:end-1)) > 2016
fprintf(2,'See: /libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/README\n');
end
disp('--------------------------------------------------------------');
installSuccess = false;
end
end
% Step: 2.2
try
disp('Step: 2.2 - Installing: mxAnisoDistanceTransform4Graph: ...');
movefile( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/AnisotropicFastMarching4Graph/*mex*') , strcat(VTrailsToolkitRootDir,'libs/') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.3
try
disp('Step: 2.3 - Compiling: gradient3Dcpp: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Gradient3D/gradient3Dcpp.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.4
try
disp('Step: 2.4 - Installing: gradient3Dcpp: ...');
movefile( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Gradient3D/*mex*') , strcat(VTrailsToolkitRootDir,'libs/') );
rmdir( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Gradient3D/codegen/') , 's' );
delete( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Gradient3D/gcGuiReport.mat') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.5
try
disp('Step: 2.5 - Extracting: boost_1_49_0.zip: ...');
system( ['zip -s0 ',...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0_split.zip'),...
' --out ',...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0.zip'),...
' -q'] );
unzip( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0.zip') , ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.6
try
disp('Step: 2.6 - Extracting: rncarpio-linterp-ca556a0.zip: ...');
unzip( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/rncarpio-linterp-ca556a0.zip') , ...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.7
try
disp('Step: 2.7 - Compiling: linterp_matlab: ...');
mex( strcat('-I',VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0/'),...
strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/rncarpio-linterp-ca556a0/src/linterp_matlab.cpp'),...
'-outdir', strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/rncarpio-linterp-ca556a0/src/') );
fprintf('\nDONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 2.8
try
disp('Step: 2.8 - Installing: linterp_matlab: ...');
movefile( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/rncarpio-linterp-ca556a0/src/linterp_matlab.mex*') , strcat(VTrailsToolkitRootDir,'libs/') );
delete( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0.zip') );
rmdir( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/boost_1_49_0/') , 's' );
rmdir( strcat(VTrailsToolkitRootDir,'libs/2_GeodesicConnect_MEXCompiler/Linterp/rncarpio-linterp-ca556a0/') , 's' );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
%% Compiling Tree-Extraction and Refinement Mex-files:
% Step: 3.1
try
disp('Step: 3.1 - Compiling: VTR3D_getPairs2BeEvaluated: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/VTR3D_getPairs2BeEvaluated.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 3.2
try
disp('Step: 3.2 - Compiling: VTR3D_notUnique: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/VTR3D_notUnique.prj') );
fprintf([repmat('\b',[1,195]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 3.3
try
disp('Step: 3.3 - Compiling: VTR3D_repeatedValue: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/VTR3D_repeatedValue.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 3.4
try
disp('Step: 3.4 - Compiling: VTR3D_repeatedValueSymm: ...');
coder('-build', strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/VTR3D_repeatedValueSymm.prj') );
fprintf([repmat('\b',[1,45]),' DONE!\n']);
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
% Step: 3.5
try
disp('Step: 3.5 - Installing: VTR3D*: ...');
movefile( strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/*mex*') , strcat(VTrailsToolkitRootDir,'libs/') );
rmdir( strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/codegen/') , 's' );
delete( strcat(VTrailsToolkitRootDir,'libs/3_RefineTree_MEXCompiler/gcGuiReport.mat') );
fprintf('\b\b\b\b DONE!\n');
disp('--------------------------------------------------------------');
catch me
ME = cat(2,ME,me);
fprintf('\b\b\b\b');
fprintf(2,'FAILED!\n');
disp('--------------------------------------------------------------');
installSuccess = false;
end
function exportErrorLog(VTrailsToolkitRootDir,MExcept)
save( strcat(VTrailsToolkitRootDir,'VTrails_Install_ErrorLog.mat') , 'MExcept' , '-v7.3' );