-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadKinectData.m
78 lines (57 loc) · 1.73 KB
/
loadKinectData.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
%{
i=0: NUI_SKELETON_POSITION_HIP_
CENTER
i=1: NUI_SKELETON_POSITION_SPINE
i=2: NUI_SKELETON_POSITION_SHOULDER_CENTER
i=3: NUI_SKELETON_POSITION_HEAD
i=4: NUI_SKELETON_POSITION_SHOULDER_LEFT
i=5: NUI_SKELETON_POSITION_ELBOW_LEFT
i=6: NUI_SKELETON_POSITION_WRIST_LEFT
i=7: NUI_SKELETON_POSITION_HAND_LEFT
i=8: NUI_SKELETON_POSITION_SHOULDER_RIGHT
i=9: NUI_SKELETON_POSITION_ELBOW_RIGHT
i=10: NUI_SKELETON_POSITION_WRIST_RIGHT
i=11: NUI_SKELETON_POSITION_HAND_RIGHT
i=12: NUI_SKELETON_POSITION_HIP_LEFT
i=13: NUI_SKELETON_POSITION_KNEE_LEFT
i=14: NUI_SKELETON_POSITION_ANKLE_LEFT
i=15: NUI_SKELETON_POSITION_FOOT_LEFT
i=16: NUI_SKELETON_POSITION_HIP_RIGHT
i=17: NUI_SKELETON_POSITION_KNEE_RIGHT
i=18: NUI_SKELETON_POSITION_ANKLE_RIGHT
i=19: NUI_SKELETON_POSITION_FOOT_RIGHT
Remember matlab index start at 1.
Joint needed = (i+1)*4 // For z value of left hand
%}
%
function [finalM] =loadKinectData(root_folder, flag)
d = dir([root_folder, 'kin*.txt']);
col = zeros(60,1);
finalM = [];
for j = 1:length(d)
ifp1 = fopen([root_folder,d(j).name],'r');
while 1
%Read whole file into s
s= fgets(ifp1);
if s == -1
break;
end
%Each a is 80 data points: Inferred,x,y,z,
a = sscanf(s(find(s == ' ') + 1:end),'%f');
%cla
cnt = 1;
for i=1:4:length(a)
col(cnt:cnt + 2) = a(i+1:i+3);
cnt = cnt + 3;
end
% if flag normalise for hip centroid
if flag == 1
cog = col(1:3);
for i=1:3:60
col(i:i+2) = col(i:i+2) - cog;
end
end
finalM = [finalM, col];
end
fclose(ifp1);
end