SOFA plugin: LeapMotion  master
Open source framework for multi-physics simuation
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Leap::Hand Class Reference

#include <Leap.h>

Inheritance diagram for Leap::Hand:

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.

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.

Public Member Functions

 Hand (HandImplementation *)
 
LEAP_EXPORT Hand ()
 
LEAP_EXPORT int32_t id () const
 
LEAP_EXPORT Frame frame () const
 
LEAP_EXPORT PointableList pointables () const
 
LEAP_EXPORT Pointable pointable (int32_t id) const
 
LEAP_EXPORT FingerList fingers () const
 
LEAP_EXPORT Finger finger (int32_t id) const
 
LEAP_EXPORT ToolList tools () const
 
LEAP_EXPORT Tool tool (int32_t id) const
 
LEAP_EXPORT Vector palmPosition () const
 
LEAP_EXPORT Vector palmVelocity () const
 
LEAP_EXPORT Vector palmNormal () const
 
LEAP_EXPORT Vector direction () const
 
LEAP_EXPORT Vector sphereCenter () const
 
LEAP_EXPORT float sphereRadius () const
 
LEAP_EXPORT Vector translation (const Frame &sinceFrame) const
 
LEAP_EXPORT float translationProbability (const Frame &sinceFrame) const
 
LEAP_EXPORT Vector rotationAxis (const Frame &sinceFrame) const
 
LEAP_EXPORT float rotationAngle (const Frame &sinceFrame) const
 
LEAP_EXPORT float rotationAngle (const Frame &sinceFrame, const Vector &axis) const
 
LEAP_EXPORT Matrix rotationMatrix (const Frame &sinceFrame) const
 
LEAP_EXPORT float rotationProbability (const Frame &sinceFrame) const
 
LEAP_EXPORT float scaleFactor (const Frame &sinceFrame) const
 
LEAP_EXPORT float scaleProbability (const Frame &sinceFrame) const
 
LEAP_EXPORT bool isValid () const
 
LEAP_EXPORT bool operator== (const Hand &) const
 
LEAP_EXPORT bool operator!= (const Hand &) const
 
LEAP_EXPORT std::string toString () const
 

Static Public Member Functions

static LEAP_EXPORT const Handinvalid ()
 

Friends

LEAP_EXPORT friend std::ostream & operator<< (std::ostream &, const Hand &)
 

Additional Inherited Members

- Protected Attributes inherited from Leap::Interface
class SharedObject * m_object
 
- Protected Member Functions inherited from Leap::Interface
LEAP_EXPORT Interface (void *owner)
 
LEAP_EXPORT Interface (Implementation *reference, void *owner)
 
LEAP_EXPORT Interface (const Interface &rhs)
 
LEAP_EXPORT Interfaceoperator= (const Interface &rhs)
 
virtual LEAP_EXPORT ~Interface ()
 
template<typename T >
T * get () const
 

Constructor details

◆ Hand() [1/2]

Leap::Hand::Hand ( HandImplementation *  )

◆ Hand() [2/2]

LEAP_EXPORT Leap::Hand::Hand ( )

Constructs a Hand object.

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

Function details

◆ direction()

LEAP_EXPORT Vector Leap::Hand::direction ( ) const

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.

Returns
The Vector pointing from the palm position toward the fingers.

◆ finger()

LEAP_EXPORT Finger Leap::Hand::finger ( int32_t  id) const

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.

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

◆ fingers()

LEAP_EXPORT FingerList Leap::Hand::fingers ( ) const

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.

Returns
The FingerList containing all Finger objects attached to this hand.

◆ frame()

LEAP_EXPORT Frame Leap::Hand::frame ( ) const

The Frame associated with this Hand.

Returns
The associated Frame object, if available; otherwise, an invalid Frame object is returned.

◆ id()

LEAP_EXPORT int32_t Leap::Hand::id ( ) const

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 field of view), the Leap 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.

Returns
The ID of this hand.

◆ invalid()

static LEAP_EXPORT const Hand& Leap::Hand::invalid ( )
static

Returns an invalid Hand object.

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.

◆ isValid()

LEAP_EXPORT bool Leap::Hand::isValid ( ) const

Reports whether this is a valid Hand object.

Returns
True, if this Hand object contains valid tracking data.

◆ operator!=()

LEAP_EXPORT bool Leap::Hand::operator!= ( const Hand ) const

Compare Hand object inequality. 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.

◆ operator==()

LEAP_EXPORT bool Leap::Hand::operator== ( const Hand ) const

Compare Hand object equality. 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.

◆ palmNormal()

LEAP_EXPORT Vector Leap::Hand::palmNormal ( ) const

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.

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

Returns
The Vector normal to the plane formed by the palm.

◆ palmPosition()

LEAP_EXPORT Vector Leap::Hand::palmPosition ( ) const

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

Returns
The Vector representing the coordinates of the palm position.

◆ palmVelocity()

LEAP_EXPORT Vector Leap::Hand::palmVelocity ( ) const

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

Returns
The Vector representing the coordinates of the palm velocity.

◆ pointable()

LEAP_EXPORT Pointable Leap::Hand::pointable ( int32_t  id) const

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.

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

◆ pointables()

LEAP_EXPORT PointableList Leap::Hand::pointables ( ) const

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.

Returns
The PointableList containing all Pointable objects associated with this hand.

◆ rotationAngle() [1/2]

LEAP_EXPORT float Leap::Hand::rotationAngle ( const Frame sinceFrame) const

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.

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

◆ rotationAngle() [2/2]

LEAP_EXPORT float Leap::Hand::rotationAngle ( const Frame sinceFrame,
const Vector axis 
) const

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.

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
sinceFrameThe starting frame for computing the relative rotation.
axisThe 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.

◆ rotationAxis()

LEAP_EXPORT Vector Leap::Hand::rotationAxis ( const Frame sinceFrame) const

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.

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

◆ rotationMatrix()

LEAP_EXPORT Matrix Leap::Hand::rotationMatrix ( const Frame sinceFrame) const

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.

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

◆ rotationProbability()

LEAP_EXPORT float Leap::Hand::rotationProbability ( const Frame sinceFrame) const

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

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

◆ scaleFactor()

LEAP_EXPORT float Leap::Hand::scaleFactor ( const Frame sinceFrame) const

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.

The Leap 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
sinceFrameThe 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.

◆ scaleProbability()

LEAP_EXPORT float Leap::Hand::scaleProbability ( const Frame sinceFrame) const

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

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

◆ sphereCenter()

LEAP_EXPORT Vector Leap::Hand::sphereCenter ( ) const

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

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

Returns
The Vector representing the center position of the sphere.

◆ sphereRadius()

LEAP_EXPORT float Leap::Hand::sphereRadius ( ) const

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.

Returns
The radius of the sphere in millimeters.

◆ tool()

LEAP_EXPORT Tool Leap::Hand::tool ( int32_t  id) const

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.

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

◆ tools()

LEAP_EXPORT ToolList Leap::Hand::tools ( ) const

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.

Returns
The ToolList containing all Tool objects held by this hand.

◆ toString()

LEAP_EXPORT std::string Leap::Hand::toString ( ) const

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

Returns
A description of the Hand as a string.

◆ translation()

LEAP_EXPORT Vector Leap::Hand::translation ( const Frame sinceFrame) const

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.

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

◆ translationProbability()

LEAP_EXPORT float Leap::Hand::translationProbability ( const Frame sinceFrame) const

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

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

Related details

◆ operator<<

LEAP_EXPORT friend std::ostream& operator<< ( std::ostream &  ,
const Hand  
)
friend

Writes a brief, human readable description of the Hand object to an output stream.