Class: Frame

Frame

The Frame class represents a set of hand and finger tracking data detected in a single frame.

The Leap detects hands, fingers and tools within the tracking area, reporting their positions, orientations and motions in frames at the Leap frame rate.

Access Frame objects using the Controller#frame() function.

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, constant> Invalid :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 400

fingers[] :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 87

fingers[] :Pointable

The list of fingers detected in this frame that are attached to this hand, given in arbitrary order.

The list can be empty if no fingers attached to this hand are detected.

Type:
Source:
  • hand.js, line 118

gestures[] :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 124

hands[] :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 61

id :String

A unique ID for this Frame. Consecutive frames processed by the Leap have consecutive increasing values.

Type:
  • String
Source:
  • frame.js, line 48

pointables[] :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 70

timestamp :Number

The frame capture time in microseconds elapsed since the Leap started.

Type:
  • Number
Source:
  • frame.js, line 55

tools[] :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 79

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 26

Methods

dump() → {String}

Returns a JSON-formatted string containing the hands, pointables and gestures in this frame.

Source:
  • frame.js, line 370
Returns:

A JSON-formatted string.

Type
String

finger(id) → {Pointable|Pointable.Invalid}

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 186
Returns:

The finger with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.

Type
Pointable | Pointable.Invalid

hand(id) → {Hand|Hand.Invalid}

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 210
Returns:

The Hand object with the matching ID if one exists in this frame; otherwise, an invalid Hand object is returned.

Type
Hand | Hand.Invalid

pointable(id) → {Pointable|Pointable.Invalid}

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 163
Returns:

The Pointable object with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.

Type
Pointable | Pointable.Invalid

rotationAngle(sinceFrame) → {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 Description
sinceFrame Frame

The starting frame for computing the relative rotation.

Source:
  • frame.js, line 232
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) → {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 Frame

The starting frame for computing the relative rotation.

Source:
  • frame.js, line 260
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
Vector

rotationMatrix(sinceFrame) → {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 Frame

The starting frame for computing the relative rotation.

Source:
  • frame.js, line 286
Returns:

A transformation Matrix containing the heuristically determined rotational change between the current frame and that specified in the sinceFrame parameter.

Type
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 Frame

The starting frame for computing the relative scaling.

Source:
  • frame.js, line 310
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) → {Pointable|Pointable.Invalid}

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 139
Returns:

The tool with the matching ID if one exists in this frame; otherwise, an invalid Pointable object is returned.

Type
Pointable | Pointable.Invalid

toString() → {String}

A string containing a brief, human readable description of the Frame object.

Source:
  • frame.js, line 357
Returns:

A brief description of this frame.

Type
String

translation(sinceFrame) → {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 Frame

The starting frame for computing the relative translation.

Source:
  • frame.js, line 331
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
Vector