-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprepare_data.m
68 lines (55 loc) · 1.51 KB
/
prepare_data.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
function [onedet, unaries, pairwise] = prepare_data(idx, params, data, dets)
savefile = 0;
if(ischar(idx))
idx = str2double(idx);
savefile = 1;
end
setpath;
try
load(fullfile(outpath, [num2str(idx, '%06d') '.mat']), 'idx', 'onedet', 'unaries', 'pairwise');
return;
catch
end
if nargin < 3
load(datafile);
end
if nargin < 4
load(detfile);
end
if nargin < 2
if is_train
params = learn_params(data, dets);
else
params = learn_params_test(data);
end
end
onedet = dets{idx};
clear dets;
if(~exist(outpath, 'dir'))
mkdir(outpath);
end
%% get the full boxes
if(isempty(onedet))
unaries = zeros(0, 3);
pairwise = zeros(0, 0);
else
rt = box2rect(onedet(:, 1:4));
onedet(:, 1:4) = onedet(:, 1:4) + (params.transform(onedet(:, 5), :) .* [rt(:, 3:4) rt(:, 3:4)]);
if(params.ver == 0.5) % not using... just complicated and not helping...
error('dont use');
unaries = compute_unaries2(onedet, params);
pairwise = compute_pairwise_match2(onedet, unaries, params);
else
unaries = compute_unaries(onedet, params);
pairwise = compute_pairwise_match_new(onedet, params);
end
end
if savefile
save(fullfile(outpath, [num2str(idx, '%06d') '.mat']), 'idx', 'onedet', 'unaries', 'pairwise');
end
if(0) % debugging
temp = load(fullfile(outpath, [num2str(idx, '%06d') '.mat']), 'idx', 'onedet', 'unaries', 'pairwise');
assert(all(temp.unaries(:) == unaries(:)));
assert(all(temp.pairwise(:) == pairwise(:)));
end
end