Contents
abstract class Leap.Gesture
The Gesture 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 Gesture object to the frame gesture list. For continuous gestures, which occur over many frames, the Leap 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; otherwise no gestures are recognized or reported.
Subclasses of Gesture define the properties for the specific movement patterns recognized by the Leap.
The Gesture subclasses for include:
- CircleGesture -- A circular movement by a finger.
- SwipeGesture -- A straight line movement by the hand with fingers extended.
- ScreenTapGesture -- A forward tapping movement by a finger.
- KeyTapGesture -- A downward tapping movement by a finger.
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 only creates a single ScreenTapGesture object appears 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 from the Frame gestures array. 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.
Constructor Top
Gesture () |
Properties Top
Number | duration | ||
Array | handIds | ||
Number | id | ||
Array | pointableIds | ||
String | state | ||
String | type |
Constructor details
Top
gesture.js at line 3
Gesture
()
Constructs a new Gesture object.
An uninitialized Gesture object is considered invalid. Get valid instances
of the Gesture class, which will be one of the Gesture subclasses, from a
Frame object.
Constructs a new Gesture object.
An uninitialized Gesture object is considered invalid. Get valid instances of the Gesture class, which will be one of the Gesture subclasses, from a Frame object.
Properties Detail Top
gesture.js at line 107
public
Number
duration
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 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.
gesture.js at line 87
public
Array
handIds
The list of hands associated with this Gesture, if any.
If no hands are related to this gesture, the list is empty.
gesture.js at line 75
public
Number
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.
gesture.js at line 97
public
Array
pointableIds
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.
gesture.js at line 121
public
String
state
The gesture ID.
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.
Possible values for the state field are:
- start
- update
- stop
gesture.js at line 139
public
String
type
The gesture type.
Possible values for the type field are:
- circle
- swipe
- screenTap
- keyTap