![]() |
Leap Motion C++ API Reference
0.8.0
|
The Gesture class represents a recognized movement by the user. More...
Inherits Leap::Interface.
Inherited by Leap::CircleGesture, Leap::KeyTapGesture, Leap::ScreenTapGesture, and Leap::SwipeGesture.
Public Types | |
enum | State { STATE_INVALID = -1, STATE_START = 1, STATE_UPDATE = 2, STATE_STOP = 3 } |
The possible gesture states. More... | |
enum | Type { TYPE_INVALID = -1, TYPE_SWIPE = 1, TYPE_CIRCLE = 4, TYPE_SCREEN_TAP = 5, TYPE_KEY_TAP = 6 } |
The supported types of gestures. More... | |
Public Member Functions | |
int64_t | duration () const |
The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds. | |
float | durationSeconds () const |
The elapsed duration in seconds. | |
Frame | frame () const |
The Frame containing this Gesture instance. | |
Gesture () | |
Constructs a new Gesture object. | |
Gesture (const Gesture &rhs) | |
Constructs a new copy of an Gesture object. | |
HandList | hands () const |
The list of hands associated with this Gesture, if any. | |
int32_t | id () const |
The gesture ID. | |
bool | isValid () const |
Reports whether this Gesture instance represents a valid Gesture. | |
bool | operator!= (const Gesture &rhs) const |
Compare Gesture object inequality. | |
bool | operator== (const Gesture &rhs) const |
Compare Gesture object equality. | |
PointableList | pointables () const |
The list of fingers and tools associated with this Gesture, if any. | |
State | state () const |
The gesture state. | |
std::string | toString () const |
A string containing a brief, human-readable description of this Gesture. | |
Type | type () const |
The gesture type. | |
Static Public Member Functions | |
static const Gesture & | invalid () |
Returns an invalid Gesture object. | |
The Gesture class represents a recognized movement by the user.
The Leap Motion device 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 Motion software recognizes a gesture, it assigns an ID and adds a Gesture object to the frame gesture list. For continuous gestures, which occur over many frames, the Leap Motion software updates the gesture by adding a Gesture object having the same ID and updated properties in each subsequent frame.
Important: Recognition for each type of gesture must be enabled using the Controller::enableGesture() function; otherwise no gestures are recognized or reported.
Subclasses of Gesture define the properties for the specific movement patterns recognized by the Leap Motion software.
The Gesture subclasses for include:
Circle and swipe gestures are continuous and these objects can have a state of start, update, and stop.
The screen tap gesture is a discrete gesture. The Leap Motion software only creates a single ScreenTapGesture object for each tap and it always has a stop state.
Get valid Gesture instances from a Frame object. You can get a list of gestures with the Frame::gestures() method. You can get a list of gestures since a specified frame with the Frame::gestures(const Frame&)
method. You can also use the Frame::gesture()
method to find a gesture in the current frame using an ID value obtained in a previous frame.
Gesture objects can be invalid. For example, when you get a gesture by ID using Frame::gesture()
, and there is no gesture with that ID in the current frame, then gesture()
returns an Invalid Gesture 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 Config 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 |
enum Leap::Gesture::State |
enum Leap::Gesture::Type |
The supported types of gestures.
Leap::Gesture::Gesture | ( | ) |
int64_t Leap::Gesture::duration | ( | ) | const |
The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.
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.
float Leap::Gesture::durationSeconds | ( | ) | const |
Frame Leap::Gesture::frame | ( | ) | const |
HandList Leap::Gesture::hands | ( | ) | const |
int32_t Leap::Gesture::id | ( | ) | const |
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.
|
static |
Returns an invalid Gesture object.
You can use the instance returned by this function in comparisons testing whether a given Gesture instance is valid or invalid. (You can also use the Gesture::isValid() function.)
bool Leap::Gesture::isValid | ( | ) | const |
Reports whether this Gesture instance represents a valid Gesture.
An invalid Gesture object does not represent a snapshot of a recognized movement. Invalid Gesture objects are returned when a valid object cannot be provided. For example, when you get an gesture by ID using Frame::gesture(), and there is no gesture with that ID in the current frame, then gesture() returns an Invalid Gesture object (rather than a null value). Always check object validity in situations where an gesture might be invalid.
bool Leap::Gesture::operator!= | ( | const Gesture & | rhs | ) | const |
Compare Gesture object inequality.
Two Gestures are equal only if they represent the same snapshot of the same recognized movement.
bool Leap::Gesture::operator== | ( | const Gesture & | rhs | ) | const |
Compare Gesture object equality.
Two Gestures are equal if they represent the same snapshot of the same recognized movement.
PointableList Leap::Gesture::pointables | ( | ) | const |
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.
State Leap::Gesture::state | ( | ) | const |
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.
std::string Leap::Gesture::toString | ( | ) | const |
A string containing a brief, human-readable description of this Gesture.
Type Leap::Gesture::type | ( | ) | const |
The gesture type.