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
| fname = 'Example1.htr';
fid = fopen(fname,'rt');
str = fgetl(fid);
str = fgetl(fid);
while ~strncmp(str,'[SegmentNames&Hierarchy]',24)
[name,value] = strread(str,'%s%s%*s','commentstyle','shell');
if all(isstrprop(value{1},'digit'))
H.(name{1}) = str2double(value{1});
else
H.(name{1}) = value{1};
end
str = fgetl(fid);
end
str = fgetl(fid);
str = fgetl(fid);
n = 1;
while ~strncmp(str,'[BasePosition]',14)
[child(n),parent(n)] = strread(str,'%s%s');
n = n+1;
str = fgetl(fid);
end
str = fgetl(fid);
str = fgetl(fid);
while ~strncmp(str,'[',1)
[segmentname, Tx, Ty, Tz, Rx, Ry, Rz, BoneLength] = strread(str,'%s%f%f%f%f%f%f%f');
Segment.(segmentname{1}) = [Tx, Ty, Tz, Rx, Ry, Rz, BoneLength];
str = fgetl(fid);
end
fclose(fid);
X = textread(fname,'%s','delimiter','\n','commentstyle','shell');
f = fieldnames(Segment);
idx = find(strcmp(X,sprintf('[%s]',f{1})),1,'first')-1;
for n = 1:numel(f)
M{n} = str2num(char(X(((n-1)*(H.NumFrames+1)+2:n*(H.NumFrames+1))+idx)));
end |
Partager