new Frame()
Constructs a Frame object.
Frame instances created with this constructor are invalid. Get valid Frame objects by calling the Controller.frame() function.
- Source:
- frame.js, line 8
Members
-
<static> Invalid :Leap.Frame
-
An invalid Frame object.
You can use this invalid Frame in comparisons testing whether a given Frame instance is valid or invalid. (You can also check the Frame.valid property.)
Type:
- Source:
- frame.js, line 427
-
fingers[] :Leap.Pointable
-
The list of Finger objects detected in this frame, given in arbitrary order. The list can be empty if no fingers are detected.
Type:
- Source:
- frame.js, line 94
-
gestures[] :Leap.Gesture
-
The list of Gesture objects detected in this frame, given in arbitrary order. The list can be empty if no gestures are detected.
Circle and swipe gestures are updated every frame. Tap gestures only appear in the list for a single frame.
Type:
- Source:
- frame.js, line 132
-
hands[] :Leap.Hand
-
The list of Hand objects detected in this frame, given in arbitrary order. The list can be empty if no hands are detected.
Type:
- Source:
- frame.js, line 65
-
id :String
-
A unique ID for this Frame. Consecutive frames processed by the Leap have consecutive increasing values.
Type:
- String
- Source:
- frame.js, line 50
-
pointables[] :Leap.Pointable
-
The list of Pointable objects (fingers and tools) detected in this frame, given in arbitrary order. The list can be empty if no fingers or tools are detected.
Type:
- Source:
- frame.js, line 75
-
timestamp :Number
-
The frame capture time in microseconds elapsed since the Leap started.
Type:
- Number
- Source:
- frame.js, line 58
-
tools[] :Leap.Pointable
-
The list of Tool objects detected in this frame, given in arbitrary order. The list can be empty if no tools are detected.
Type:
- Source:
- frame.js, line 85
-
valid :Boolean
-
Reports whether this Frame instance is valid.
A valid Frame is one generated by the Controller object that contains tracking data for all detected entities. An invalid Frame contains no actual tracking data, but you can call its functions without risk of a undefined object exception. The invalid Frame mechanism makes it more convenient to track individual data across the frame history. For example, you can invoke:
var finger = controller.frame(n).finger(fingerID);
for an arbitrary Frame history value, "n", without first checking whether frame(n) returned a null object. (You should still check that the returned Finger instance is valid.)
Type:
- Boolean
- Source:
- frame.js, line 27
Methods
-
dump() → {String}
-
Returns a JSON-formatted string containing the hands, pointables and gestures in this frame.
- Source:
- frame.js, line 396
Returns:
A JSON-formatted string.
- Type
- String
-
finger(id) → {Leap.Pointable}
-
The finger with the specified ID in this frame.
Use the Frame finger() function to retrieve the finger from this frame using an ID value obtained from a previous frame. This function always returns a Finger object, but if no finger with the specified ID is present, an invalid Pointable object is returned.
Note that ID values persist across frames, but only until tracking of a particular object is lost. If tracking of a finger is lost and subsequently regained, the new Pointable object representing that physical finger may have a different ID than that representing the finger in an earlier frame.
Parameters:
Name Type Description id
String The ID value of a finger from a previous frame.
- Source:
- frame.js, line 197
Returns:
The finger with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.
- Type
- Leap.Pointable
-
hand(id) → {Leap.Hand}
-
The Hand object with the specified ID in this frame.
Use the Frame hand() function to retrieve the Hand object from this frame using an ID value obtained from a previous frame. This function always returns a Hand object, but if no hand with the specified ID is present, an invalid Hand object is returned.
Note that ID values persist across frames, but only until tracking of a particular object is lost. If tracking of a hand is lost and subsequently regained, the new Hand object representing that physical hand may have a different ID than that representing the physical hand in an earlier frame.
Parameters:
Name Type Description id
String The ID value of a Hand object from a previous frame.
- Source:
- frame.js, line 222
Returns:
The Hand object with the matching ID if one exists in this frame; otherwise, an invalid Hand object is returned.
- Type
- Leap.Hand
-
pointable(id) → {Leap.Pointable}
-
The Pointable object with the specified ID in this frame.
Use the Frame pointable() function to retrieve the Pointable object from this frame using an ID value obtained from a previous frame. This function always returns a Pointable object, but if no finger or tool with the specified ID is present, an invalid Pointable object is returned.
Note that ID values persist across frames, but only until tracking of a particular object is lost. If tracking of a finger or tool is lost and subsequently regained, the new Pointable object representing that finger or tool may have a different ID than that representing the finger or tool in an earlier frame.
Parameters:
Name Type Description id
String The ID value of a Pointable object from a previous frame.
- Source:
- frame.js, line 173
Returns:
The Pointable object with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.
- Type
- Leap.Pointable
-
rotationAngle(sinceFrame, axis) → {Number}
-
The angle of rotation around the rotation axis derived from the overall rotational motion between the current frame and the specified frame.
The returned angle is expressed in radians measured clockwise around the rotation axis (using the right-hand rule) between the start and end frames. The value is always between 0 and pi radians (0 and 180 degrees).
The Leap derives frame rotation from the relative change in position and orientation of all objects detected in the field of view.
If either this frame or sinceFrame is an invalid Frame object, then the angle of rotation is zero.
Parameters:
Name Type Argument Description sinceFrame
Leap.Frame The starting frame for computing the relative rotation.
axis
Leap.Vector <optional>
The axis to measure rotation around.
- Source:
- frame.js, line 245
Returns:
A positive value containing the heuristically determined rotational change between the current frame and that specified in the sinceFrame parameter.
- Type
- Number
-
rotationAxis(sinceFrame) → {Leap.Vector}
-
The axis of rotation derived from the overall rotational motion between the current frame and the specified frame.
The returned direction vector is normalized.
The Leap derives frame rotation from the relative change in position and orientation of all objects detected in the field of view.
If either this frame or sinceFrame is an invalid Frame object, or if no rotation is detected between the two frames, a zero vector is returned.
Parameters:
Name Type Description sinceFrame
Leap.Frame The starting frame for computing the relative rotation.
- Source:
- frame.js, line 281
Returns:
A normalized direction Vector representing the axis of the heuristically determined rotational change between the current frame and that specified in the sinceFrame parameter.
- Type
- Leap.Vector
-
rotationMatrix(sinceFrame) → {Leap.Matrix}
-
The transform matrix expressing the rotation derived from the overall rotational motion between the current frame and the specified frame.
The Leap derives frame rotation from the relative change in position and orientation of all objects detected in the field of view.
If either this frame or sinceFrame is an invalid Frame object, then this method returns an identity matrix.
Parameters:
Name Type Description sinceFrame
Leap.Frame The starting frame for computing the relative rotation.
- Source:
- frame.js, line 308
Returns:
A transformation Matrix containing the heuristically determined rotational change between the current frame and that specified in the sinceFrame parameter.
- Type
- Leap.Matrix
-
scaleFactor(sinceFrame) → {Number}
-
The scale factor derived from the overall motion between the current frame and the specified frame.
The scale factor is always positive. A value of 1.0 indicates no scaling took place. Values between 0.0 and 1.0 indicate contraction and values greater than 1.0 indicate expansion.
The Leap derives scaling from the relative inward or outward motion of all objects detected in the field of view (independent of translation and rotation).
If either this frame or sinceFrame is an invalid Frame object, then this method returns 1.0.
Parameters:
Name Type Description sinceFrame
Leap.Frame The starting frame for computing the relative scaling.
- Source:
- frame.js, line 333
Returns:
A positive value representing the heuristically determined scaling change ratio between the current frame and that specified in the sinceFrame parameter.
- Type
- Number
-
tool(id) → {Leap.Pointable}
-
The tool with the specified ID in this frame.
Use the Frame tool() function to retrieve a tool from this frame using an ID value obtained from a previous frame. This function always returns a Pointable object, but if no tool with the specified ID is present, an invalid Pointable object is returned.
Note that ID values persist across frames, but only until tracking of a particular object is lost. If tracking of a tool is lost and subsequently regained, the new Pointable object representing that tool may have a different ID than that representing the tool in an earlier frame.
Parameters:
Name Type Description id
String The ID value of a Tool object from a previous frame.
- Source:
- frame.js, line 148
Returns:
The tool with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.
- Type
- Leap.Pointable
-
toString() → {String}
-
A string containing a brief, human readable description of the Frame object.
- Source:
- frame.js, line 382
Returns:
A brief description of this frame.
- Type
- String
-
translation(sinceFrame) → {Leap.Vector}
-
The change of position derived from the overall linear motion between the current frame and the specified frame.
The returned translation vector provides the magnitude and direction of the movement in millimeters.
The Leap derives frame translation from the linear motion of all objects detected in the field of view.
If either this frame or sinceFrame is an invalid Frame object, then this method returns a zero vector.
Parameters:
Name Type Description sinceFrame
Leap.Frame The starting frame for computing the relative translation.
- Source:
- frame.js, line 355
Returns:
A Vector representing the heuristically determined change in position of all objects between the current frame and that specified in the sinceFrame parameter.
- Type
- Leap.Vector