GestureΒΆ

Methods:

class com::leapmotion::leap::Gesture

The Gesture class represents a recognized movement by the user.

Public Functions

long duration()

The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.

float microseconds = gesture.duration();

The duration reported for the first Gesture in the sequence (with the STATE_START state) will typically be a small positive number since the movement must progress far enough for the Leap Motion software to recognize it as an intentional gesture.

Return
int64_t the elapsed duration in microseconds.

float durationSeconds()

The elapsed duration in seconds.

float seconds = gesture.durationSeconds();

See
duration()
Return
float the elapsed duration in seconds.

boolean equals(Gesture rhs)

Compare Gesture object equality.

Boolean gestureIsEqual = thisGesture.equals(thatGesture);

Two Gestures are equal if they represent the same snapshot of the same recognized movement.

Frame frame()

The Frame containing this Gesture instance.

Frame frameOfGesture = gesture.frame();

Return
Frame The parent Frame object.

Gesture()

Constructs a new Gesture object.

An uninitialized Gesture object is considered invalid. Get valid instances of the Gesture class, which will be one of the Gesture subclasses, from a Frame object.

Since
1.0

Gesture(Gesture rhs)

Constructs a new copy of an Gesture object.

Gesture copy = new Gesture(gesture);

HandList hands()

The list of hands associated with this Gesture, if any.

HandList handsForGesture = gesture.hands();

If no hands are related to this gesture, the list is empty.

Return
HandList the list of related Hand objects.

int id()

The gesture ID.

All Gesture objects belonging to the same recognized movement share the same ID value. Use the ID value with the Frame::gesture() method to find updates related to this Gesture object in subsequent frames.

int gestureToFind = gesture.id();
GestureList manyGestures = frame.gestures(olderFrame);
for(Gesture gestureObject : manyGestures)
{
    if (gestureObject.id() == gestureToFind) {
        //Process it...
    }
}

Return
int32_t the ID of this Gesture.

boolean isValid()

Reports whether this Gesture instance represents a valid Gesture.

if (gesture.isValid()) {
    // Process it...
}

Return
bool True, if this is a valid Gesture instance; false, otherwise.

PointableList pointables()

The list of fingers and tools associated with this Gesture, if any.

If no Pointable objects are related to this gesture, the list is empty.

PointableList pointablesForGesture = gesture.pointables();

Return
PointableList the list of related Pointable objects.

Gesture.State state()

The gesture state.

Recognized movements occur over time and have a beginning, a middle, and an end. The ‘state()‘ attribute reports where in that sequence this Gesture object falls.

for(Gesture gestureObj : frame.gestures())
{
    switch (gesture.state()) {
        case STATE_START:
            //Handle starting gestures
            break;
        case STATE_UPDATE:
            //Handle continuing gestures
            break;
        case STATE_STOP:
            //Handle ending gestures
            break;
        default:
            //Handle unrecognized states
            break;
    }
}

Return
Gesture::State A value from the Gesture::State enumeration.

String toString()

A string containing a brief, human-readable description of this Gesture.

for(Gesture gesture : frame.gestures()){
    System.out.println(gesture.toString());
}

Gesture.Type type()

The gesture type.

for(Gesture gesture : frame.gestures())
{
    switch (gesture.type()) {
        case TYPE_CIRCLE:
            //Handle circle gestures
            break;
        case TYPE_KEY_TAP:
            //Handle key tap gestures
            break;
        case TYPE_SCREEN_TAP:
            //Handle screen tap gestures
            break;
        case TYPE_SWIPE:
            //Handle swipe gestures
            break;
        default:
            //Handle unrecognized gestures
            break;
    }
}

Return
Gesture::Type A value from the Gesture::Type enumeration.

Public Static Functions

Gesture invalid()

Returns an invalid Gesture object.

Gesture trackedGesture = frame.gesture(gestureID);
if (!trackedGesture.equals(Gesture.invalid())) {
    //Process it...
}

Return
The invalid Gesture instance.

class State

The possible gesture states.

class Type

The supported types of gestures.