This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathworkspace_create.m
157 lines (113 loc) · 4.67 KB
/
workspace_create.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
function workspace_create(varargin)
% workspace_create Initialize a new VOT workspace
%
% This function serves as a guided initialization of a workspace. It generates
% all the basic scripts to run your tracker on an experiment stack based on a
% series of questions.
%
% Input:
% - varargin[Tracker] (boolean, string): Generate a new tracker, if boolean, the
% identifier of a tracker will be obtained interactively.
% - varargin[Stack] (string): Select a stack as an input.
%
tracker = [];
stack = [];
for j=1:2:length(varargin)
switch lower(varargin{j})
case 'tracker', tracker = varargin{j+1};
case 'stack', stack = varargin{j+1};
otherwise, error(['unrecognized argument ' varargin{j}]);
end
end
script_directory = fileparts(mfilename('fullpath'));
addpath(fileparts(script_directory));
toolkit_path; % Setup the full toolkit path just in case
set_global_variable('toolkit_path', fileparts(script_directory));
set_global_variable('indent', 0);
set_global_variable('directory', pwd());
stacks = {};
files = dir(fullfile(fileparts(script_directory), 'stacks'));
for i = 1:length(files)
if ~files(i).isdir && strxcmp(files(i).name, 'stack_', 'prefix') ...
&& strxcmp(files(i).name, '.m', 'suffix')
stacks{end+1} = files(i).name(7:end-2); %#ok<AGROW>
end;
end
directory = get_global_variable('directory');
if ~isascii(get_global_variable('toolkit_path'))
warning('Toolkit path contains non-ASCII characters. This may cause problems.')
end;
if ~isascii(directory)
warning('Workspace path contains non-ASCII characters. This may cause problems.')
end;
% Check if the directory is already a valid VOT workspace ...
configuration_file = fullfile(directory, 'configuration.m');
if exist(configuration_file, 'file')
error('Directory is probably already a VOT workspace.');
end;
% Copy configuration templates ...
templates_directory = fullfile(script_directory, 'templates');
version = toolkit_version();
if isempty(stack)
print_text('Select one of the available experiment stacks:');
for i = 1:length(stacks)
print_text(' %d - %s', i, stacks{i});
end;
option = input('Selection: ', 's');
option = int32(str2double(option));
if isempty(option) || option < 1 || option > length(stacks)
error('Not a valid stack!');
end;
selected_stack = stacks{option};
else
selected_stack = stack;
if isempty(selected_stack)
error('Not a valid stack!');
end;
end
if isempty(tracker)
tracker = true;
end;
if islogical(tracker)
tracker_identifier = input('Input an unique identifier for your tracker: ', 's');
else
tracker_identifier = tracker;
tracker = true;
end
if ~valid_identifier(tracker_identifier)
error('Not a valid tracker identifier!');
end;
if tracker
tracker_create('identifier', tracker_identifier, 'directory', directory);
end;
variables = {'version', num2str(version.major), ...
'tracker', tracker_identifier, 'stack', selected_stack, ...
'toolkit', get_global_variable('toolkit_path')};
generate_from_template(fullfile(directory, 'configuration.m'), ...
fullfile(templates_directory, 'configuration.tpl'), variables{:});
generate_from_template(fullfile(directory, 'run_experiments.m'), ...
fullfile(templates_directory, 'run_experiments.tpl'), variables{:});
generate_from_template(fullfile(directory, 'run_test.m'), ...
fullfile(templates_directory, 'run_test.tpl'), variables{:});
generate_from_template(fullfile(directory, 'run_pack.m'), ...
fullfile(templates_directory, 'run_pack.tpl'), variables{:});
generate_from_template(fullfile(directory, 'run_browse.m'), ...
fullfile(templates_directory, 'run_browse.tpl'), variables{:});
generate_from_template(fullfile(directory, 'run_analysis.m'), ...
fullfile(templates_directory, 'run_analysis.tpl'), variables{:});
set_global_variable('native_path', fullfile(get_global_variable('toolkit_path'), 'native'));
mkpath(get_global_variable('native_path'));
rmpath(get_global_variable('native_path')); rehash; % Try to avoid locked files on Windows
initialize_native();
addpath(get_global_variable('native_path'));
% Print further instructions ...
print_text('');
print_text('***************************************************************************');
print_text('');
print_text('The VOT workspace has been configured');
print_text('Please edit the tracker_%s.m file to configure your tracker.', tracker_identifier);
print_text('Then run run_test.m script to make sure that the tracker is working.');
print_text('To run the experiments execute the run_experiments.m script.');
print_text('');
print_text('***************************************************************************');
print_text('');