LeapCircleGestureΒΆ

Properties:

Methods:

class LeapCircleGesture

The LeapCircleGesture classes represents a circular finger movement.

A circle movement is recognized when the tip of a finger draws a circle within the Leap field of view.

api/../../../images/Leap_Gesture_Circle.png

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

[controller enableGesture:LEAP_GESTURE_TYPE_CIRCLE enable:YES];

Circle gestures are continuous. The LeapCircleGesture objects for the gesture have three possible states:

LEAP_GESTURE_STATE_START The circle gesture has just started. The movement has progressed far enough for the recognizer to classify it as a circle.

LEAP_GESTURE_STATE_UPDATE The circle gesture is continuing.

LEAP_GESTURE_STATE_STOP The circle gesture is finished.

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

Key string Value type Default value Units
Gesture.Circle.MinRadius float 5.0 mm
Gesture.Circle.MinArc float 1.5 * pi radians

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

[controller.config setFloat:@"Gesture.Circle.MinRadius" value:10.0];
[controller.config setFloat:@"Gesture.Circle.MinArc" value:.5];
[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

Property


- (LeapVector *) center
center

The center point of the circle within the Leap frame of reference.

LeapVector *centerPoint = circleGesture.center;

Return
LeapVector The center of the circle in mm from the Leap origin.
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


- (LeapVector *) normal
normal

Returns the normal vector for the circle being traced.

If you draw the circle clockwise, the normal vector points in the same general direction as the pointable object drawing the circle. If you draw the circle counterclockwise, the normal points back toward the pointable. If the angle between the normal and the pointable object drawing the circle is less than 90 degrees, then the circle is clockwise.

NSString* clockDirection;
if ([[[circleGesture pointable] direction]
        angleTo:[circleGesture normal]] <= LEAP_PI/2)
{
   clockDirection = @"clockwise";
} else {
   clockDirection = @"counterclockwise";
}

Return
LeapVector the normal vector for the circle being traced
Since 1.0


- (LeapPointable *) pointable
pointable

The finger performing the circle gesture.

LeapPointable *circlingPointable = circleGesture.pointable;

Return
A LeapPointable object representing the circling finger.
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


- (float) progress
progress

The number of times the finger tip has traversed the circle.

Progress is reported as a positive number of the number. For example, a progress value of .5 indicates that the finger has gone halfway around, while a value of 3 indicates that the finger has gone around the the circle three times.

int revolutions = floor(circleGesture.progress);

Progress starts where the circle gesture began. Since the circle must be partially formed before the Leap Motion software can recognize it, progress will be greater than zero when a circle gesture first appears in the frame.

Return
float A positive number indicating the gesture progress.
Since
1.0


- (float) radius
radius

The radius of the circle.

float currentRadius = circleGesture.radius;

Return
The circle radius 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