Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modeling hand movement as a 3D curve in Matlab/Java

I just need some directions regarding a problem I have, where to look, etc.. I am using a movement tracking glove for one of my projects, which returns an X, Y and Z values for each finger and for the palm.

What I would like to do is to first create a representation of each finger movements based on these coordinates, , and then attach each of them to the movement of the palm, to have a representation of the hand. This second step will be easy once I manage the first one, but... I don't manage.

I'm trying to implement it in Java (better analysis possibilities), but can only manage to make a 3D graph with ALL the points, at the same time. And there are around 45,000 of them in each curve, so... Would you have any idea of how to make it more like an animation, as in displaying a point at its XYZ coordinates at a given time t?

The other question is: is matlab actually the best option for this? I see how to make this animation work in Java, but I've never used Java for data management, and I doubt it is really good at it.. Is there another software/language that would be good at data management AND animating it? Or should I just use Java to make the animation, and Matlab to do the analysis?

Thanks!

like image 678
Cristol.GdM Avatar asked Jan 04 '12 17:01

Cristol.GdM


1 Answers

You can do the following. Let pos be an Nx3 matrix which contains the x,y,z data of a point, for N time instances. You write a main script which sets up vars etc, and create a loop timer t1 that calls the plotting function "doPlot". The main script is,

clear all
clc

pos=rand(100,3)*10;  %position matrix of random x,y,z coordinates. 100 time instances here

ax=axes;
set(ax,'NextPlot','replacechildren');
axis([0 10 0 10 0 10]); %set axis limits- fit to your needs

Dt=0.1; %sampling period in secs

k=1;
hp=plot3(pos(k,1),pos(k,2),pos(k,3),'o'); %get handle to dot object

t1=timer('TimerFcn','k=doPlot(hp,pos,t1,k)','Period', Dt,'ExecutionMode','fixedRate');
start(t1);

Next you create the plotting function doPlot,

function k=doPlot(hp,pos,t1,k)

k=k+1;
if k<length(pos)
   set(hp,'XData',pos(k,1),'YData',pos(k,2),'ZData',pos(k,3));
   axis([0 10 0 10 0 10]);
else
    stop(t1)
end

You will see a point (circle) in 3D randomly moving aroung in space. The animation period is Dt secs (0.1 secs in this case). You must fit it to your needs. This is a basic animation in Matlab. You could do much more. It depends on your needs.

like image 147
Jorge Avatar answered Oct 18 '22 16:10

Jorge