For more information:
I recorded with Xbox Kinect. From the Kinect I got translations and rotations. With those I calculate the positions of the joints in space.
But because I recorded a lot of frames, the for loop takes really long because for every frame the script has to do a big calculation, plot and do the calculation again for the next frame.
Here is a little piece of my script:
%load all information
twaist = [M(:,26) M(:,27) M(:,28)];
rwaist = [M(:,29) M(:,30) M(:,31)];
a=1;
b=size(M);
c=b(1,1);
for a=1:c;
%calculate the position of the joint in space
rxwaist=rwaist(a,1)*pi/180;
rywaist=rwaist(a,2)*pi/180;
rzwaist=rwaist(a,3)*pi/180;
ARwaist= [1 0 0;0 cos(rxwaist) -sin(rxwaist);0 sin(rxwaist) cos(rxwaist)];
BRwaist=[cos(rywaist) 0 sin(rywaist);0 1 0; -sin(rywaist) 0 cos(rywaist)];
CRwaist=[cos(rzwaist) -sin(rzwaist) 0; sin(rzwaist) cos(rzwaist) 0; 0 0 1];
Rwaist=ARwaist*BRwaist*CRwaist;
%creating a vector
ptwaist=[twaist(a,1);twaist(a,2);twaist(a,3)];
%Defining position (for waist is really simple, because this is my beginning point)
poswaist=ptwaist;
%Transpose
poswaist2=transpose(poswaist);
%creating lines between joints
pts_sw=[posspine2; poswaist2];
plot3(pts_sw(:,1), pts_sw(:,2), pts_sw(:,3),'g','LineWidth',1.5)
grid on
title('Stick Figure');
xlabel('X');
ylabel('Y');
zlabel('Z');
axis equal
xlim([-80 80])
ylim([-50 200])
zlim([-310 -160])
drawnow
hold off
a=a+1;
end
So this script does these calculations for 26 joints per frame.
It is really slow but I don't know any other way to do this..