Methods:
The Gesture class represents a recognized movement by the user.
Public FunctionsPublic Static Functionsint64_t 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.
Frame frame()The Frame containing this Gesture instance.
Leap::Frame frameOfGesture = gesture.frame();Gesture()Gesture(const Gesture & rhs)Constructs a new copy of an Gesture object.
Leap::Gesture copy = Leap::Gesture(gesture);HandList hands()The list of hands associated with this Gesture, if any.
Leap::HandList handsForGesture = gesture.hands();If no hands are related to this gesture, the list is empty.
int32_t 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.
int32_t gestureOfInterest = gesture.id(); Leap::GestureList manyGestures = frame.gestures(olderFrame); for(Leap::GestureList::const_iterator gl = manyGestures.begin(); gl != manyGestures.end(); gl++) { if ((*gl).id() == gestureOfInterest) { //Process it... } }
- Return
- int32_t the ID of this Gesture.
bool isValid()bool operator!=(const Gesture & rhs)Compare Gesture object inequality.
thisGesture != thatGesture;Two Gestures are equal only if they represent the same snapshot of the same recognized movement.
bool operator==(const Gesture & rhs)Compare Gesture object equality.
thisGesture == thatGesture;Two Gestures are equal if they represent the same snapshot of the same recognized movement.
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.
Leap::PointableList pointablesForGesture = gesture.pointables();
- Return
- PointableList the list of related Pointable objects.
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.
Leap::GestureList gestures = frame.gestures(); for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != gestures.end(); gl++) { switch ((*gl).state()) { case Leap::Gesture::STATE_START: //Handle starting gestures break; case Leap::Gesture::STATE_UPDATE: //Handle continuing gestures break; case Leap::Gesture::STATE_STOP: //Handle ending gestures break; default: //Handle unrecognized states break; } }
- Return
- Gesture::State A value from the Gesture::State enumeration.
std::string toString()A string containing a brief, human-readable description of this Gesture.
Leap::GestureList gestures = frame.gestures(); for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != gestures.end(); gl++) std::cout << (*gl).toString() << std::endl;Type type()The gesture type.
Leap::GestureList gestures = frame.gestures(); for(Leap::GestureList::const_iterator gl = gestures.begin(); gl != frame.gestures().end(); gl++) { switch ((*gl).type()) { case Leap::Gesture::TYPE_CIRCLE: //Handle circle gestures break; case Leap::Gesture::TYPE_KEY_TAP: //Handle key tap gestures break; case Leap::Gesture::TYPE_SCREEN_TAP: //Handle screen tap gestures break; case Leap::Gesture::TYPE_SWIPE: //Handle swipe gestures break; default: //Handle unrecognized gestures break; } }
- Return
- Gesture::Type A value from the Gesture::Type enumeration.
const Gesture & invalid()Returns an invalid Gesture object.
Leap::Gesture trackedGesture = frame.gesture(gestureID); if (trackedGesture != Leap::Gesture::invalid()) { //Process it... }
- Return
- The invalid Gesture instance.
Type enum
The supported types of gestures.
Values:
- TYPE_INVALID = = -1 -
An invalid type.
- TYPE_SWIPE = = 1 -
A straight line movement by the hand with fingers extended.
- TYPE_CIRCLE = = 4 -
A circular movement by a finger.
- TYPE_SCREEN_TAP = = 5 -
A forward tapping movement by a finger.
- TYPE_KEY_TAP = = 6 -
A downward tapping movement by a finger.
State enum
The possible gesture states.
Values:
- STATE_INVALID = = -1 -
An invalid state.
- STATE_START = = 1 -
The gesture is starting.
Just enough has happened to recognize it.
- STATE_UPDATE = = 2 -
The gesture is in progress.
(Note: not all gestures have updates).
- STATE_STOP = = 3 -
The gesture has completed or stopped.
C++