nberlove nberlove - 5 months ago 30
Python Question

How does LeapMotion specify which hand is left and which is right?

I am new to Leap Motion, and am playing with the sample code in Python (also new to Python). I am trying to get the a few pieces of information about the left and right hands and fingers (pitch, roll, yaw...etc). It is important that I know which is left and which is right. I can pull out hand information using frame.hands but I am confused about which hand is which. For example is frame.hands[0] always the left hand, the leftmost hand, or is it arbitrary? I am also confused about why it sometimes thinks there are more than 2 hands. Is frame.hands[0] the same hand from frame to frame? If not, is there a good way to track a hand?


I don't think there is any guarantee of index order in the HandList, although you can use e.g. rightmost to select on a spatial basis:

    hands = frame.hands

    rightmost = hands.rightmost

However, to reproduce their note verbatim:

Note that the the leftmost() and rightmost() functions only identify which hand is farthest to the left or right. The functions do not identify which hand is the right or left hand.

If you want to track a hand from frame to frame, you can use its Hand.id; see the documentation:

handID = rightmost.id

hand = frame.hand(handID)