-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_annotation.m
76 lines (59 loc) · 1.59 KB
/
parse_annotation.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
function [ entries ] = parse_annotation( annotation, nframes, ratio )
% PARSE_ANNOTATION Parses an annotation like the ones we made for the cmu
% dataset.
%
% Input
% Annotation : String. Something like 'all', '1-17' or '2- 16, 90 - 120'.
% nframes : Integer. The number of frames in the mocap sequences.
% ratio : Float. Annotation framerate / mocap framerate.
% Output
%
% --
% Julieta
if nargin < 3,
ratio = 0.8;
end
% Define the output.
entries = {};
if isempty( annotation ),
return;
end
% Trim the annotation.
annotation = strtrim( annotation );
% See if it is emptyummary of this function goes here
% Detailed explanation goes here after trimming.
if isempty( annotation ),
return;
end
if strcmp( annotation, 'all'),
entries{1} = [ 2, nframes ];
return;
end
% Separate by commas.
if exist('strsplit', 'file'),
xx = strsplit( annotation, ',');
else
% For older matlab < 2013.
xx = strread( annotation, '%s', 'delimiter', ',');
end
for i = 1:numel(xx),
% Trim the ith entry.
trimmed_entry = strtrim( xx{i} );
% Parse the 2 numbers.
if exist('strsplit', 'file'), % for newer matlab > 2013
yy = strsplit( trimmed_entry, '-');
else
% For older matlab < 2013.
yy = strread( trimmed_entry, '%s', 'delimiter', '-');
end
bg = floor( str2double( strtrim( yy{1} ) ) * ratio);
if bg == 0
bg = 1;
end
nd = floor( str2double( strtrim( yy{2} ) ) * ratio);
if bg >= nd,
error('The annotion is wrong.');
end
entries{ end+1 } = [bg, nd];
end
end