-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract_skeleton_data.m
147 lines (124 loc) · 4.51 KB
/
extract_skeleton_data.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
%USB-VID_045E&PID_02BF-0000000000000000_13
function BX=extract_skelton_data()
flag=1;
for i=1:531
%filename='H:\Adavus and postures\another1\export\USB-VID_045E&PID_02BF-0000000000000000_'
%filename='H:\Adavus and postures\good\export\export2\USB-VID_045E&PID_02BF-0000000000000000_'
%filename='H:\Adavus and postures\abhishek1\export\USB-VID_045E&PID_02BF-0000000000000000_';
filename='H:\Adavus and postures\abhishek1\export\USB-VID_045E&PID_02BF-0000000000000000_'
temp=num2str(i);
filename=strcat(filename,temp);
A=load(filename);
fprintf('filename : %s\n',filename);
%disp(filename);
for j=1:6
if strcmp(A.SkeletonFrame.Skeletons(j).TrackingState,'Tracked')==1
flag=0;
break;
end
end
if flag==0
break;
end
% if i==50
% [m n]=size(X);
% BX = zeros(m, n);
% f1=fopen('temp.txt','w');
% for j=1:m
% for k=1:n
% fprintf(f1,'%d,%d,%d\n',X(j,k),Y(j,k),Z(j,k));
% end
% end
%
% end
end
output_file=strcat('abhishek1.txt');
f1=fopen(output_file,'w');
for k=i:531
if k==14 | k==107 | k==167 | k==191
filename='H:\Adavus and postures\abhishek1\export\USB-VID_045E&PID_02BF-0000000000000000_'
temp=num2str(k);
filename=strcat(filename,temp);
A=load(filename);
for l=1:6
if strcmp(A.SkeletonFrame.Skeletons(l).TrackingState,'Tracked')==1
break;
end
end
calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% if k==122
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k==148
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k=203
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k==287
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k==340
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k==343
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
%
% if k==348
% calculate_ratios(A.SkeletonFrame.Skeletons(l),f1,k);
% end
% fclose(f1);
end
end
end
function calculate_ratios(A,f1,k)
%ratio1
x1=dist(A.Joints(5).Position,A.Joints(3).Position);
x2=dist(A.Joints(3).Position,A.Joints(9).Position);
l1=x1+x2; % length of two shoulder bones
x1=dist(A.Joints(3).Position,A.Joints(5).Position);
x2=dist(A.Joints(5).Position,A.Joints(6).Position);
x3=dist(A.Joints(6).Position,A.Joints(7).Position);
x4=dist(A.Joints(7).Position,A.Joints(8).Position);
l21=x1+x2+x3+x4 %left hand total length
x1=dist(A.Joints(3).Position,A.Joints(9).Position);
x2=dist(A.Joints(9).Position,A.Joints(10).Position);
x3=dist(A.Joints(10).Position,A.Joints(11).Position);
x4=dist(A.Joints(11).Position,A.Joints(12).Position);
l22=x1+x2+x3+x4 %lright hand total length
x1=dist(A.Joints(4).Position,A.Joints(3).Position);
x2=dist(A.Joints(3).Position,A.Joints(2).Position);
x3=dist(A.Joints(2).Position,A.Joints(1).Position);
x4=dist(A.Joints(1).Position,A.Joints(13).Position);
x5=dist(A.Joints(13).Position,A.Joints(14).Position);
x6=dist(A.Joints(14).Position,A.Joints(15).Position);
x7=dist(A.Joints(15).Position,A.Joints(16).Position);
l31=x1+x2+x3+x4+x5+x6+x7; %total body height
x1=dist(A.Joints(4).Position,A.Joints(3).Position);
x2=dist(A.Joints(3).Position,A.Joints(2).Position);
x3=dist(A.Joints(2).Position,A.Joints(1).Position);
x4=dist(A.Joints(1).Position,A.Joints(17).Position);
x5=dist(A.Joints(17).Position,A.Joints(18).Position);
x6=dist(A.Joints(18).Position,A.Joints(19).Position);
x7=dist(A.Joints(19).Position,A.Joints(20).Position);
l32=x1+x2+x3+x4+x5+x6+x7; %total body height
r1=l1/l31;
r2=l1/l32;
r3=l1/l21;
r4=l1/l22;
r5=l21/l31;
r6=l22/l32;
fprintf(f1,'%d %f %f %f %f %f %f \n',k,r1,r2,r3,r4,r5,r6);
end
function y=dist(A1,A2)
X1=(A1.X-A2.X)*(A1.X-A2.X);
Y1=(A1.Y-A2.Y)*(A1.Y-A2.Y);
Z1=(A1.Z-A2.Z)*(A1.Z-A2.Z);
y=sqrt(X1+Y1+Z1);
end