forked from xiaodongyang/SNV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compVidDesc.m
65 lines (49 loc) · 2.26 KB
/
compVidDesc.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
function compVidDesc(info, scheme)
basisName = [scheme.code, '_', num2str(scheme.ncenters), '_', ...
num2str(scheme.lx), num2str(scheme.ly), num2str(scheme.lt), '.mat'];
load(basisName, 'basis');
for i = 1:info.ncls
idxcls = sprintf('a%02d', i);
for j = 1:info.nsbj
idxsbj = sprintf('s%02d', j);
for k = 1:info.nemp
idxemp = sprintf('e%02d', k);
disp(['computing video descriptor: ', idxcls, '_', idxsbj, '_', idxemp, ' ......']);
% read normals and masks
normalName = [info.normpath, '\', idxcls, '_', idxsbj, '_', idxemp, '_norm.mat'];
% some missed videos
if ~exist(normalName, 'file')
continue;
end
load(normalName, 'dx', 'dy', 'dt', 'masks');
[pns, rows, cols, frms] = getPolyNormals(dx, dy, dt, scheme.lx, scheme.ly, scheme.lt);
clear dx dy dt;
% remove all-zero polynormals
flag = sum(pns ~= 0, 2);
pns(~flag, :) = [];
rows(~flag) = []; cols(~flag) = []; frms(~flag) = [];
locs.rows = rows; locs.cols = cols; locs.frms = frms;
clear rows cols frms;
% whitening
if strcmp(scheme.code, 'SC')
pns = pns';
pns = pns - repmat(mean(pns), size(pns, 1), 1); % zero-mean
pns = pns ./ (repmat(sqrt(sum(pns.^2)), size(pns, 1), 1) + eps); % unit-variance
pns = pns';
end
% coding polynormals
codes = codePolyNormals(scheme, pns, basis);
% determine the max bounding box of action region
bb = getBoundBox(masks);
% load motion energy
energyName = [info.enerpath, '\', idxcls, '_', idxsbj, '_', idxemp, '_ener.mat'];
load(energyName, 'hist');
% pooling polynormals
desc = poolPolyNormals(scheme, pns, locs, basis, codes, bb, hist);
% save
descName = [info.descpath, '\', idxcls, '_', idxsbj, '_', idxemp, '_desc.mat'];
save(descName, 'desc');
end
end
end
end