Documentation

com.leapmotion.leap.Hand Class Reference

The Hand class reports the physical characteristics of a detected hand. More...

Inherits com.leapmotion.leap.Interface.

Public Member Functions

Vector direction ()
The direction from the palm position toward the fingers.
boolean equals (Hand arg0)
Compare Hand object equality.
Finger finger (int id)
The Finger object with the specified ID attached to this hand.
FingerList fingers ()
The list of Finger objects detected in this frame that are attached to this hand, given in arbitrary order.
Frame frame ()
The Frame associated with this Hand.
Hand ()
Constructs a Hand object.
int id ()
A unique ID assigned to this Hand object, whose value remains the same across consecutive frames while the tracked hand remains visible.
boolean isValid ()
Reports whether this is a valid Hand object.
Vector palmNormal ()
The normal vector to the palm.
Vector palmPosition ()
The center position of the palm in millimeters from the Leap Motion Controller origin.
Vector palmVelocity ()
The rate of change of the palm position in millimeters/second.
Pointable pointable (int id)
The Pointable object with the specified ID associated with this hand.
PointableList pointables ()
The list of Pointable objects (fingers and tools) detected in this frame that are associated with this hand, given in arbitrary order.
float rotationAngle (Frame sinceFrame)
The angle of rotation around the rotation axis derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.
float rotationAngle (Frame sinceFrame, Vector axis)
The angle of rotation around the specified axis derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.
Vector rotationAxis (Frame sinceFrame)
The axis of rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.
Matrix rotationMatrix (Frame sinceFrame)
The transform matrix expressing the rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.
float rotationProbability (Frame sinceFrame)
The estimated probability that the hand motion between the current frame and the specified frame is intended to be a rotating motion.
float scaleFactor (Frame sinceFrame)
The scale factor derived from this hand's motion between the current frame and the specified frame.
float scaleProbability (Frame sinceFrame)
The estimated probability that the hand motion between the current frame and the specified frame is intended to be a scaling motion.
Vector sphereCenter ()
The center of a sphere fit to the curvature of this hand.
float sphereRadius ()
The radius of a sphere fit to the curvature of this hand.
Vector stabilizedPalmPosition ()
The stabilized palm position of this Hand.
float timeVisible ()
The duration of time this Hand has been visible to the Leap Motion Controller.
Tool tool (int id)
The Tool object with the specified ID held by this hand.
ToolList tools ()
The list of Tool objects detected in this frame that are held by this hand, given in arbitrary order.
String toString ()
A string containing a brief, human readable description of the Hand object.
Vector translation (Frame sinceFrame)
The change of position of this hand between the current frame and the specified frame.
float translationProbability (Frame sinceFrame)
The estimated probability that the hand motion between the current frame and the specified frame is intended to be a translating motion.

Static Public Member Functions

static Hand invalid ()
Returns an invalid Hand object.

Detailed Description

The Hand class reports the physical characteristics of a detected hand.

Hand tracking data includes a palm position and velocity; vectors for the palm normal and direction to the fingers; properties of a sphere fit to the hand; and lists of the attached fingers and tools.

Get Hand objects from a Frame object:

Frame frame = controller.frame(); // controller is a Controller object
HandList hands = frame.hands();
Hand firstHand = hands.get(0);

Note that Hand objects can be invalid, which means that they do not contain valid tracking data and do not correspond to a physical entity. Invalid Hand objects can be the result of asking for a Hand object using an ID from an earlier frame when no Hand objects with that ID exist in the current frame. A Hand object created from the Hand constructor is also invalid. Test for validity with the Hand::isValid() function.

Since
1.0

Constructor & Destructor Documentation

com.leapmotion.leap.Hand.Hand ( )

Constructs a Hand object.

An uninitialized hand is considered invalid. Get valid Hand objects from a Frame object.

Hand leftmostHand = frame.hands().leftmost();
Since
1.0

Member Function Documentation

Vector com.leapmotion.leap.Hand.direction ( )

The direction from the palm position toward the fingers.

The direction is expressed as a unit vector pointing in the same direction as the directed line from the palm position to the fingers.

You can use the palm direction vector to compute the pitch and yaw angles of the palm with respect to the horizontal plane:

float pitch = hand.direction().pitch();
float yaw = hand.direction().yaw();
float roll = hand.palmNormal().roll();
Returns
The Vector pointing from the palm position toward the fingers.
Since
1.0
boolean com.leapmotion.leap.Hand.equals ( Hand arg0 )

Compare Hand object equality.

Boolean handIsEqual = thisHand.equals(thatHand);

Two Hand objects are equal if and only if both Hand objects represent the exact same physical hand in the same frame and both Hand objects are valid.

Since
1.0
Finger com.leapmotion.leap.Hand.finger ( int id )

The Finger object with the specified ID attached to this hand.

Use the Hand::finger() function to retrieve a Finger object attached to this hand 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 Finger object is returned.

Finger fingerOnHandByID = hand.finger(fingerID);

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 Finger object representing that finger may have a different ID than that representing the finger in an earlier frame.

Parameters
id The ID value of a Finger object from a previous frame.
Returns
The Finger object with the matching ID if one exists for this hand in this frame; otherwise, an invalid Finger object is returned.
Since
1.0
FingerList com.leapmotion.leap.Hand.fingers ( )

The list of Finger objects 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.

// hand is a Hand object
PointableList pointables = hand.pointables(); // Both fingers and tools
FingerList fingers = hand.fingers();
ToolList tools = hand.tools();
Returns
The FingerList containing all Finger objects attached to this hand.
Since
1.0
Frame com.leapmotion.leap.Hand.frame ( )

The Frame associated with this Hand.

Frame frameForHand = hand.frame();
Returns
The associated Frame object, if available; otherwise, an invalid Frame object is returned.
Since
1.0
int com.leapmotion.leap.Hand.id ( )

A unique ID assigned to this Hand object, whose value remains the same across consecutive frames while the tracked hand remains visible.

If tracking is lost (for example, when a hand is occluded by another hand or when it is withdrawn from or reaches the edge of the Leap Motion Controller field of view), the Leap Motion software may assign a new ID when it detects the hand in a future frame.

Use the ID value with the Frame::hand() function to find this Hand object in future frames:

Hand knownHand = frame.hand(handID);
Returns
The ID of this hand.
Since
1.0
static Hand com.leapmotion.leap.Hand.invalid ( )
static

Returns an invalid Hand object.

if (!hand.equals(Hand.invalid())) {
//Process hand data...
}

You can use the instance returned by this function in comparisons testing whether a given Hand instance is valid or invalid. (You can also use the Hand::isValid() function.)

Returns
The invalid Hand instance.
Since
1.0
boolean com.leapmotion.leap.Hand.isValid ( )

Reports whether this is a valid Hand object.

if (hand.isValid()) {
//Process hand data...
}
Returns
True, if this Hand object contains valid tracking data.
Since
1.0
Vector com.leapmotion.leap.Hand.palmNormal ( )

The normal vector to the palm.

If your hand is flat, this vector will point downward, or "out" of the front surface of your palm.

Leap_Palm_Vectors.png

The direction is expressed as a unit vector pointing in the same direction as the palm normal (that is, a vector orthogonal to the palm).

You can use the palm normal vector to compute the roll angle of the palm with respect to the horizontal plane:

float pitch = hand.direction().pitch();
float yaw = hand.direction().yaw();
float roll = hand.palmNormal().roll();
Returns
The Vector normal to the plane formed by the palm.
Since
1.0
Vector com.leapmotion.leap.Hand.palmPosition ( )

The center position of the palm in millimeters from the Leap Motion Controller origin.

Vector handCenter = hand.palmPosition();
Returns
The Vector representing the coordinates of the palm position.
Since
1.0
Vector com.leapmotion.leap.Hand.palmVelocity ( )

The rate of change of the palm position in millimeters/second.

Vector handSpeed = hand.palmVelocity();
Returns
The Vector representing the coordinates of the palm velocity.
Since
1.0
Pointable com.leapmotion.leap.Hand.pointable ( int id )

The Pointable object with the specified ID associated with this hand.

Use the Hand::pointable() function to retrieve a Pointable object associated with this hand 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.

Pointable knownPointable = hand.pointable(pointableID);

Note that the ID values assigned to objects persist across frames, but only until tracking of that 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
id The ID value of a Pointable object from a previous frame.
Returns
The Pointable object with the matching ID if one exists for this hand in this frame; otherwise, an invalid Pointable object is returned.
Since
1.0
PointableList com.leapmotion.leap.Hand.pointables ( )

The list of Pointable objects (fingers and tools) detected in this frame that are associated with this hand, given in arbitrary order.

The list can be empty if no fingers or tools associated with this hand are detected.

Use the Pointable::isFinger() function to determine whether or not an item in the list represents a finger. Use the Pointable::isTool() function to determine whether or not an item in the list represents a tool. You can also get only fingers using the Hand::fingers() function or only tools using the Hand::tools() function.

// hand is a Hand object
PointableList pointables = hand.pointables(); // Both fingers and tools
FingerList fingers = hand.fingers();
ToolList tools = hand.tools();
Returns
The PointableList containing all Pointable objects associated with this hand.
Since
1.0
float com.leapmotion.leap.Hand.rotationAngle ( Frame sinceFrame )

The angle of rotation around the rotation axis derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

float rotationOfHand = hand.rotationAngle(startFrame);

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).

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then the angle of rotation is zero.

Parameters
sinceFrame The starting frame for computing the relative rotation.
Returns
A positive value representing the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter.
Since
1.0
float com.leapmotion.leap.Hand.rotationAngle ( Frame sinceFrame,
Vector axis
)

The angle of rotation around the specified axis derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

float rotationAroundYAxis = hand.rotationAngle(startFrame, Vector.yAxis());

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 -pi and pi radians (-180 and 180 degrees).

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then the angle of rotation is zero.

Parameters
sinceFrame The starting frame for computing the relative rotation.
axis The axis to measure rotation around.
Returns
A value representing the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter around the specified axis.
Since
1.0
Vector com.leapmotion.leap.Hand.rotationAxis ( Frame sinceFrame )

The axis of rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

Vector axisOfHandRotation = hand.rotationAxis(startFrame);

The returned direction vector is normalized.

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns a zero vector.

Parameters
sinceFrame The starting frame for computing the relative rotation.
Returns
A normalized direction Vector representing the heuristically determined axis of rotational change of the hand between the current frame and that specified in the sinceFrame parameter.
Since
1.0
Matrix com.leapmotion.leap.Hand.rotationMatrix ( Frame sinceFrame )

The transform matrix expressing the rotation derived from the change in orientation of this hand, and any associated fingers and tools, between the current frame and the specified frame.

Matrix handRotationTransform = hand.rotationMatrix(startFrame);

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns an identity matrix.

Parameters
sinceFrame The starting frame for computing the relative rotation.
Returns
A transformation Matrix representing the heuristically determined rotational change of the hand between the current frame and that specified in the sinceFrame parameter.
Since
1.0
float com.leapmotion.leap.Hand.rotationProbability ( Frame sinceFrame )

The estimated probability that the hand motion between the current frame and the specified frame is intended to be a rotating motion.

float rotationIntentFactor = hand.rotationProbability(startFrame);

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns zero.

Parameters
sinceFrame The starting frame for computing the relative rotation.
Returns
A value between 0 and 1 representing the estimated probability that the hand motion between the current frame and the specified frame is intended to be a rotating motion.
Since
1.0
float com.leapmotion.leap.Hand.scaleFactor ( Frame sinceFrame )

The scale factor derived from this hand's 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.

float handScaleMotion = hand.scaleFactor(startFrame);

The Leap Motion software derives scaling from the relative inward or outward motion of a hand and its associated fingers and tools (independent of translation and rotation).

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns 1.0.

Parameters
sinceFrame The starting frame for computing the relative scaling.
Returns
A positive value representing the heuristically determined scaling change ratio of the hand between the current frame and that specified in the sinceFrame parameter.
Since
1.0
float com.leapmotion.leap.Hand.scaleProbability ( Frame sinceFrame )

The estimated probability that the hand motion between the current frame and the specified frame is intended to be a scaling motion.

float scaleIntentFactor = hand.scaleProbability(startFrame);

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns zero.

Parameters
sinceFrame The starting frame for computing the relative scaling.
Returns
A value between 0 and 1 representing the estimated probability that the hand motion between the current frame and the specified frame is intended to be a scaling motion.
Since
1.0
Vector com.leapmotion.leap.Hand.sphereCenter ( )

The center of a sphere fit to the curvature of this hand.

Vector sphereCenter = hand.sphereCenter();

This sphere is placed roughly as if the hand were holding a ball.

Leap_Hand_Ball.png
Returns
The Vector representing the center position of the sphere.
Since
1.0
float com.leapmotion.leap.Hand.sphereRadius ( )

The radius of a sphere fit to the curvature of this hand.

This sphere is placed roughly as if the hand were holding a ball. Thus the size of the sphere decreases as the fingers are curled into a fist.

float sphereDiameter = 2 * hand.sphereRadius();
Returns
The radius of the sphere in millimeters.
Since
1.0
Vector com.leapmotion.leap.Hand.stabilizedPalmPosition ( )

The stabilized palm position of this Hand.

Smoothing and stabilization is performed in order to make this value more suitable for interaction with 2D content. The stabilized position lags behind the palm position by a variable amount, depending primarily on the speed of movement.

Vector filteredHandPosition = hand.stabilizedPalmPosition();
Returns
A modified palm position of this Hand object with some additional smoothing and stabilization applied.
Since
1.0
float com.leapmotion.leap.Hand.timeVisible ( )

The duration of time this Hand has been visible to the Leap Motion Controller.

float lifetimeOfThisHandObject = hand.timeVisible();
Returns
The duration (in seconds) that this Hand has been tracked.
Since
1.0
Tool com.leapmotion.leap.Hand.tool ( int id )

The Tool object with the specified ID held by this hand.

Use the Hand::tool() function to retrieve a Tool object held by this hand using an ID value obtained from a previous frame. This function always returns a Tool object, but if no tool with the specified ID is present, an invalid Tool object is returned.

Tool toolByID = hand.tool(toolID);

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 Tool object representing that tool may have a different ID than that representing the tool in an earlier frame.

Parameters
id The ID value of a Tool object from a previous frame.
Returns
The Tool object with the matching ID if one exists for this hand in this frame; otherwise, an invalid Tool object is returned.
Since
1.0
ToolList com.leapmotion.leap.Hand.tools ( )

The list of Tool objects detected in this frame that are held by this hand, given in arbitrary order.

The list can be empty if no tools held by this hand are detected.

ToolList toolsForHand = hand.tools();
Returns
The ToolList containing all Tool objects held by this hand.
Since
1.0
String com.leapmotion.leap.Hand.toString ( )

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

Returns
A description of the Hand as a string.
Since
1.0
Vector com.leapmotion.leap.Hand.translation ( Frame sinceFrame )

The change of position of this hand between the current frame and the specified frame.

The returned translation vector provides the magnitude and direction of the movement in millimeters.

Vector linearHandMovement = hand.translation(startFrame);

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns a zero vector.

Parameters
sinceFrame The starting frame for computing the translation.
Returns
A Vector representing the heuristically determined change in hand position between the current frame and that specified in the sinceFrame parameter.
Since
1.0
float com.leapmotion.leap.Hand.translationProbability ( Frame sinceFrame )

The estimated probability that the hand motion between the current frame and the specified frame is intended to be a translating motion.

float translationIntentFactor = hand.translationProbability(startFrame);

If a corresponding Hand object is not found in sinceFrame, or if either this frame or sinceFrame are invalid Frame objects, then this method returns zero.

Parameters
sinceFrame The starting frame for computing the translation.
Returns
A value between 0 and 1 representing the estimated probability that the hand motion between the current frame and the specified frame is intended to be a translating motion.
Since
1.0