LeapSwipeGestureΒΆ

Properties:

Methods:

class LeapSwipeGesture

The LeapSwipeGesture class represents a swiping motion of fingers and tools.

api/../../../images/Leap_Gesture_Swipe.png

SwipeGesture objects are generated for each swiping finger or tool. Swipe gestures are continuous; a gesture object with the same ID value will appear in each frame while the gesture continues. The LeapSwipeGesture objects for the gesture have three possible states:

LEAP_GESTURE_STATE_START The gesture has just started.

LEAP_GESTURE_STATE_UPDATE The swipe gesture is continuing.

LEAP_GESTURE_STATE_STOP The swipe gesture is finished.

Important: To use swipe gestures in your application, you must enable recognition of the swipe gesture. You can enable recognition with:

[controller enableGesture:LEAP_GESTURE_TYPE_SWIPE enable:YES];

You can set the minimum length and velocity required for a movement to be recognized as a swipe using the config attribute of a connected LeapController object. Use the following keys to configure swipe recognition:

Key string Value type Default value Units
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s

The following example demonstrates how to set the swipe configuration parameters:

[controller.config setFloat:@"Gesture.Swipe.MinLength" value:200.0];
[controller.config setFloat:@"Gesture.Swipe.MinVelocity" value:750];
[controller.config save];

The LeapController object must be connected to the Leap Motion service/daemon before setting the configuration parameters.

Since 1.0

Public Functions


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

Compare LeapGesture object equality.

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

[thisGesture equals:thatGesture];

Since 1.0
Parameters


- (LeapPointable *) pointable

The finger or tool performing the swipe gesture.

LeapPointable *gesturer = swipe.pointable;

Return
A LeapPointable object representing the swiping finger or tool.
Since 1.0

Property


- (LeapVector *) direction
direction

The unit direction vector parallel to the swipe motion.

LeapVector *direction = swipe.direction;

You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.

Return
LeapVector The unit direction vector representing the swipe motion.
Since 1.0


- (int64_t) duration
duration

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

int64_t microseconds = gesture.duration;

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.

Return
int64_t the elapsed duration in microseconds.
Since 1.0


- (float) durationSeconds
durationSeconds

The elapsed duration in seconds.

float seconds = gesture.duration;

See
duration
Return
float the elapsed duration in seconds.
Since 1.0


- (LeapFrame *) frame
frame

The LeapFrame containing this LeapGesture instance.

LeapFrame *owningFrame = gesture.frame;

Return
The parent LeapFrame object.
Since 1.0


- (NSArray *) hands
hands

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

NSArray *handList = gesture.hands;
//Only one hand for current gestures
LeapHand *gesturingHand = [handList objectAtIndex:0];

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

Return
NSArray the list of related LeapHand objects.
Since 1.0


- (int32_t) id
id

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.

int gestureID = gesture.id;

Return
int32_t the ID of this LeapGesture.
Since 1.0


- (BOOL) isValid
isValid

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.

LeapFrame *frame = [controller frame:0];
LeapGesture *trackedGesture = [frame gesture:trackedGestureID];
if(trackedGesture.isValid)
{
    //Use the data...
}

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


- (NSArray *) pointables
pointables

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

NSArray *pointableList = gesture.pointables;
//Only one pointable for current gestures
LeapHand *gesturingPointable = [pointableList objectAtIndex:0];

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

Return
NSArray the list of related LeapPointable objects.
Since 1.0


- (LeapVector *) position
position

The current position of the swipe.

LeapVector *current = swipe.position;

Return
LeapVector The current swipe position within the Leap frame of reference, in mm.
Since 1.0


- (float) speed
speed

The swipe speed in mm/second.

float velocity = swipe.speed;

Return
float The speed of the finger performing the swipe gesture in millimeters per second.
Since 1.0


- (LeapVector *) startPosition
startPosition

The position where the swipe began.

LeapVector *start = swipe.startPosition;

Return
LeapVector The starting position within the Leap frame of reference, in mm.
Since 1.0


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

LeapGestureState state = gesture.state;

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.

Return
LeapGestureState A value from the LeapGestureState enumeration.
Since 1.0


- (LeapGestureType) type
type

The gesture type.

LeapGestureType type = 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.

Return
LeapGestureType A value from the LeapGestureType enumeration.
Since 1.0

Public Static Functions


+ (LeapGesture *) invalid

Returns an invalid LeapGesture object.

LeapGesture *wrongGesture = LeapGesture.invalid;

Return
The invalid LeapGesture instance.
Since 1.0