# LeapFinger¶

Properties:

Methods:

class LeapFinger

The LeapFinger class represents a tracked finger.

Fingers are pointable objects that the Leap has classified as a finger. Get valid LeapFinger objects from a LeapFrame or a LeapHand object.

Note that LeapFinger objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical finger. Invalid LeapFinger objects can be the result of asking for a finger using an ID from an earlier frame when no fingers with that ID exist in the current frame. A LeapFinger object created from the LeapFinger constructor is also invalid. Test for validity with the LeapFinger isValid function.

Since 1.0

Public Functions

- (LeapBone *) bone:(LeapBoneType) type

The bone of the specified anatomical type for this finger.

Note that the thumb bone types match the types of the other fingers in the Leap Motion model. A real thumb has one fewer bone than the other fingers, so a zero-length bone is inserted for the thumb in the Leap Motion model. To keep the bone indexes and names consistent between the thumb and other fingers, the zero-length bone is added at the metacarpal position. However, in the standard anatomical naming system, the missing thumb bone is the intermediate phalanx. Thus, in the Leap Motion model, the anatomical metacarpal of the thumb is labeled as the proximal phalanx and the proximal phalanx is labeled as the intermediate phalanx.

static const NSString *const boneNamesInit[] = {
@"Metacarpal", @"Proximal phalanx",
@"Intermediate phalanx", @"Distal phalanx"
};
NSArray *boneNames = [[NSArray alloc] initWithObjects:boneNamesInit count:4];

for (LeapFinger *finger in hand.fingers) {
for (int boneType = LEAP_BONE_TYPE_METACARPAL; boneType <= LEAP_BONE_TYPE_DISTAL; boneType++) {
LeapBone *bone = [finger bone:boneType];
NSLog(@"%@ bone, start: %@, end: %@, direction: %@",
[boneNames objectAtIndex:boneType],
bone.prevJoint,
bone.nextJoint,
bone.direction);
}
}


Return
The LeapBone object of the specified bone type.
Since
2.0
Parameters
• type -

An index value from the LeapBoneType enumeration identifying the bone of interest.

- (LeapVector *) jointPosition:(LeapFingerJoint) jointIx

The position of the specified joint on this finger in millimeters from the Leap Motion origin.

Return
The LeapVector containing the coordinates of the joint position.
Since 2.0
Parameters
• jointIx -

An index value from the LeapFingerJoint enumeration identifying the joint of interest.

Property

- (LeapVector *) direction
direction

The direction in which this finger or tool is pointing.

LeapVector *direction = pointable.direction;


The direction is expressed as a unit vector pointing in the same direction as the tip.

Return
The LeapVector pointing in the same direction as the tip of this LeapPointable object.
Since 1.0

- (LeapFrame *) frame
frame

The LeapFrame associated with this LeapPointable object.

LeapFrame *owningFrame = pointable.frame;


This property is a weak reference to the LeapFrame object so it is only valid during the lifetime of the LeapFrame object while the LeapFrame object is in the history buffer or while your application maintains its own reference.

Return
The associated LeapFrame object, if available; otherwise, an invalid LeapFrame object is returned.
Since 1.0

- (LeapHand *) hand
hand

The LeapHand associated with a finger.

LeapHand *owningHand = pointable.hand;


This property is a weak reference to the LeapHand object so it is only valid during the lifetime of that LeapHand object in other words, while the parent LeapFrame object is valid or while your application maintains its own reference.

As of version 2, tools are not associated with hands, so this property always returns an invalid LeapHand object for tools.

Return
The associated LeapHand object, if available; otherwise, an invalid LeapHand object is returned.
Since 1.0

- (int32_t) id
id

A unique ID assigned to this LeapPointable object, whose value remains the same across consecutive frames while the tracked finger or tool remains visible.

If tracking is lost, the Leap may assign a new ID when it detects the entity in a future frame.

int id = pointable.id;


Use the ID value with the [LeapFrame pointable:] function to find this LeapPointable object in future frames.

int idOfInterest = 201;
LeapPointable *pointableOfInterest = [frame pointable:idOfInterest];


Return
The ID assigned to this LeapPointable object.
Since 1.0

- (BOOL) isExtended
isExtended

Whether or not this Pointable is in an extended posture.

int extendedCount = 0;
for (LeapPointable *pointable in frame.pointables) {
if (pointable.isExtended) {
extendedCount++;
}
}


A finger is considered extended if it is extended straight from the hand as if pointing. A finger is not extended when it is bent down and curled towards the palm.

Return
True, if the pointable is extended.
Since 2.0

- (BOOL) isFinger
isFinger

Whether or not the LeapPointable is classified a finger.

if (pointable.isFinger) {
LeapFinger *finger = (LeapFinger *)pointable;
}


Return
YES, if this LeapPointable is classified as a LeapFinger.
Since 1.0

- (BOOL) isTool
isTool

Whether or not the LeapPointable is classified to be a tool.

if (pointable.isTool) {
LeapTool *tool = (LeapTool *)pointable;
}


Return
NO

- (BOOL) isValid
isValid

Reports whether this is a valid LeapPointable object.

if(pointable.isValid){
//Use the data
}


Return
YES, if this LeapPointable object contains valid tracking data.
Since 1.0

- (float) length
length

The estimated length of the finger or tool in millimeters.

The reported length is the visible length of the finger or tool. If the length isn’t known, then a value of 0 is returned.

float length = pointable.length;


Return
The estimated length of this LeapPointable object.
Since 1.0

- (LeapVector *) stabilizedTipPosition
stabilizedTipPosition

The stabilized tip position of this LeapPointable.

LeapVector *stabilizedPosition = pointable.stabilizedTipPosition;


Smoothing and stabilization is performed in order to make this value more suitable for interaction with 2D content.

Since 1.0

- (float) timeVisible
timeVisible

The duration of time this Pointable has been visible to the Leap Motion Controller.

float lifetime = pointable.timeVisible;


Return
The duration (in seconds) that this Pointable has been tracked.
Since 1.0

- (LeapVector *) tipPosition
tipPosition

The tip position in millimeters from the Leap origin.

LeapVector *position = pointable.tipPosition;


Return
The LeapVector containing the coordinates of the tip position.
Since 1.0

- (LeapVector *) tipVelocity
tipVelocity

The rate of change of the tip position in millimeters/second.

LeapVector *speed = pointable.tipVelocity;


Return
The LeapVector containing the coordinates of the tip velocity.
Since 1.0

- (float) touchDistance
touchDistance

A value proportional to the distance between this LeapPointable object and the adaptive touch plane.

float touchDistance = pointable.touchDistance;


- (LeapPointableZone) touchZone
touchZone

The current touch zone of this LeapPointable object.

LeapPointableZone zone = pointable.touchZone;


- (LeapFingerType) type
type

The name of this finger.

static const NSString *const fingerNamesInit[] = {
@"Thumb", @"Index finger", @"Middle finger",
@"Ring finger", @"Little finger"
};
NSArray *fingerNames = [[NSArray alloc] initWithObjects:fingerNamesInit count:5];

for (LeapFinger *finger in hand.fingers) {
NSLog(@"Finger is: %@,",[fingerNames objectAtIndex:finger.type]);
}


Return
The anatomical type of this finger as a member of the LeapFingerType enumeration.
Since 2.0

- (float) width
width

The estimated width of the finger or tool in millimeters.

The reported width is the average width of the visible portion of the finger or tool. If the width isn’t known, then a value of 0 is returned.

float width = pointable.width;


Return
The estimated width of this LeapPointable object.
Since 1.0

Public Static Functions

+ (LeapPointable *) invalid

Returns an invalid LeapPointable object.

LeapPointable *pointer = LeapPointable.invalid;


Return
The invalid LeapPointable instance.
Since 1.0

## LeapFingerJoint¶

LeapFingerJoint enum

Enumerates the joints of a finger.

The joints along the finger are indexed from 0 to 3 (tip to knuckle). The same joint identifiers are used for the thumb, even though the thumb has one less phalanx bone than the other digits. This puts the base joint (JOINT_MCP) at the base of thumb’s metacarpal bone.

Pass a member of this enumeration to [LeapPointable jointPosition] to get the physical position of that joint.

Note: The term “joint” is applied loosely here and the set of joints includes the finger tip even though it is not an anatomical joint.

Since 2.0

Values:

• LEAP_FINGER_JOINT_MCP = = 0 -

The metacarpophalangeal joint, or knuckle, of the finger.

The metacarpophalangeal joint is located at the base of a finger between the metacarpal bone and the first phalanx. The common name for this joint is the knuckle.

On a thumb, which has one less phalanx than a finger, this joint index identifies the thumb joint near the base of the hand, between the carpal and metacarpal bones.

Since 2.0

• LEAP_FINGER_JOINT_PIP = = 1 -

The proximal interphalangeal joint of the finger.

This joint is the middle joint of a finger.

The proximal interphalangeal joint is located between the two finger segments closest to the hand (the proximal and the intermediate phalanges). On a thumb, which lacks an intermediate phalanx, this joint index identifies the knuckle joint between the proximal phalanx and the metacarpal bone.

Since 2.0

• LEAP_FINGER_JOINT_DIP = = 2 -

The distal interphalangeal joint of the finger.

This joint is closest to the tip.

The distal interphalangeal joint is located between the most extreme segment of the finger (the distal phalanx) and the middle segment (the intermediate phalanx).

Since 2.0

• LEAP_FINGER_JOINT_TIP = = 3 -

The tip of the finger.

Since 2.0

## LeapFingerType¶

LeapFingerType enum

Enumerates the names of the fingers.

Members of this enumeration are returned by [LeapFinger type] to identify a Finger object.

Since 2.0

Values:

• LEAP_FINGER_TYPE_THUMB = = 0 -

The thumb.

• LEAP_FINGER_TYPE_INDEX = = 1 -

The index or forefinger.

• LEAP_FINGER_TYPE_MIDDLE = = 2 -

The middle finger.

• LEAP_FINGER_TYPE_RING = = 3 -

The ring finger.

• LEAP_FINGER_TYPE_PINKY = = 4 -

The pinky or little finger.