Tanoda
Hand.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9namespace Leap {
10 using System;
11 using System.Collections.Generic;
12
25 [Serializable]
26 public class Hand : IEquatable<Hand> {
27
36 public Hand() {
37 Arm = new Arm();
38 Fingers = new List<Finger>(5);
39 Fingers.Add(new Finger());
40 Fingers.Add(new Finger());
41 Fingers.Add(new Finger());
42 Fingers.Add(new Finger());
43 Fingers.Add(new Finger());
44 }
45
54 public Hand(long frameID,
55 int id,
56 float confidence,
57 float grabStrength,
58 float grabAngle,
59 float pinchStrength,
60 float pinchDistance,
61 float palmWidth,
62 bool isLeft,
63 float timeVisible,
64 Arm arm,
65 List<Finger> fingers,
66 Vector palmPosition,
67 Vector stabilizedPalmPosition,
68 Vector palmVelocity,
69 Vector palmNormal,
70 LeapQuaternion palmOrientation,
71 Vector direction,
72 Vector wristPosition) {
73 FrameId = frameID;
74 Id = id;
75 Confidence = confidence;
76 GrabStrength = grabStrength;
77 GrabAngle = grabAngle;
78 PinchStrength = pinchStrength;
79 PinchDistance = pinchDistance;
80 PalmWidth = palmWidth;
81 IsLeft = isLeft;
82 TimeVisible = timeVisible;
83 Arm = arm;
84 Fingers = fingers;
85 PalmPosition = palmPosition;
86 StabilizedPalmPosition = stabilizedPalmPosition;
87 PalmVelocity = palmVelocity;
88 PalmNormal = palmNormal;
89 Rotation = palmOrientation;
90 Direction = direction;
91 WristPosition = wristPosition;
92 }
93
107 public Finger Finger(int id) {
108 for (int i = Fingers.Count; i-- != 0;) {
109 if (Fingers[i].Id == id) {
110 return Fingers[i];
111 }
112 }
113 return null;
114 }
115
122 public bool Equals(Hand other) {
123 return Id == other.Id && FrameId == other.FrameId;
124 }
125
130 public override string ToString() {
131 return string.Format(
132 "Hand {0} {1}.",
133 this.Id,
134 this.IsLeft ? "left" : "right"
135 );
136 }
137
138 public long FrameId;
139
152 public int Id;
153
159 public List<Finger> Fingers;
160
166
172
185
197
204 public LeapTransform Basis { get { return new LeapTransform(PalmPosition, Rotation); } }
205
212
220 public float GrabStrength;
221
233 public float GrabAngle;
234
243 public float PinchStrength;
244
253 public float PinchDistance;
254
259 public float PalmWidth;
260
271
277
282 public float TimeVisible;
283
290 public float Confidence;
291
296 public bool IsLeft;
297
302 public bool IsRight { get { return !IsLeft; } }
303
311 public Arm Arm;
312 }
313}
The Arm class represents the forearm.
Definition: Arm.cs:16
The Finger class represents a tracked finger.
Definition: Finger.cs:20
The Hand class reports the physical characteristics of a detected hand.
Definition: Hand.cs:26
override string ToString()
A string containing a brief, human readable description of the Hand object.
Definition: Hand.cs:130
Vector WristPosition
The position of the wrist of this hand.
Definition: Hand.cs:276
float PalmWidth
The estimated width of the palm when the hand is in a flat position.
Definition: Hand.cs:259
Vector Direction
The direction from the palm position toward the fingers.
Definition: Hand.cs:196
float PinchStrength
The holding strength of a pinch hand pose.
Definition: Hand.cs:243
Hand(long frameID, int id, float confidence, float grabStrength, float grabAngle, float pinchStrength, float pinchDistance, float palmWidth, bool isLeft, float timeVisible, Arm arm, List< Finger > fingers, Vector palmPosition, Vector stabilizedPalmPosition, Vector palmVelocity, Vector palmNormal, LeapQuaternion palmOrientation, Vector direction, Vector wristPosition)
Constructs a hand.
Definition: Hand.cs:54
LeapTransform Basis
The transform of the hand.
Definition: Hand.cs:204
Vector PalmNormal
The normal vector to the palm. If your hand is flat, this vector will point downward,...
Definition: Hand.cs:184
Finger Finger(int id)
The Finger object with the specified ID attached to this hand.
Definition: Hand.cs:107
long FrameId
Definition: Hand.cs:138
Vector PalmVelocity
The rate of change of the palm position.
Definition: Hand.cs:171
bool IsLeft
Identifies whether this Hand is a left hand.
Definition: Hand.cs:296
Vector StabilizedPalmPosition
The stabilized palm position of this Hand.
Definition: Hand.cs:270
Hand()
Constructs a Hand object.
Definition: Hand.cs:36
float TimeVisible
The duration of time this Hand has been visible to the Leap Motion Controller.
Definition: Hand.cs:282
Arm Arm
The arm to which this hand is attached.
Definition: Hand.cs:311
float PinchDistance
The distance between the thumb and index finger of a pinch hand pose.
Definition: Hand.cs:253
Vector PalmPosition
The center position of the palm.
Definition: Hand.cs:165
int Id
A unique ID assigned to this Hand object, whose value remains the same across consecutive frames whil...
Definition: Hand.cs:152
float Confidence
How confident we are with a given hand pose. The confidence level ranges between 0....
Definition: Hand.cs:290
List< Finger > Fingers
The list of Finger objects detected in this frame that are attached to this hand, given in order from...
Definition: Hand.cs:159
LeapQuaternion Rotation
The rotation of the hand as a quaternion.
Definition: Hand.cs:211
float GrabAngle
The angle between the fingers and the hand of a grab hand pose.
Definition: Hand.cs:233
float GrabStrength
The strength of a grab hand pose.
Definition: Hand.cs:220
bool Equals(Hand other)
Compare Hand object equality.
Definition: Hand.cs:122
bool IsRight
Identifies whether this Hand is a right hand.
Definition: Hand.cs:302
The LeapQuaternion struct represents a rotation in three-dimensional space.
The LeapTransform class represents a transform in three dimensional space.
The Vector struct represents a three-component mathematical vector or point such as a direction or po...
Definition: Vector.cs:36