-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathload_skeleton.m
88 lines (75 loc) · 2.75 KB
/
load_skeleton.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
function [ posMat, posConf, oriMat, oriConf ] = load_skeleton( filename )
%load_skeleton parses a skeleton file
% posMat: (frame,user,joint,idx)
% vectors of 3D joint positions (x,y,z)
% posConf: (frame,user,joint)
% joint position confidence levels
% oriMat: (frame,user,joint,idx1,idx2)
% 3x3 matrices of joint orientations
% oriConf: (frame,user,joint)
% joint orientation confidence levels
%
% Included in the dataset:
% http://www.cs.ucf.edu/~smasood/datasets/UCFKinect.zip
fid = fopen(filename);
line = fgetl(fid);
while ischar(line)
% parse frame title and index
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
frame = str2num(tmp)+1;
% parse numUsers title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
numUsers = str2num(tmp);
% step through each user
for user = 1:numUsers
% parse userID title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
userID = str2num(tmp);
% parse numJoints title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
numJoints = str2num(tmp);
% step through each joint
for joint = 1:numJoints
% parse joint title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
% this line preserves the joint IDs from OpenNI
%jointID = str2num(tmp);
% ---or---
% this line renumbers the joint IDs for ease of array manipulation
jointID = joint;
% parse orientation confidence title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
oconf = str2num(tmp);
oriConf(frame,userID,jointID) = oconf;
% parse orientation title and value
[t,line] = strtok(line,'|');
ori = zeros(3);
for o = 1:9
[tmp,line] = strtok(line,'|');
ori(o) = str2num(tmp);
end
oriMat(frame,userID,jointID,:,:) = ori;
% parse position confidence title and value
[t,line] = strtok(line,'|');
[tmp,line] = strtok(line,'|');
pconf = str2num(tmp);
posConf(frame,userID,jointID) = pconf;
% parse position title and value
[t,line] = strtok(line,'|');
pos = zeros(1,3);
for p = 1:3
[tmp,line] = strtok(line,'|');
pos(p) = str2num(tmp);
end
posMat(frame,userID,jointID,:) = pos;
end
end
line = fgetl(fid);
end
fclose(fid);