JeungEunLee

motionpatches : orientation/tall nomalized with median value

No preview for this file type
function bodyinfo = read_skeleton_file(filename)
% Reads an .skeleton file from "NTU RGB+D 3D Action Recognition Dataset".
%
% Argrument:
% filename: full adress and filename of the .skeleton file.
%
% For further information please refer to:
% NTU RGB+D dataset's webpage:
% http://rose1.ntu.edu.sg/Datasets/actionRecognition.asp
% NTU RGB+D dataset's github page:
% https://github.com/shahroudy/NTURGB-D
% CVPR 2016 paper:
% Amir Shahroudy, Jun Liu, Tian-Tsong Ng, and Gang Wang,
% "NTU RGB+D: A Large Scale Dataset for 3D Human Activity Analysis",
% in IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016
%
% For more details about the provided data, please refer to:
% https://msdn.microsoft.com/en-us/library/dn799271.aspx
% https://msdn.microsoft.com/en-us/library/dn782037.aspx
fileid = fopen(filename);
framecount = fscanf(fileid,'%d',1); % no of the recorded frames
bodyinfo=[]; % to store multiple skeletons per frame
for f=1:framecount
bodycount = fscanf(fileid,'%d',1); % no of observerd skeletons in current frame
for b=1:bodycount
clear body;
body.bodyID = fscanf(fileid,'%ld',1); % tracking id of the skeleton
arrayint = fscanf(fileid,'%d',6); % read 6 integers
body.clipedEdges = arrayint(1);
body.handLeftConfidence = arrayint(2);
body.handLeftState = arrayint(3);
body.handRightConfidence = arrayint(4);
body.handRightState = arrayint(5);
body.isResticted = arrayint(6);
lean = fscanf(fileid,'%f',2);
body.leanX = lean(1);
body.leanY = lean(2);
body.trackingState = fscanf(fileid,'%d',1);
body.jointCount = fscanf(fileid,'%d',1); % no of joints (25)
joints=[];
for j=1:body.jointCount
jointinfo = fscanf(fileid,'%f',11);
joint=[];
% 3D location of the joint j
joint.x = jointinfo(1);
joint.y = jointinfo(2);
joint.z = jointinfo(3);
% 2D location of the joint j in corresponding depth/IR frame
joint.depthX = jointinfo(4);
joint.depthY = jointinfo(5);
% 2D location of the joint j in corresponding RGB frame
joint.colorX = jointinfo(6);
joint.colorY = jointinfo(7);
% The orientation of the joint j
joint.orientationW = jointinfo(8);
joint.orientationX = jointinfo(9);
joint.orientationY = jointinfo(10);
joint.orientationZ = jointinfo(11);
% The tracking state of the joint j
joint.trackingState = fscanf(fileid,'%d',1);
body.joints(j)=joint;
end
bodyinfo(f).bodies(b)=body;
end
end
fclose(fileid);
end
\ No newline at end of file
S001C002P005R002A008
S001C002P006R001A008
S001C003P002R001A055
S001C003P002R002A012
S001C003P005R002A004
S001C003P005R002A005
S001C003P005R002A006
S001C003P006R002A008
S002C002P011R002A030
S002C003P008R001A020
S002C003P010R002A010
S002C003P011R002A007
S002C003P011R002A011
S002C003P014R002A007
S003C001P019R001A055
S003C002P002R002A055
S003C002P018R002A055
S003C003P002R001A055
S003C003P016R001A055
S003C003P018R002A024
S004C002P003R001A013
S004C002P008R001A009
S004C002P020R001A003
S004C002P020R001A004
S004C002P020R001A012
S004C002P020R001A020
S004C002P020R001A021
S004C002P020R001A036
S005C002P004R001A001
S005C002P004R001A003
S005C002P010R001A016
S005C002P010R001A017
S005C002P010R001A048
S005C002P010R001A049
S005C002P016R001A009
S005C002P016R001A010
S005C002P018R001A003
S005C002P018R001A028
S005C002P018R001A029
S005C003P016R002A009
S005C003P018R002A013
S005C003P021R002A057
S006C001P001R002A055
S006C002P007R001A005
S006C002P007R001A006
S006C002P016R001A043
S006C002P016R001A051
S006C002P016R001A052
S006C002P022R001A012
S006C002P023R001A020
S006C002P023R001A021
S006C002P023R001A022
S006C002P023R001A023
S006C002P024R001A018
S006C002P024R001A019
S006C003P001R002A013
S006C003P007R002A009
S006C003P007R002A010
S006C003P007R002A025
S006C003P016R001A060
S006C003P017R001A055
S006C003P017R002A013
S006C003P017R002A014
S006C003P017R002A015
S006C003P022R002A013
S007C001P018R002A050
S007C001P025R002A051
S007C001P028R001A050
S007C001P028R001A051
S007C001P028R001A052
S007C002P008R002A008
S007C002P015R002A055
S007C002P026R001A008
S007C002P026R001A009
S007C002P026R001A010
S007C002P026R001A011
S007C002P026R001A012
S007C002P026R001A050
S007C002P027R001A011
S007C002P027R001A013
S007C002P028R002A055
S007C003P007R001A002
S007C003P007R001A004
S007C003P019R001A060
S007C003P027R002A001
S007C003P027R002A002
S007C003P027R002A003
S007C003P027R002A004
S007C003P027R002A005
S007C003P027R002A006
S007C003P027R002A007
S007C003P027R002A008
S007C003P027R002A009
S007C003P027R002A010
S007C003P027R002A011
S007C003P027R002A012
S007C003P027R002A013
S008C002P001R001A009
S008C002P001R001A010
S008C002P001R001A014
S008C002P001R001A015
S008C002P001R001A016
S008C002P001R001A018
S008C002P001R001A019
S008C002P008R002A059
S008C002P025R001A060
S008C002P029R001A004
S008C002P031R001A005
S008C002P031R001A006
S008C002P032R001A018
S008C002P034R001A018
S008C002P034R001A019
S008C002P035R001A059
S008C002P035R002A002
S008C002P035R002A005
S008C003P007R001A009
S008C003P007R001A016
S008C003P007R001A017
S008C003P007R001A018
S008C003P007R001A019
S008C003P007R001A020
S008C003P007R001A021
S008C003P007R001A022
S008C003P007R001A023
S008C003P007R001A025
S008C003P007R001A026
S008C003P007R001A028
S008C003P007R001A029
S008C003P007R002A003
S008C003P008R002A050
S008C003P025R002A002
S008C003P025R002A011
S008C003P025R002A012
S008C003P025R002A016
S008C003P025R002A020
S008C003P025R002A022
S008C003P025R002A023
S008C003P025R002A030
S008C003P025R002A031
S008C003P025R002A032
S008C003P025R002A033
S008C003P025R002A049
S008C003P025R002A060
S008C003P031R001A001
S008C003P031R002A004
S008C003P031R002A014
S008C003P031R002A015
S008C003P031R002A016
S008C003P031R002A017
S008C003P032R002A013
S008C003P033R002A001
S008C003P033R002A011
S008C003P033R002A012
S008C003P034R002A001
S008C003P034R002A012
S008C003P034R002A022
S008C003P034R002A023
S008C003P034R002A024
S008C003P034R002A044
S008C003P034R002A045
S008C003P035R002A016
S008C003P035R002A017
S008C003P035R002A018
S008C003P035R002A019
S008C003P035R002A020
S008C003P035R002A021
S009C002P007R001A001
S009C002P007R001A003
S009C002P007R001A014
S009C002P008R001A014
S009C002P015R002A050
S009C002P016R001A002
S009C002P017R001A028
S009C002P017R001A029
S009C003P017R002A030
S009C003P025R002A054
S010C001P007R002A020
S010C002P016R002A055
S010C002P017R001A005
S010C002P017R001A018
S010C002P017R001A019
S010C002P019R001A001
S010C002P025R001A012
S010C003P007R002A043
S010C003P008R002A003
S010C003P016R001A055
S010C003P017R002A055
S011C001P002R001A008
S011C001P018R002A050
S011C002P008R002A059
S011C002P016R002A055
S011C002P017R001A020
S011C002P017R001A021
S011C002P018R002A055
S011C002P027R001A009
S011C002P027R001A010
S011C002P027R001A037
S011C003P001R001A055
S011C003P002R001A055
S011C003P008R002A012
S011C003P015R001A055
S011C003P016R001A055
S011C003P019R001A055
S011C003P025R001A055
S011C003P028R002A055
S012C001P019R001A060
S012C001P019R002A060
S012C002P015R001A055
S012C002P017R002A012
S012C002P025R001A060
S012C003P008R001A057
S012C003P015R001A055
S012C003P015R002A055
S012C003P016R001A055
S012C003P017R002A055
S012C003P018R001A055
S012C003P018R001A057
S012C003P019R002A011
S012C003P019R002A012
S012C003P025R001A055
S012C003P027R001A055
S012C003P027R002A009
S012C003P028R001A035
S012C003P028R002A055
S013C001P015R001A054
S013C001P017R002A054
S013C001P018R001A016
S013C001P028R001A040
S013C002P015R001A054
S013C002P017R002A054
S013C002P028R001A040
S013C003P008R002A059
S013C003P015R001A054
S013C003P017R002A054
S013C003P025R002A022
S013C003P027R001A055
S013C003P028R001A040
S014C001P027R002A040
S014C002P015R001A003
S014C002P019R001A029
S014C002P025R002A059
S014C002P027R002A040
S014C002P039R001A050
S014C003P007R002A059
S014C003P015R002A055
S014C003P019R002A055
S014C003P025R001A048
S014C003P027R002A040
S015C001P008R002A040
S015C001P016R001A055
S015C001P017R001A055
S015C001P017R002A055
S015C002P007R001A059
S015C002P008R001A003
S015C002P008R001A004
S015C002P008R002A040
S015C002P015R001A002
S015C002P016R001A001
S015C002P016R002A055
S015C003P008R002A007
S015C003P008R002A011
S015C003P008R002A012
S015C003P008R002A028
S015C003P008R002A040
S015C003P025R002A012
S015C003P025R002A017
S015C003P025R002A020
S015C003P025R002A021
S015C003P025R002A030
S015C003P025R002A033
S015C003P025R002A034
S015C003P025R002A036
S015C003P025R002A037
S015C003P025R002A044
S016C001P019R002A040
S016C001P025R001A011
S016C001P025R001A012
S016C001P025R001A060
S016C001P040R001A055
S016C001P040R002A055
S016C002P008R001A011
S016C002P019R002A040
S016C002P025R002A012
S016C003P008R001A011
S016C003P008R002A002
S016C003P008R002A003
S016C003P008R002A004
S016C003P008R002A006
S016C003P008R002A009
S016C003P019R002A040
S016C003P039R002A016
S017C001P016R002A031
S017C002P007R001A013
S017C002P008R001A009
S017C002P015R001A042
S017C002P016R002A031
S017C002P016R002A055
S017C003P007R002A013
S017C003P008R001A059
S017C003P016R002A031
S017C003P017R001A055
S017C003P020R001A059
\ No newline at end of file
%your motion_patch location
ori = imread('/home/rfj/바탕화면/actionGAN/motion_patch/S001C001P001R001A020.png');
ori = im2double(ori);
ori = ori(:,:,:);
dx = [];
dy = [];
dz = [];
for f = 1:numel(ori(:,1,1))
for j = 1:25
dx = [dx;ori(f,j,1)];
dy = [dy;ori(f,j,2)];
dz = [dz;ori(f,j,3)];
end
end
a = [1 0 0]; % Red 척추 1,2,3,4,20
b = [0 0 1]; % Blue 오른팔 8,9,10,11,23,24
c = [0 1 0]; % Green왼팔 5,6,7,21,22 (여기서 5번이 빠짐. 넣고싶으면 나중에 24 joint가 아니라 25 joint로 추가)
d = [1 1 0]; % Yellow 오른다리 16,17,18,19
e = [0 1 1]; % Skyblue 왼다리 12,13,14,15
colors = [a;a;a;a;c;c;c;c;b;b;b;b;e;e;e;e;d;d;d;d;a;c;c;b;b];
scatter3(dx,dy,dz,100,'filled');
connecting_joints= ...
[2 1 21 3 21 5 6 7 21 9 10 11 1 13 14 15 1 17 18 19 2 8 8 12 12];
for jj=1:25:numel(dx)% 1부터 8개씩 numel = 열갯수..?
current = [];
current(:,1) = dy(jj:jj+24) ;
current(:,2) = dz(jj:jj+24) ;
current(:,3) = dx(jj:jj+24) ;
scatter3(current(:,1),current(:,2),current(:,3),100,colors(:,:),'filled');
for j =1:25
k=connecting_joints(j);
line([current(j,1) current(k,1)], [current(j,2) current(k,2)] , [current(j,3) current(k,3)])
end
set(gca,'Xdir','reverse','Ydir','reverse')
xlim([0 1]);
xlabel('x')
ylim([0 1]);
ylabel('y')
zlim([0 1]);
zlabel('z')
drawnow
pause(0.01)
end
% 맨처음 방향 (frame1) 으로 일괄 orientation normalize
% => 1번프레임이 아니라 프레임들의 중앙값
% 키로 모든방향 normalize
% 노멀라이즈시 최소값 빼는게 아니라 joint1-> 0.5/0.5/0.5로 가도록
% 실험할때 전방향 노멀라이즈도 해봐야겠다..
clear;
name = '/home/rfj/바탕화면/skeletones/S001C001P002R002A020.skeleton'
bodyinfo = read_skeleton_file(name);
frame_num = size(bodyinfo,2);
%initialize
cur_subject_x = zeros(frame_num, 25);
cur_subject_y = zeros(frame_num, 25);
cur_subject_z = zeros(frame_num, 25);
tot_x = zeros(frame_num,25);
tot_y = zeros(frame_num,25);
tot_z = zeros(frame_num,25);
joint_5 = zeros(1,3);
joint_9 = zeros(1,3);
joint_1 = zeros(1,3);
joint_3 = zeros(1,3);
%get total joints information
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
tot_x(FN,JN) = joints(JN).x;
tot_y(FN,JN) = joints(JN).y;
tot_z(FN,JN) = joints(JN).z;
end
end
%get median values
M_x = median(tot_x);
M_y = median(tot_y);
M_z = median(tot_z);
%set 3 points for make plane
joint_5 = [M_x(5) M_y(5) M_z(5)];
joint_9 = [M_x(9) M_y(9) M_z(9)];
joint_1 = [M_x(1) M_y(1) M_z(1)];
joint_3 = [M_x(3) M_y(3) M_z(3)];
%find RIGID TRNASFORMATION matrix
d1 = joint_1 - joint_5;
d2 = joint_1 - joint_9;
n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly
u1 = n1/norm(n1);
u2 = [0 0 1];
cs1 = dot(u1,u2)/norm(u1)*norm(u2);
ss1 = sqrt(1-cs1.^2);
v1 = cross(u1,u2)/norm(cross(u1,u2));
R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1];
R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1];
R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1];
%1-3 number tolls to parallel x axis. Rigid transformation on plane surface
%Z axis coords oyler angle transform
t = joint_3 - joint_1;
d3 = R1(1,:) * t.';
d3(1,2) = R1(2,:) * t.';
d3(1,3) = R1(3,:) * t.';
u3 = d3(1:2)/norm(d3(1:2));
v3 = [u3(1) -u3(2)];
v3(2,:) = [u3(2) u3(1)];
u4 = [1 0].';
csss = v3\u4;
cs2 = csss(1);
ss2 = csss(2);
R2 = [cs2 -ss2 0];
R2(2,:) = [ss2 cs2 0];
R2(3,:) = [0 0 1];
%apply rigid transformation
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].';
b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].';
c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].';
cur_subject_x(FN,JN) = R2(1,:) * [a b c].';
cur_subject_y(FN,JN) = R2(2,:) * [a b c].';
cur_subject_z(FN,JN) = R2(3,:) * [a b c].';
end
end
%orientation normalize 2 (with plane surface)
if cur_subject_x(1,4) < cur_subject_x(1,1)
cur_subject_x = 0 - cur_subject_x;
end
if cur_subject_y(1,9) > cur_subject_y(1,5)
cur_subject_y = 0 - cur_subject_y;
end
%get current median
CM_x=median(cur_subject_x);
CM_y=median(cur_subject_y);
CM_z=median(cur_subject_z);
%for transform bellybutton to 0.5,0.5 (Except X) but it doesn't work
belly_button = 0.5 - CM_y(2);
belly_button(2) = 0.5 - CM_z(2);
% normalize with x... <- HERE! WANT TO PARALLEL TRANSFORM
... but if I plus belly_button for x and y axis , it dosn't work
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
max_tall = max(cur_subject_x(:));
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
% 이미지 저장
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/sample.png');
imwrite(motionpatch,new_file_name);
% read image after write
ori = imread('/home/rfj/바탕화면/sample.png');
ori = im2double(ori);
ori = ori(:,:,:);
dx = [];
dy = [];
dz = [];
for f = 1:numel(ori(:,1,1))
for j = 1:25
dx = [dx;ori(f,j,1)];
dy = [dy;ori(f,j,2)];
dz = [dz;ori(f,j,3)];
end
end
a = [1 0 0]; % Red 척추 1,2,3,4,20
b = [0 0 1]; % Blue 오른팔 8,9,10,11,23,24
c = [0 1 0]; % Green왼팔 5,6,7,21,22 (여기서 5번이 빠짐. 넣고싶으면 나중에 24 joint가 아니라 25 joint로 추가)
d = [1 1 0]; % Yellow 오른다리 16,17,18,19
e = [0 1 1]; % Skyblue 왼다리 12,13,14,15
colors = [a;a;a;a;c;c;c;c;b;b;b;b;e;e;e;e;d;d;d;d;a;c;c;b;b];
scatter3(dx,dy,dz,100,'filled');
connecting_joints= ...
[2 1 21 3 21 5 6 7 21 9 10 11 1 13 14 15 1 17 18 19 2 8 8 12 12];
for jj=1:25:numel(dx)% 1부터 8개씩 numel = 열갯수..?
current = [];
current(:,1) = dy(jj:jj+24) ;
current(:,2) = dz(jj:jj+24) ;
current(:,3) = dx(jj:jj+24) ;
scatter3(current(:,1),current(:,2),current(:,3),100,colors(:,:),'filled');
for j =1:25
k=connecting_joints(j);
line([current(j,1) current(k,1)], [current(j,2) current(k,2)] , [current(j,3) current(k,3)])
end
set(gca,'Xdir','reverse','Ydir','reverse')
xlim([0 1]);
xlabel('x')
ylim([0 1]);
ylabel('y')
zlim([0 1]);
zlabel('z')
drawnow
pause(0.01)
end
\ No newline at end of file
%missing file delete
%LOCATION : raw skeletone files
path_name = '/media/rfj/EEA4441FA443E923/nturgb_skeletones/';
file_list = dir(path_name);
L = length(file_list);
fileID = fopen('/home/rfj/MATLAB/bin/samples_with_missing_skeletons.txt','r');
formatSpec = '%s';
sizeA = [20 Inf];
missing_file_list = fscanf(fileID,formatSpec,sizeA);
missing_file_list = missing_file_list.';
fclose(fileID);
perfect_list = [];
for K = 3:L
file_name = char(file_list(K).name);
missing_num = 0;
for J = 1:length(missing_file_list);
missing_name = missing_file_list(J,:);
if file_name(1:20) == missing_name
missing_num = 1;
end
end
if missing_num == 0
perfect_list = [perfect_list;file_name];
end
end
% make motion patch
L = length(perfect_list);
for K = 1:L
file_name = char(perfect_list(K,:));
name = strcat(path_name,file_name(1:20),'.skeleton');
num_body = file_name(22);
BN = str2num(num_body);
[token,remainder] = strtok(file_name,'A');
class = str2num(remainder(2:4));
if class == 20
bodyinfo = read_skeleton_file(name);
frame_num = size(bodyinfo,2);
%initialize
cur_subject_x = zeros(frame_num, 25);
cur_subject_y = zeros(frame_num, 25);
cur_subject_z = zeros(frame_num, 25);
tot_x = zeros(frame_num,25);
tot_y = zeros(frame_num,25);
tot_z = zeros(frame_num,25);
joint_5 = zeros(1,3);
joint_9 = zeros(1,3);
joint_1 = zeros(1,3);
joint_3 = zeros(1,3);
try
%get total joints information
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
tot_x(FN,JN) = joints(JN).x;
tot_y(FN,JN) = joints(JN).y;
tot_z(FN,JN) = joints(JN).z;
end
end
%get median values
M_x = median(tot_x);
M_y = median(tot_y);
M_z = median(tot_z);
%set 3 points for make plane
joint_5 = [M_x(5) M_y(5) M_z(5)];
joint_9 = [M_x(9) M_y(9) M_z(9)];
joint_1 = [M_x(1) M_y(1) M_z(1)];
joint_3 = [M_x(3) M_y(3) M_z(3)];
%find RIGID TRNASFORMATION matrix
d1 = joint_1 - joint_5;
d2 = joint_1 - joint_9;
n1 = cross(d1,d2); % because we will parallel transform, don't need to find belly
u1 = n1/norm(n1);
u2 = [0 0 1];
cs1 = dot(u1,u2)/norm(u1)*norm(u2);
ss1 = sqrt(1-cs1.^2);
v1 = cross(u1,u2)/norm(cross(u1,u2));
R1 = [v1(1)*v1(1)*(1-cs1)+cs1 v1(1)*v1(2)*(1-cs1)-v1(3)*ss1 v1(1)*v1(3)*(1-cs1)+v1(2)*ss1];
R1(2,:) = [v1(1)*v1(2)*(1-cs1)+v1(3)*ss1 v1(2)*v1(2)*(1-cs1)+cs1 v1(2)*v1(3)*(1-cs1)-v1(1)*ss1];
R1(3,:) = [v1(1)*v1(3)*(1-cs1)-v1(2)*ss1 v1(2)*v1(3)*(1-cs1)+v1(1)*ss1 v1(3)*v1(3)*(1-cs1)+cs1];
%1-3 number tolls to parallel x axis. Rigid transformation on plane surface
%Z axis coords oyler angle transform
t = joint_3 - joint_1;
d3 = R1(1,:) * t.';
d3(1,2) = R1(2,:) * t.';
d3(1,3) = R1(3,:) * t.';
u3 = d3(1:2)/norm(d3(1:2));
v3 = [u3(1) -u3(2)];
v3(2,:) = [u3(2) u3(1)];
u4 = [1 0].';
csss = v3\u4;
cs2 = csss(1);
ss2 = csss(2);
R2 = [cs2 -ss2 0];
R2(2,:) = [ss2 cs2 0];
R2(3,:) = [0 0 1];
%apply rigid transformation
for FN = 1:frame_num
cur_body = bodyinfo(FN).bodies(1);
joints = cur_body.joints;
for JN = 1:25
a = R1(1,:) * [joints(JN).x joints(JN).y joints(JN).z].';
b = R1(2,:) * [joints(JN).x joints(JN).y joints(JN).z].';
c = R1(3,:) * [joints(JN).x joints(JN).y joints(JN).z].';
cur_subject_x(FN,JN) = R2(1,:) * [a b c].';
cur_subject_y(FN,JN) = R2(2,:) * [a b c].';
cur_subject_z(FN,JN) = R2(3,:) * [a b c].';
end
end
%orientation normalize 2 (with plane surface)
if cur_subject_x(1,4) < cur_subject_x(1,1)
cur_subject_x = 0 - cur_subject_x;
end
if cur_subject_y(1,9) > cur_subject_y(1,5)
cur_subject_y = 0 - cur_subject_y;
end
%get current median
CM_x=median(cur_subject_x);
CM_y=median(cur_subject_y);
CM_z=median(cur_subject_z);
%for transform bellybutton to 0.5,0.5 (Except X) but it doesn't work
belly_button = 0.5 - CM_y(2);
belly_button(2) = 0.5 - CM_z(2);
% normalize with x... <- HERE! WANT TO PARALLEL TRANSFORM
... but if I plus belly_button for x and y axis , it dosn't work
cur_subject_x = cur_subject_x - min(cur_subject_x(:));
max_tall = max(cur_subject_x(:));
cur_subject_x = cur_subject_x ./ max_tall;
cur_subject_y = cur_subject_y - min(cur_subject_y(:));
cur_subject_y = cur_subject_y ./ max_tall;
cur_subject_z = cur_subject_z - min(cur_subject_z(:));
cur_subject_z = cur_subject_z ./ max_tall;
% 이미지 저장
motionpatch = cur_subject_x;
motionpatch(:,:,2) = cur_subject_y;
motionpatch(:,:,3) = cur_subject_z;
new_file_name = strcat('/home/rfj/바탕화면/motionpatch/',num2str(class),'/',file_name(1:20),'.png');
imwrite(motionpatch,new_file_name);
catch
name
end
end
end