Finger

Methods:

class Leap::Finger

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.

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 Finger::isValid() function.

Since
1.0

Public Functions

Bone bone(Bone::Type boneIx)

The bone at a given bone index on this finger.

Leap::FingerList fingers = frame.hands()[0].fingers();
for(Leap::FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); fl++){
    Leap::Bone bone;
    Leap::Bone::Type boneType;
    for(int b = 0; b < 4; b++)
    {
        boneType = static_cast<Leap::Bone::Type>(b);
        bone = (*fl).bone(boneType);
        std::cout << "Finger index: " << (*fl).type() << " " << bone << std::endl;
    }
}

Return
The Bone that has the specified bone type.
Since
2.0
Parameters
  • boneIx -

    An index value from the Bone::Type enumeration identifying the bone of interest.

Finger()

Constructs a Finger object.

An uninitialized finger is considered invalid. Get valid Finger objects from a Frame or a Hand object.

Since
1.0

Finger(const Pointable &)

If the specified Pointable object represents a finger, creates a copy of it as a Finger object; otherwise, creates an invalid Finger object.

Leap::Finger finger = Leap::Finger(pointable);

Since
1.0

Vector jointPosition(Joint jointIx)

Deprecated as of version 2.0 Use ‘bone’ method instead.

std::string toString()

A string containing a brief, human readable description of the Finger object.

std::string description = finger.toString();

Return
A description of the Finger object as a string.
Since
1.0

Type type()

The name of this finger.

Leap::Finger::Type fingerType = finger.type();

Return
The anatomical type of this finger as a member of the Finger::Type enumeration.
Since
2.0

Public Static Functions

const Finger & invalid()

Returns an invalid Finger object.

You can use the instance returned by this function in comparisons testing whether a given Finger instance is valid or invalid. (You can also use the Finger::isValid() function.)

Leap::Finger invalidFinger = Leap::Finger::invalid();

Return
The invalid Finger instance.
Since
1.0

Finger Names

Type enum

Enumerates the names of the fingers.

Members of this enumeration are returned by Finger::type() to identify a Finger object.

Since
2.0

Values:

  • TYPE_THUMB = = 0 -

    The thumb.

  • TYPE_INDEX = = 1 -

    The index or fore-finger.

  • TYPE_MIDDLE = = 2 -

    The middle finger.

  • TYPE_RING = = 3 -

    The ring finger.

  • TYPE_PINKY = = 4 -

    The pinky or little finger.