Finger

Attributes:

class Finger()

Extends Pointable().

The Finger class represents a tracked finger.

Fingers are Pointable objects that the Leap Motion software has classified as a finger. Get valid Finger objects from a Frame or a Hand object.

var hand = frame.hands[0];
var finger = hand.fingers[0];

Starting in Leap Motion version 2 (LeapJS 0.6.0), fingers are always associated with a hand and every hand always has five fingers.

Fingers may be permanently associated to a hand. In this case the angular order of the finger IDs will be invariant. As fingers move in and out of view it is possible for the guessed ID of a finger to be incorrect. Consequently, it may be necessary for finger IDs to be exchanged. All tracked properties, such as velocity, will remain continuous in the API. However, quantities that are derived from the API output (such as a history of positions) will be discontinuous unless they have a corresponding ID exchange.

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

New in version 2.0.

Finger.bones
Type:Bone[] – an array containing the finger bones.

The finger bones ordered from wrist to finger tip (metacarpal, proximal, intermediate, and distal).

New in version 2.0.

Finger.carpPosition
Type:number[] – a 3-element array representing a position vector.

The physical position of the base end of the metacarpal bone of the finger (closest to the wrist).

New in version 2.0.

Finger.dipPosition
Type:number[] – a 3-element array representing a position vector.

The physical position of the distal interphalangeal joint of the finger. This point is the base of the distal bone (closest to the intermediate phalanx).

var position = finger.dipPosition;
console.table(position);

New in version 2.0.

Finger.distal
Type:Bone()

The distal phalanx of the finger (the bone most distant from the body).

New in version 2.0.

Finger.medial
Type:Bone()

The intermediate phalanx of the finger (the bone in the middle of the finger).

New in version 2.0.

Finger.extended
Type:boolean

True, if the finger is a pointing, or extended, posture.

var extendedFingers = 0;
    for(var f = 0; f < hand.fingers.length; f++){
        var finger = hand.fingers[f];
        if(finger.extended) extendedFingers++;
}
console.log("Extended fingers: " + extendedFingers);

New in version 2.0.

Finger.mcpPosition
Type:number[] – a 3-element array representing a position vector.

The physical position of the metacarpophalangeal joint, or knuckle, of the finger. This position is the joint between the metacarpal and proximal phalanx bones.

var position = finger.mcpPosition;
console.table(position);

New in version 2.0.

Finger.metacarpal
Type:Bone()

The metacarpal bone of the finger (the bone within the palm of the hand).

New in version 2.0.

Finger.pipPosition
Type:number[] – a 3-element array representing a position vector.

The physical position of the proximal interphalangeal joint of the finger. This position is the joint between the proximal and the intermediate phalanges.

var position = finger.pipPosition;
console.table(position);

New in version 2.0.

Finger.proximal
Type:Bone()

The proximal phalanx of the finger (the phalanx bone closest to the body).

New in version 2.0.

Finger.type
Type:integer – a code indicating the finger name

The anatomical name of this finger:

  • 0 = THUMB
  • 1 = INDEX
  • 2 = MIDDLE
  • 3 = RING
  • 4 = PINKY
var nameMap = ["thumb", "index", "middle", "ring", "pinky"];
var fingerName = nameMap[finger.type];

New in version 2.0.

Finger.invalid
Type:Finger

An invalid Finger object.

You can use this invalid object in comparisons testing whether a given Finger instance is valid or invalid. (You can also use the Pointable.valid attribute.)

function findStubbyFinger(frame){
    for(var f = 0; f < hand.fingers.length; f++){
        var finger = hand.fingers[f];
        if(finger.length <= finger.width * 2.5) return finger;
    }
    return Leap.Finger.invalid;
}

New in version 2.0.