2

anybody who know how to calculate the speed of hand gesture from hand tracking ? (i'm using processing 1.5.1 with simpleopenNI 0.27)

Thanks for your attention

Luigi
  • 4,129
  • 6
  • 37
  • 57
Faiz
  • 40
  • 4

1 Answers1

4

Speed is distance per unit time. Therefore, speed is:

distance_between_hand_in_consecutive_frames/(seconds_per_frame)

To find distance in 3d, use Euclidean distance with the position of the hand in consecutive frames.

EDIT: A psuedocode example.

f1 = get_current_frame_hand_coordinates()
f0 = get_previous_frame_hand_coordinates()

Then you need a function to calculate distance. Your input should be two tuples, here a and b, of size three, i.e. (x,y,z)

e_distance(a,b):
    d = square_root( (a[0]-b[0])^2 + (a[1]-b[1])^2 + (a[2]-b[2])^2 )
    return d

dist = e_distance(f0,f1)

Basically, here you just plug the tuple values into the equation. I'm not sure how your code is laid out, this is designed for a single set of tuples.

Now that you have the distance, then we just need to calculate the speed.

speed = distance/seconds_per_frame

Wikipedia says that the framerate of a Kinect is between 9 and 30 Hz. This means that your seconds_per_frame is between 1/9 and 1/30 of a second.

This will only give you the speed. Your question asks about speed (which only has magnitude), but you can also get velocity (which has both magnitude and direction) fairly easily with a little trig.

Luigi
  • 4,129
  • 6
  • 37
  • 57
  • thanks for your response. but my problem is about how to apply that method in a code. could you show me an example ? – Faiz Apr 14 '14 at 19:01
  • I'm not going to fully code it out but when I get to a computer I'll psuedocode it out and hopefully that should help you integrate it into your code. – Luigi Apr 15 '14 at 01:43