Inherits from NSObject
Declared in LeapObjectiveC.h

Overview

The LeapGesture class represents a recognized movement by the user.

The Leap watches the activity within its field of view for certain movement
patterns typical of a user gesture or command. For example, a movement from side to
side with the hand can indicate a swipe gesture, while a finger poking forward
can indicate a screen tap gesture.

When the Leap recognizes a gesture, it assigns an ID and adds a
LeapGesture object to the frame gesture list. For continuous gestures, which
occur over many frames, the Leap updates the gesture by adding
a LeapGesture object having the same ID and updated properties in each
subsequent frame.

Important: Recognition for each type of gesture must be enabled using the
[LeapController enableGesture:enable:] function; otherwise no gestures are
recognized or reported
.

Subclasses of LeapGesture define the properties for the specific movement patterns
recognized by the Leap.

The LeapGesture subclasses for include:

Circle and swipe gestures are continuous and these objects can have a
state of start, update, and stop.

The tap gestures are discrete. The Leap only creates a single
LeapScreenTapGesture or LeapKeyTapGesture object appears for each tap and that
object is always assigned the stop state.

Get valid LeapGesture instances from a object. You can get a list of gestures
with the [LeapFrame gestures:] method. You can also
use the [LeapFrame gesture:] method to find a gesture in the current frame using
an ID value obtained in a previous frame.

LeapGesture objects can be invalid. For example, when you get a gesture by ID
using [LeapFrame gesture:], and there is no gesture with that ID in the current
frame, then gesture: returns an Invalid LeapGesture object (rather than a null
value). Always check object validity in situations where a gesture might be
invalid.

The following keys can be used with the LeapConfig class to configure the gesture
recognizer:

Key string Value type Default value Units
Gesture.Circle.MinRadius float 5.0 mm
Gesture.Circle.MinArc float 1.5*pi radians
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s
Gesture.KeyTap.MinDownVelocity float 50 mm/s
Gesture.KeyTap.HistorySeconds float 0.1 s
Gesture.KeyTap.MinDistance float 5.0 mm
Gesture.ScreenTap.MinForwardVelocity float 50 mm/s
Gesture.ScreenTap.HistorySeconds float 0.1 s
Gesture.ScreenTap.MinDistance float 3.0 mm

Tasks

  •   frame

    The LeapFrame containing this LeapGesture instance.

    property
  •   hands

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

    property
  •   pointables

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

    property
  • – type

    The gesture type.

  • – state

    The gesture state.

  • – id

    The gesture ID.

  • – duration

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

  • – durationSeconds

    The elapsed duration in seconds.

  • – isValid

    Reports whether this LeapGesture instance represents a valid gesture.

  • – equals:

    Compare LeapGesture object equality.

  • + invalid

    Returns an invalid LeapGesture object.

Properties

frame

The LeapFrame containing this LeapGesture instance.

@property (nonatomic, strong, readonly) LeapFrame *frame

Return Value

The parent LeapFrame object.

Discussion

The LeapFrame containing this LeapGesture instance.

Declared In

LeapObjectiveC.h

hands

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

@property (nonatomic, strong, readonly) NSArray *hands

Return Value

NSArray the list of related LeapHand objects.

Discussion

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

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

Declared In

LeapObjectiveC.h

pointables

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

@property (nonatomic, strong, readonly) NSArray *pointables

Return Value

NSArray the list of related LeapPointable objects.

Discussion

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

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

Declared In

LeapObjectiveC.h

Class Methods

invalid

Returns an invalid LeapGesture object.

+ (LeapGesture *)invalid

Return Value

The invalid LeapGesture instance.

Discussion

Returns an invalid LeapGesture object.

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

Declared In

LeapObjectiveC.h

Instance Methods

duration

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

- (int64_t)duration

Return Value

int64_t the elapsed duration in microseconds.

Discussion

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

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

Declared In

LeapObjectiveC.h

durationSeconds

The elapsed duration in seconds.

- (float)durationSeconds

Return Value

float the elapsed duration in seconds.

Discussion

The elapsed duration in seconds.

Declared In

LeapObjectiveC.h

equals:

Compare LeapGesture object equality.

- (BOOL)equals:(const LeapGesture *)other

Parameters

other

The LeapGesture object to compare.

Discussion

Compare LeapGesture object equality.

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

Declared In

LeapObjectiveC.h

id

The gesture ID.

- (int32_t)id

Return Value

int32_t the ID of this LeapGesture.

Discussion

The gesture ID.

All LeapGesture objects belonging to the same recognized movement share the
same ID value. Use the ID value with the [LeapFrame gesture:] method to
find updates related to this LeapGesture object in subsequent frames.

Declared In

LeapObjectiveC.h

isValid

Reports whether this LeapGesture instance represents a valid gesture.

- (BOOL)isValid

Return Value

bool Yes, if this is a valid LeapGesture instance; NO, otherwise.

Discussion

Reports whether this LeapGesture instance represents a valid gesture.

An invalid LeapGesture object does not represent a snapshot of a recognized
movement. Invalid LeapGesture objects are returned when a valid object cannot
be provided. For example, when you get an gesture by ID
using [LeapFrame gesture:], and there is no gesture with that ID in the current
frame, then gesture: returns an Invalid LeapGesture object (rather than a null
value). Always check object validity in situations where an gesture might be
invalid.

Declared In

LeapObjectiveC.h

state

The gesture state.

- (LeapGestureState)state

Return Value

LeapGestureState A value from the LeapGestureState enumeration.

Discussion

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
LeapGesture object falls.

The possible gesture states are defined by the LeapGestureState enumeration:

  • LEAP_GESTURE_STATE_INVALID – An invalid state.
  • LEAP_GESTURE_STATE_START – The gesture is starting. Just enough has happened to recognize it.
  • LEAP_GESTURE_STATE_UPDATE – The gesture is in progress. (Note: not all gestures have updates).
  • LEAP_GESTURE_STATE_STOP – The gesture has completed or stopped.

Declared In

LeapObjectiveC.h

type

The gesture type.

- (LeapGestureType)type

Return Value

LeapGestureType A value from the LeapGestureType enumeration.

Discussion

The gesture type.

The supported types of gestures are defined by the LeapGestureType enumeration:

  • LEAP_GESTURE_TYPE_INVALID – An invalid type.
  • LEAP_GESTURE_TYPE_SWIPE – A straight line movement by the hand with fingers extended.
  • LEAP_GESTURE_TYPE_CIRCLE – A circular movement by a finger.
  • LEAP_GESTURE_TYPE_SCREEN_TAP – A forward tapping movement by a finger.
  • LEAP_GESTURE_TYPE_KEY_TAP – A downward tapping movement by a finger.

Declared In

LeapObjectiveC.h