[4de1c7]: / app / resources / LeapSDK / v3_python27 / src / Finger.cs

Download this file

295 lines (277 with data), 9.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/******************************************************************************\
* Copyright (C) 2012-2016 Leap Motion, Inc. All rights reserved. *
* Leap Motion proprietary and confidential. Not for distribution. *
* Use subject to the terms of the Leap Motion SDK Agreement available at *
* https://developer.leapmotion.com/sdk_agreement, or another agreement *
* between Leap Motion and you, your company or other organization. *
\******************************************************************************/
namespace Leap
{
using System;
using System.Runtime.InteropServices;
/**
* The Finger class represents a tracked finger.
*
* Fingers are objects that the Leap Motion software has classified as a finger.
* Get valid Finger objects from a Frame or a Hand object.
*
* Fingers may be permanently associated to a hand. In this case the angular order of the finger IDs
* will be invariant. As fingers move in and out of view it is possible for the guessed ID
* of a finger to be incorrect. Consequently, it may be necessary for finger IDs to be
* exchanged. All tracked properties, such as velocity, will remain continuous in the API.
* However, quantities that are derived from the API output (such as a history of positions)
* will be discontinuous unless they have a corresponding ID exchange.
* @since 1.0
*/
[Serializable]
public class Finger
{
public Bone[] bones = new Bone[4];
/**
* Constructs a finger.
*
* An uninitialized finger is considered invalid.
* Get valid Finger objects from a Hand object.
*
* @since 3.0
*/
public Finger()
{
bones[0] = new Bone();
bones[1] = new Bone();
bones[2] = new Bone();
bones[3] = new Bone();
}
/**
* Constructs a finger.
*
* Generally, you should not create your own finger objects. Such objects will not
* have valid tracking data. Get valid finger objects from a hand in a frame
* received from the service.
*
* @param frameId The id of the frame this finger appears in.
* @param handId The id of the hand this finger belongs to.
* @param fingerId The id of this finger (handId + 0-4 for finger position).
* @param timeVisible How long this instance of the finger has been visible.
* @param tipPosition The position of the finger tip.
* @param tipVelocity The velocity of the finger tip.
* @param direction The pointing direction of the finger.
* @param stabilizedTipPosition The stabilized tip position.
* @param width The average width of the finger.
* @param length The length of the finger.
* @param isExtended Whether the finger is more-or-less straight.
* @param type The finger name.
* @param metacarpal The first bone of the finger (inside the hand).
* @param proximal The second bone of the finger
* @param intermediate The third bone of the finger.
* @param distal The end bone.
* @since 3.0
*/
public Finger(long frameId,
int handId,
int fingerId,
float timeVisible,
Vector tipPosition,
Vector tipVelocity,
Vector direction,
Vector stabilizedTipPosition,
float width,
float length,
bool isExtended,
Finger.FingerType type,
Bone metacarpal,
Bone proximal,
Bone intermediate,
Bone distal)
{
Type = type;
bones[0] = metacarpal;
bones[1] = proximal;
bones[2] = intermediate;
bones[3] = distal;
Id = (handId * 10) + fingerId;
HandId = handId;
TipPosition = tipPosition;
TipVelocity = tipVelocity;
Direction = direction;
Width = width;
Length = length;
IsExtended = isExtended;
StabilizedTipPosition = stabilizedTipPosition;
TimeVisible = timeVisible;
}
/**
* The bone at a given bone index on this finger.
*
* \include Bone_iteration.txt
*
* @param boneIx An index value from the Bone::Type enumeration identifying the
* bone of interest.
* @returns The Bone that has the specified bone type.
* @since 2.0
*/
public Bone Bone(Bone.BoneType boneIx)
{
return bones[(int)boneIx];
}
/**
* A string containing a brief, human readable description of the Finger object.
*
* \include Finger_toString.txt
*
* @returns A description of the Finger object as a string.
* @since 1.0
*/
public override string ToString()
{
return Enum.GetName(typeof(FingerType), Type) + " id:" + Id;
}
/**
* The name of this finger.
*
* \include Finger_type.txt
*
* @returns The anatomical type of this finger as a member of the Finger::Type
* enumeration.
* @since 2.0
*/
public Finger.FingerType Type;
/**
* A unique ID assigned to this Finger object, whose value remains the
* same across consecutive frames while the tracked finger or tool remains
* visible. If tracking is lost (for example, when a finger is occluded by
* another finger or when it is withdrawn from the Leap Motion Controller field of view), the
* Leap Motion software may assign a new ID when it detects the entity in a future frame.
*
* \include Finger_id.txt
*
* Use the ID value with the Frame::pointable() function to find this
* Finger object in future frames.
*
* IDs should be from 1 to 100 (inclusive). If more than 100 objects are tracked
* an IDs of -1 will be used until an ID in the defined range is available.
*
* @returns The ID assigned to this Finger object.
* @since 1.0
*/
public int Id;
/**
* The Hand associated with a finger.
*
* \include Finger_hand.txt
*
* Not that in version 2+, tools are not associated with hands. For
* tools, this function always returns an invalid Hand object.
*
* @returns The associated Hand object, if available; otherwise,
* an invalid Hand object is returned.
* @since 1.0
*/
public int HandId;
/**
* The tip position in millimeters from the Leap Motion origin.
*
* \include Finger_tipPosition.txt
*
* @returns The Vector containing the coordinates of the tip position.
* @since 1.0
*/
public Vector TipPosition;
/**
* The rate of change of the tip position in millimeters/second.
*
* \include Finger_tipVelocity.txt
*
* @returns The Vector containing the coordinates of the tip velocity.
* @since 1.0
*/
public Vector TipVelocity;
/**
* The direction in which this finger or tool is pointing.
*
* \include Finger_direction.txt
*
* The direction is expressed as a unit vector pointing in the same
* direction as the tip.
*
* \image html images/Leap_Finger_Model.png
*
* @returns The Vector pointing in the same direction as the tip of this
* Finger object.
* @since 1.0
*/
public Vector Direction;
/**
* The estimated width of the finger or tool in millimeters.
*
* \include Finger_width.txt
*
* @returns The estimated width of this Finger object.
* @since 1.0
*/
public float Width;
/**
* The estimated length of the finger or tool in millimeters.
*
* \include Finger_length.txt
*
* @returns The estimated length of this Finger object.
* @since 1.0
*/
public float Length;
/**
* Whether or not this Finger is in an extended posture.
*
* A finger is considered extended if it is extended straight from the hand as if
* pointing. A finger is not extended when it is bent down and curled towards the
* palm. Tools are always extended.
*
* \include Finger_isExtended.txt
*
* @returns True, if the pointable is extended.
* @since 2.0
*/
public bool IsExtended;
/**
* The stabilized tip position of this Finger.
*
* Smoothing and stabilization is performed in order to make
* this value more suitable for interaction with 2D content. The stabilized
* position lags behind the tip position by a variable amount, depending
* primarily on the speed of movement.
*
* \include Finger_stabilizedTipPosition.txt
*
* @returns A modified tip position of this Finger object
* with some additional smoothing and stabilization applied.
* @since 1.0
*/
public Vector StabilizedTipPosition;
/**
* The duration of time this Finger has been visible to the Leap Motion Controller.
*
* \include Finger_timeVisible.txt
*
* @returns The duration (in seconds) that this Finger has been tracked.
* @since 1.0
*/
public float TimeVisible;
/**
* Enumerates the names of the fingers.
*
* Members of this enumeration are returned by Finger::type() to identify a
* Finger object.
* @since 2.0
*/
public enum FingerType
{
TYPE_THUMB = 0,
TYPE_INDEX = 1,
TYPE_MIDDLE = 2,
TYPE_RING = 3,
/** The pinky or little finger */
TYPE_PINKY = 4,
TYPE_UNKNOWN = -1
}
}
}