Fingers

Fingers and tools — things that can be pointed — are represented by Pointable objects. In addition, separate Finger and Tool classes specialize the Pointable class to provide specific information.

Getting Pointable Objects

You can get the fingers associated with a particular hand from the Hand object. You can also get all detected pointables (fingers and tools) from a Frame object.

Pointable Object Characteristics

Pointable objects have many attributes describing the characteristics of the represented finger or tool.

https://di4564baj7skl.cloudfront.net/documentation/v2/images/Leap_Finger_Model.png

Finger tipPosition and direction vectors provide the positions of the finger tips and the directions in which the fingers are pointing.

The Leap Motion software classifies a detected pointable object as either a finger or a tool. Use the Pointable::isTool() function to determine which one a Pointable object represents.

https://di4564baj7skl.cloudfront.net/documentation/v2/images/Leap_Tool.png

A Tool is longer, thinner, and straighter than a finger.

  • Tip position — the instantaneous position in mm from the Leap Motion origin.
  • Tip velocity — the instantaneous velocity in mm/s.
  • Stabilized tip position — the position filtered and stabilized using velocity and past positions.
  • Direction — the current pointing direction vector.
  • Length — the apparent length of the finger or tool.
  • Width — the average width.
  • Touch distance — the normalized distance from the virtual touch plane. See Touch Emulation.
  • Touch zone — the pointable’s current relation to the virtual touch plane.

The following example illustrates how to get a pointable object from a frame and access its basic characteristics:

pointable = frame.pointables.frontmost
direction = pointable.direction
length = pointable.length
width = pointable.width
stabilizedPosition = pointable.stabilized_tip_position
position = pointable.tip_position
speed = pointable.tip_velocity
touchDistance = pointable.touch_distance
zone = pointable.touch_zone

Converting a Pointable Object to a Finger or Tool

To convert a Pointable object to its proper Finger or Tool subclass, use the appropriate Finger or Tool constructor (one of the few times that you should use the constructor for a Leap class).

if (pointable.is_tool):
    tool = Leap.Tool(pointable)
else:
    finger = Leap.Finger(pointable)

Fingers

Finger objects extend Pointable to represent physical fingers. A finger has a type, a direction and a set of bones.

As of version 2.0 of the Leap Motion SDK, all five fingers are are always present in the list of fingers for a hand. The Leap Motion software estimates positions for fingers and bones that it cannot track clearly. Thus subtle movements of fingers against or behind the hand (as seen from the Leap Motion sensor’s point of view) may not be reflected in the data.

Fingers can be identified by type, e.g. the index, thumb, pinky. Finger IDs are assigned based on the hand ID. If a hand has an ID of “5”, then its fingers are assigned IDs 50 to 55, ordered from thumb to pinky.

Pointable, Finger, and Tool Lists

The PointableList, FingerList, and ToolList classes all have a similar structure. They are designed to act like vector-style arrays and support iterators. You cannot remove or alter the member objects of lists received from the Leap API, but you can combine lists of the same object type.

To use an iterator with one of these lists:

for hand in handList:
    print hand

The PointableList, FingerList, and ToolList classes define additional functions for getting members of the list based on their relative position within the Leap coordinate system. These functions include leftmost(), rightmost(), and frontmost(). The following snippet illustrates a few ways to use these functions:

farLeft = frame.fingers.leftmost
mostForwardOnHand = frame.hands[0].fingers.frontmost
rightTool = frame.tools.rightmost