-
-
Save avisingh599/73ac41db59d87115c99e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
label=1; | |
testr=1; | |
trainr=1; | |
trainsequence=cell(1,48); | |
trainlabel=ones(1,48); | |
testsequence=cell(1,12); | |
testlabel=ones(1,12); | |
for j=[1 4 7 8 10 15] %% Set the Activity Number which you want to extract | |
if(j==13||j==14) | |
continue; | |
end | |
for i= [1 2 3 4 5 6 7 8 9 10] %% Set the Person Number for whom you want to extaract data | |
for k=[1] %% Set which sequence of the activity you want to extract | |
if(j<=9) | |
if(i<=9) | |
a=strcat('a0',int2str(j),'_s0',int2str(i),'_e0',int2str(k),'_skeleton.txt'); | |
else | |
a=strcat('a0',int2str(j),'_s10','_e0',int2str(k),'_skeleton.txt'); | |
end | |
else | |
if(i<=9) | |
a=strcat('a',int2str(j),'_s0',int2str(i),'_e0',int2str(k),'_skeleton.txt'); | |
else | |
a=strcat('a',int2str(j),'_s10','_e0',int2str(k),'_skeleton.txt'); | |
end | |
end | |
b=dlmread(a); | |
frames=b(1,1); | |
data=ones(20*3,frames); | |
start_index=3; | |
torso_initial=b(3,[1 2 3]); | |
torso_initial = ones(20,1)*(torso_initial); | |
crr_frame=0; | |
crr_data=ones(20,3); | |
bone_vectors=ones(19,3); | |
final_position=ones(20,3); | |
while(crr_frame<frames) | |
crr_data=b(start_index:2:start_index+38,[1,2,3]); | |
relative_position = crr_data - torso_initial; | |
rearranged_position = relative_position([1 1 2 3 3 5 6 7 3 9 10 11 1 13 14 15 1 17 18 19],:); | |
bone_vectors = relative_position(2:20,:) - rearranged_position(2:20,:); | |
segment_length = sqrt((sum((bone_vectors.*bone_vectors)'))'); | |
factor=(1./segment_length).*([.05;.21;.12;.13;.186;.146;.054;.13;.186;.146;.054;.1;.245;.246;.08;.1;.245;.246;.08]); | |
factor2 = [factor,factor,factor]; | |
scaled_bone_vector = bone_vectors.*factor2; | |
final_position(1,:)=relative_position(1,:); | |
final_position(2,:)=final_position(1,:)+scaled_bone_vector(1,:); | |
final_position(3,:)=final_position(2,:)+scaled_bone_vector(2,:); | |
final_position(4,:)=final_position(3,:)+scaled_bone_vector(3,:); | |
final_position(5,:)=final_position(3,:)+scaled_bone_vector(4,:); | |
final_position(6,:)=final_position(5,:)+scaled_bone_vector(5,:); | |
final_position(7,:)=final_position(6,:)+scaled_bone_vector(6,:); | |
final_position(8,:)=final_position(7,:)+scaled_bone_vector(7,:); | |
final_position(9,:)=final_position(3,:)+scaled_bone_vector(8,:); | |
final_position(10,:)=final_position(9,:)+scaled_bone_vector(9,:); | |
final_position(11,:)=final_position(10,:)+scaled_bone_vector(10,:); | |
final_position(12,:)=final_position(11,:)+scaled_bone_vector(11,:); | |
final_position(13,:)=final_position(1,:)+scaled_bone_vector(12,:); | |
final_position(14,:)=final_position(13,:)+scaled_bone_vector(13,:); | |
final_position(15,:)=final_position(14,:)+scaled_bone_vector(14,:); | |
final_position(16,:)=final_position(15,:)+scaled_bone_vector(15,:); | |
final_position(17,:)=final_position(1,:)+scaled_bone_vector(16,:); | |
final_position(18,:)=final_position(17,:)+scaled_bone_vector(17,:); | |
final_position(19,:)=final_position(18,:)+scaled_bone_vector(18,:); | |
final_position(20,:)=final_position(19,:)+scaled_bone_vector(19,:); | |
data(:,crr_frame+1)=final_position(:); | |
crr_frame=crr_frame+1; | |
start_index=start_index+41; | |
end | |
new_data=ones(120,frames); | |
new_data(1:60,:)=data; | |
new_data(61:120,1)=zeros(60,1); | |
new_data(61:120,2:frames)=data(:,2:frames)-data(:,1:frames-1); | |
%if(j<=12) | |
% label=j-1; | |
%else | |
% label=j-3; | |
%end | |
switch(j) | |
case 1 | |
label=0; | |
% break; | |
case 4 | |
label=1; | |
% break; | |
case 7 | |
label=2; | |
% break; | |
case 8 | |
label=3; | |
% break; | |
case 10 | |
label=4; | |
%break; | |
case 15 | |
label=5; | |
end | |
% disp('this is alright'); | |
if(i>=3) %% Set the Person Number you want to put in the train sequence | |
trainsequence{1,trainr}=new_data; | |
trainlabel(1,trainr)=label; | |
trainr=trainr+1; | |
else %% Rest all person are put in the test sequence | |
testsequence{1,testr}=new_data; | |
testlabel(1,testr)=label; | |
testr=testr+1; | |
end | |
% save(strcat('a02_s10_e01_skeleton_data'),'data'); | |
% save(strcat('a02_s0',int2str(i),'_e02_skeleton_data'),'data'); | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment