-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeap.h
6047 lines (5605 loc) · 196 KB
/
Leap.h
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************\
* Copyright (C) 2012-2015 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. *
\******************************************************************************/
#if !defined(__Leap_h__)
#define __Leap_h__
#include "LeapMath.h"
#include <string>
#include <vector>
#include <cstring>
// Define integer types for Visual Studio 2008 and earlier
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
// Define Leap export macros
#if defined(_MSC_VER) // Visual C++
#if LEAP_API_INTERNAL
#define LEAP_EXPORT
#elif LEAP_API_IMPLEMENTATION
#define LEAP_EXPORT __declspec(dllexport)
#else
#define LEAP_EXPORT __declspec(dllimport)
#endif
#define LEAP_EXPORT_CLASS
#define LEAP_EXPORT_PLUGIN __declspec(dllexport)
#elif !defined(SWIG)
#define LEAP_EXPORT __attribute__((visibility("default")))
#define LEAP_EXPORT_CLASS __attribute__((visibility("default")))
#define LEAP_EXPORT_PLUGIN __attribute__((visibility("default")))
#else
#define LEAP_EXPORT
#define LEAP_EXPORT_CLASS
#define LEAP_EXPORT_PLUGIN
#endif
namespace Leap {
// Interface for internal use only
class LEAP_EXPORT_CLASS Interface {
public:
struct Implementation {
LEAP_EXPORT virtual ~Implementation() {}
};
protected:
LEAP_EXPORT Interface(void* owner);
LEAP_EXPORT Interface(Implementation* reference, void* owner);
LEAP_EXPORT Interface(const Interface& rhs);
Interface(class SharedObject* object);
LEAP_EXPORT Interface& operator=(const Interface& rhs);
LEAP_EXPORT virtual ~Interface();
template<typename T> T* get() const { return static_cast<T*>(reference()); }
class SharedObject* m_object;
LEAP_EXPORT static void deleteCString(const char* cstr);
private:
LEAP_EXPORT Implementation* reference() const;
};
// Forward declarations for internal use only
class PointableImplementation;
class BoneImplementation;
class FingerImplementation;
class ToolImplementation;
class HandImplementation;
class GestureImplementation;
class ScreenImplementation;
class DeviceImplementation;
class ImageImplementation;
class InteractionBoxImplementation;
class BugReportImplementation;
class FrameImplementation;
class ControllerImplementation;
class MaskImplementation;
class TrackedQuadImplementation;
template<typename T> class ListBaseImplementation;
// Forward declarations
class PointableList;
class FingerList;
class ToolList;
class HandList;
class GestureList;
class ImageList;
class MaskList;
class Hand;
class Gesture;
class Screen;
class InteractionBox;
class Frame;
class Listener;
/**
* The Pointable class reports the physical characteristics of a detected finger or tool.
*
* Both fingers and tools are classified as Pointable objects. Use the Pointable::isFinger()
* function to determine whether a Pointable object represents a finger. Use the
* Pointable::isTool() function to determine whether a Pointable object represents a tool.
* The Leap Motion software classifies a detected entity as a tool when it is thinner, straighter, and longer
* than a typical finger.
*
* \include Pointable_Get_Basic.txt
*
* To provide touch emulation, the Leap Motion software associates a floating touch
* plane that adapts to the user's finger movement and hand posture. The Leap Motion
* interprets purposeful movements toward this plane as potential touch points.
* The Pointable class reports
* touch state with the touchZone and touchDistance values.
*
* Note that Pointable objects can be invalid, which means that they do not contain
* valid tracking data and do not correspond to a physical entity. Invalid Pointable
* objects can be the result of asking for a Pointable object using an ID from an
* earlier frame when no Pointable objects with that ID exist in the current frame.
* A Pointable object created from the Pointable constructor is also invalid.
* Test for validity with the Pointable::isValid() function.
*
* @since 1.0
*/
class Pointable : public Interface {
public:
/**
* Defines the values for reporting the state of a Pointable object in relation to
* an adaptive touch plane.
* @since 1.0
*/
enum Zone {
/**
* The Pointable object is too far from the plane to be
* considered hovering or touching.
* @since 1.0
*/
ZONE_NONE = 0,
/**
* The Pointable object is close to, but not touching
* the plane.
* @since 1.0
*/
ZONE_HOVERING = 1,
/**
* The Pointable has penetrated the plane.
* @since 1.0
*/
ZONE_TOUCHING = 2,
#ifdef SWIGCSHARP
// deprecated
ZONENONE = ZONE_NONE,
ZONEHOVERING = ZONE_HOVERING,
ZONETOUCHING = ZONE_TOUCHING,
#endif
};
// For internal use only.
Pointable(PointableImplementation*);
// For internal use only.
Pointable(FingerImplementation*);
// For internal use only.
Pointable(ToolImplementation*);
/**
* Constructs a Pointable object.
*
* An uninitialized pointable is considered invalid.
* Get valid Pointable objects from a Frame or a Hand object.
*
* \include Pointable_Pointable.txt
*
* @since 1.0
*/
LEAP_EXPORT Pointable();
/**
* A unique ID assigned to this Pointable 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 Pointable_id.txt
*
* Use the ID value with the Frame::pointable() function to find this
* Pointable 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 Pointable object.
* @since 1.0
*/
LEAP_EXPORT int32_t id() const;
/**
* The Frame associated with this Pointable object.
*
* \include Pointable_frame.txt
*
* @returns The associated Frame object, if available; otherwise,
* an invalid Frame object is returned.
* @since 1.0
*/
LEAP_EXPORT Frame frame() const;
/**
* The Hand associated with a finger.
*
* \include Pointable_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
*/
LEAP_EXPORT Hand hand() const;
/**
* The tip position in millimeters from the Leap Motion origin.
*
* \include Pointable_tipPosition.txt
*
* @returns The Vector containing the coordinates of the tip position.
* @since 1.0
*/
LEAP_EXPORT Vector tipPosition() const;
/**
* The rate of change of the tip position in millimeters/second.
*
* \include Pointable_tipVelocity.txt
*
* @returns The Vector containing the coordinates of the tip velocity.
* @since 1.0
*/
LEAP_EXPORT Vector tipVelocity() const;
/**
* The direction in which this finger or tool is pointing.
*
* \include Pointable_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
* Pointable object.
* @since 1.0
*/
LEAP_EXPORT Vector direction() const;
/**
* The estimated width of the finger or tool in millimeters.
*
* \include Pointable_width.txt
*
* @returns The estimated width of this Pointable object.
* @since 1.0
*/
LEAP_EXPORT float width() const;
/**
* The estimated length of the finger or tool in millimeters.
*
* \include Pointable_length.txt
*
* @returns The estimated length of this Pointable object.
* @since 1.0
*/
LEAP_EXPORT float length() const;
/**
* Whether or not this Pointable is classified as a finger.
*
* \include Pointable_Conversion.txt
*
* @returns True, if this Pointable is classified as a finger.
* @since 1.0
*/
LEAP_EXPORT bool isFinger() const;
/**
* Whether or not this Pointable is classified as a tool.
*
* \include Pointable_Conversion.txt
*
* @returns True, if this Pointable is classified as a tool.
* @since 1.0
*/
LEAP_EXPORT bool isTool() const;
/**
* Whether or not this Pointable 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
*/
LEAP_EXPORT bool isExtended() const;
/**
* Reports whether this is a valid Pointable object.
*
* \include Pointable_isValid.txt
*
* @returns True, if this Pointable object contains valid tracking data.
* @since 1.0
*/
LEAP_EXPORT bool isValid() const;
/**
* The current touch zone of this Pointable object.
*
* The Leap Motion software computes the touch zone based on a floating touch
* plane that adapts to the user's finger movement and hand posture. The Leap
* Motion software interprets purposeful movements toward this plane as potential touch
* points. When a Pointable moves close to the adaptive touch plane, it enters the
* "hovering" zone. When a Pointable reaches or passes through the plane, it enters
* the "touching" zone.
*
* The possible states are present in the Zone enum of this class:
*
* **Zone.NONE** -- The Pointable is outside the hovering zone.
*
* **Zone.HOVERING** -- The Pointable is close to, but not touching the touch plane.
*
* **Zone.TOUCHING** -- The Pointable has penetrated the touch plane.
*
* The touchDistance value provides a normalized indication of the distance to
* the touch plane when the Pointable is in the hovering or touching zones.
*
* \include Pointable_touchZone.txt
*
* @returns The touch zone of this Pointable
* @since 1.0
*/
LEAP_EXPORT Zone touchZone() const;
/**
* A value proportional to the distance between this Pointable object and the
* adaptive touch plane.
*
* \image html images/Leap_Touch_Plane.png
*
* The touch distance is a value in the range [-1, 1]. The value 1.0 indicates the
* Pointable is at the far edge of the hovering zone. The value 0 indicates the
* Pointable is just entering the touching zone. A value of -1.0 indicates the
* Pointable is firmly within the touching zone. Values in between are
* proportional to the distance from the plane. Thus, the touchDistance of 0.5
* indicates that the Pointable is halfway into the hovering zone.
*
* \include Pointable_touchDistance.txt
*
* You can use the touchDistance value to modulate visual feedback given to the
* user as their fingers close in on a touch target, such as a button.
*
* @returns The normalized touch distance of this Pointable object.
* @since 1.0
*/
LEAP_EXPORT float touchDistance() const;
/**
* The stabilized tip position of this Pointable.
*
* 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 Pointable_stabilizedTipPosition.txt
*
* @returns A modified tip position of this Pointable object
* with some additional smoothing and stabilization applied.
* @since 1.0
*/
LEAP_EXPORT Vector stabilizedTipPosition() const;
/**
* The duration of time this Pointable has been visible to the Leap Motion Controller.
*
* \include Pointable_timeVisible.txt
*
* @returns The duration (in seconds) that this Pointable has been tracked.
* @since 1.0
*/
LEAP_EXPORT float timeVisible() const;
/**
* Returns an invalid Pointable object.
*
* You can use the instance returned by this function in comparisons testing
* whether a given Pointable instance is valid or invalid. (You can also use the
* Pointable::isValid() function.)
*
* \include Pointable_invalid.txt
*
* @returns The invalid Pointable instance.
* @since 1.0
*/
LEAP_EXPORT static const Pointable& invalid();
/**
* Compare Pointable object equality.
*
* \include Pointable_operator_equals.txt
*
* Two Pointable objects are equal if and only if both Pointable objects represent the
* exact same physical entities in the same frame and both Pointable objects are valid.
* @since 1.0
*/
LEAP_EXPORT bool operator==(const Pointable&) const;
/**
* Compare Pointable object inequality.
*
* \include Pointable_operator_not_equal.txt
*
* Two Pointable objects are equal if and only if both Pointable objects represent the
* exact same physical entities in the same frame and both Pointable objects are valid.
* @since 1.0
*/
LEAP_EXPORT bool operator!=(const Pointable&) const;
/**
* Writes a brief, human readable description of the Pointable object to an output stream.
*
* \include Pointable_operator_stream.txt
*
* @since 1.0
*/
LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Pointable&);
/**
* A string containing a brief, human readable description of the Pointable object.
*
* @returns A description of the Pointable object as a string.
* @since 1.0
*/
std::string toString() const {
const char* cstr = toCString();
std::string str(cstr);
deleteCString(cstr);
return str;
}
private:
LEAP_EXPORT const char* toCString() const;
};
/**
* The Arm class represents the forearm.
*
*/
class Arm : public Interface {
public:
// For internal use only.
Arm(HandImplementation*);
/**
* Constructs an invalid Arm object.
*
* Get valid Arm objects from a Hand object.
*
* \include Arm_get.txt
*
* @since 2.0.3
*/
LEAP_EXPORT Arm();
/**
* The average width of the arm.
*
* \include Arm_width.txt
*
* @since 2.0.3
*/
LEAP_EXPORT float width() const;
/**
* The normalized direction in which the arm is pointing (from elbow to wrist).
*
* \include Arm_direction.txt
*
* @since 2.0.3
*/
LEAP_EXPORT Vector direction() const;
/**
* The orthonormal basis vectors for the Arm bone as a Matrix.
*
* Basis vectors specify the orientation of a bone.
*
* **xBasis** Perpendicular to the longitudinal axis of the
* bone; exits the arm laterally through the sides of the wrist.
*
* **yBasis or up vector** Perpendicular to the longitudinal
* axis of the bone; exits the top and bottom of the arm. More positive
* in the upward direction.
*
* **zBasis** Aligned with the longitudinal axis of the arm bone.
* More positive toward the wrist.
*
* \include Arm_basis.txt
*
* The bases provided for the right arm use the right-hand rule; those for
* the left arm use the left-hand rule. Thus, the positive direction of the
* x-basis is to the right for the right arm and to the left for the left
* arm. You can change from right-hand to left-hand rule by multiplying the
* z basis vector by -1.
*
* Note that converting the basis vectors directly into a quaternion
* representation is not mathematically valid. If you use quaternions,
* create them from the derived rotation matrix not directly from the bases.
*
* @returns The basis of the arm bone as a matrix.
* @since 2.0.3
*/
LEAP_EXPORT Matrix basis() const;
/**
* The position of the elbow.
*
* \include Arm_elbowPosition.txt
*
* If not in view, the elbow position is estimated based on typical human
* anatomical proportions.
*
* @since 2.0.3
*/
LEAP_EXPORT Vector elbowPosition() const;
/**
* The position of the wrist.
*
* \include Arm_wristPosition.txt
*
* Note that the wrist position is not collocated with the end of any bone in
* the hand. There is a gap of a few centimeters since the carpal bones are
* not included in the skeleton model.
*
* @since 2.0.3
*/
LEAP_EXPORT Vector wristPosition() const;
/**
* The center of the forearm.
*
* This location represents the midpoint of the arm between the wrist position
* and the elbow position.
*
* @since 2.1.0
*/
LEAP_EXPORT Vector center() const;
/**
* Reports whether this is a valid Arm object.
*
* \include Arm_isValid.txt
*
* @returns True, if this Arm object contains valid tracking data.
* @since 2.0.3
*/
LEAP_EXPORT bool isValid() const;
/**
* Returns an invalid Arm object.
*
* \include Arm_invalid.txt
*
* @returns The invalid Arm instance.
* @since 2.0.3
*/
LEAP_EXPORT static const Arm& invalid();
/**
* Compare Arm object equality.
*
* \include Arm_operator_equals.txt
*
* Two Arm objects are equal if and only if both Arm objects represent the
* exact same physical arm in the same frame and both Arm objects are valid.
* @since 2.0.3
*/
LEAP_EXPORT bool operator==(const Arm&) const;
/**
* Compare Arm object inequality.
*
* \include Arm_operator_not_equals.txt
*
* Two Arm objects are equal if and only if both Arm objects represent the
* exact same physical arm in the same frame and both Arm objects are valid.
* @since 2.0.3
*/
LEAP_EXPORT bool operator!=(const Arm&) const;
/**
* Writes a brief, human readable description of the Arm object to an output stream.
*
* \include Arm_stream.txt
*
* @since 2.0.3
*/
LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Arm&);
/**
* A string containing a brief, human readable description of the Arm object.
*
* \include Arm_toString.txt
*
* @returns A description of the Arm object as a string.
* @since 2.0.3
*/
std::string toString() const {
const char* cstr = toCString();
std::string str(cstr);
deleteCString(cstr);
return str;
}
private:
LEAP_EXPORT const char* toCString() const;
};
/**
* The Bone class represents a tracked bone.
*
* All fingers contain 4 bones that make up the anatomy of the finger.
* Get valid Bone objects from a Finger object.
*
* Bones are ordered from base to tip, indexed from 0 to 3. Additionally, the
* bone's Type enum may be used to index a specific bone anatomically.
*
* \include Bone_iteration.txt
*
* The thumb does not have a base metacarpal bone and therefore contains a valid,
* zero length bone at that location.
*
* Note that Bone objects can be invalid, which means that they do not contain
* valid tracking data and do not correspond to a physical bone. Invalid Bone
* objects can be the result of asking for a Bone object from an invalid finger,
* indexing a bone out of range, or constructing a new bone.
* Test for validity with the Bone::isValid() function.
* @since 2.0
*/
class Bone : public Interface {
public:
/**
* Enumerates the names of the bones.
*
* Members of this enumeration are returned by Bone::type() to identify a
* Bone object.
* @since 2.0
*/
enum Type {
TYPE_METACARPAL = 0, /**< Bone connected to the wrist inside the palm */
TYPE_PROXIMAL = 1, /**< Bone connecting to the palm */
TYPE_INTERMEDIATE = 2, /**< Bone between the tip and the base*/
TYPE_DISTAL = 3, /**< Bone at the tip of the finger */
};
// For internal use only.
Bone(BoneImplementation*);
/**
* Constructs an invalid Bone object.
*
* \include Bone_invalid.txt
*
* Get valid Bone objects from a Finger object.
*
* @since 2.0
*/
LEAP_EXPORT Bone();
/**
* The base of the bone, closest to the wrist.
*
* In anatomical terms, this is the proximal end of the bone.
* \include Bone_prevJoint.txt
*
* @returns The Vector containing the coordinates of the previous joint position.
* @since 2.0
*/
LEAP_EXPORT Vector prevJoint() const;
/**
* The end of the bone, closest to the finger tip.
*
* In anatomical terms, this is the distal end of the bone.
*
* \include Bone_nextJoint.txt
*
* @returns The Vector containing the coordinates of the next joint position.
* @since 2.0
*/
LEAP_EXPORT Vector nextJoint() const;
/**
* The midpoint of the bone.
*
* \include Bone_center.txt
*
* @returns The midpoint in the center of the bone.
* @since 2.0
*/
LEAP_EXPORT Vector center() const;
/**
* The normalized direction of the bone from base to tip.
*
* \include Bone_direction.txt
*
* @returns The normalized direction of the bone from base to tip.
* @since 2.0
*/
LEAP_EXPORT Vector direction() const;
/**
* The estimated length of the bone in millimeters.
*
* \include Bone_length.txt
*
* @returns The length of the bone in millimeters.
* @since 2.0
*/
LEAP_EXPORT float length() const;
/**
* The average width of the flesh around the bone in millimeters.
*
* \include Bone_width.txt
*
* @returns The width of the flesh around the bone in millimeters.
* @since 2.0
*/
LEAP_EXPORT float width() const;
/**
* The name of this bone.
*
* \include Bone_type.txt
*
* @returns The anatomical type of this bone as a member of the Bone::Type
* enumeration.
* @since 2.0
*/
LEAP_EXPORT Type type() const;
/**
* The orthonormal basis vectors for this Bone as a Matrix.
*
* Basis vectors specify the orientation of a bone.
*
* **xBasis** Perpendicular to the longitudinal axis of the
* bone; exits the sides of the finger.
*
* **yBasis or up vector** Perpendicular to the longitudinal
* axis of the bone; exits the top and bottom of the finger. More positive
* in the upward direction.
*
* **zBasis** Aligned with the longitudinal axis of the bone.
* More positive toward the base of the finger.
*
* The bases provided for the right hand use the right-hand rule; those for
* the left hand use the left-hand rule. Thus, the positive direction of the
* x-basis is to the right for the right hand and to the left for the left
* hand. You can change from right-hand to left-hand rule by multiplying the
* z basis vector by -1.
*
* You can use the basis vectors for such purposes as measuring complex
* finger poses and skeletal animation.
*
* Note that converting the basis vectors directly into a quaternion
* representation is not mathematically valid. If you use quaternions,
* create them from the derived rotation matrix not directly from the bases.
*
* \include Bone_basis.txt
*
* @returns The basis of the bone as a matrix.
* @since 2.0
*/
LEAP_EXPORT Matrix basis() const;
/**
* Reports whether this is a valid Bone object.
*
* \include Bone_isValid.txt
*
* @returns True, if this Bone object contains valid tracking data.
* @since 2.0
*/
LEAP_EXPORT bool isValid() const;
/**
* Returns an invalid Bone object.
*
* You can use the instance returned by this function in comparisons testing
* whether a given Bone instance is valid or invalid. (You can also use the
* Bone::isValid() function.)
*
* \include Bone_invalid.txt
*
* @returns The invalid Bone instance.
* @since 2.0
*/
LEAP_EXPORT static const Bone& invalid();
/**
* Compare Bone object equality.
*
* Two Bone objects are equal if and only if both Bone objects represent the
* exact same physical bone in the same frame and both Bone objects are valid.
* @since 2.0
*/
LEAP_EXPORT bool operator==(const Bone&) const;
/**
* Compare Bone object inequality.
*
* Two Bone objects are equal if and only if both Bone objects represent the
* exact same physical bone in the same frame and both Bone objects are valid.
* @since 2.0
*/
LEAP_EXPORT bool operator!=(const Bone&) const;
/**
* Writes a brief, human readable description of the Bone object to an output stream.
*
* @since 2.0
*/
LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Bone&);
/**
* A string containing a brief, human readable description of the Bone object.
*
* \include Bone_toString.txt
*
* @returns A description of the Bone object as a string.
* @since 2.0
*/
std::string toString() const {
const char* cstr = toCString();
std::string str(cstr);
deleteCString(cstr);
return str;
}
private:
LEAP_EXPORT const char* toCString() const;
};
/**
* The Finger class represents a tracked finger.
*
* Fingers are Pointable 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.
*
* Note that Finger objects can be invalid, which means that they do not contain
* valid tracking data and do not correspond to a physical finger. Invalid Finger
* objects can be the result of asking for a Finger object using an ID from an
* earlier frame when no Finger objects with that ID exist in the current frame.
* A Finger object created from the Finger constructor is also invalid.
* Test for validity with the Finger::isValid() function.
* @since 1.0
*/
class Finger : public Pointable {
public:
/**
* Deprecated as of version 2.0
*/
enum Joint {
JOINT_MCP = 0,
JOINT_PIP = 1,
JOINT_DIP = 2,
JOINT_TIP = 3
};
/**
* Enumerates the names of the fingers.
*
* Members of this enumeration are returned by Finger::type() to identify a
* Finger object.
* @since 2.0
*/
enum Type {
TYPE_THUMB = 0, /**< The thumb */
TYPE_INDEX = 1, /**< The index or fore-finger */
TYPE_MIDDLE = 2, /**< The middle finger */
TYPE_RING = 3, /**< The ring finger */
TYPE_PINKY = 4 /**< The pinky or little finger */
};
// For internal use only.
Finger(FingerImplementation*);
/**
* Constructs a Finger object.
*
* An uninitialized finger is considered invalid.
* Get valid Finger objects from a Frame or a Hand object.
* @since 1.0
*/
LEAP_EXPORT Finger();
/**
* If the specified Pointable object represents a finger, creates a copy
* of it as a Finger object; otherwise, creates an invalid Finger object.
*
* \include Finger_Finger.txt
*
* @since 1.0
*/
LEAP_EXPORT explicit Finger(const Pointable&);
/**
* Deprecated as of version 2.0
* Use 'bone' method instead.
*/
LEAP_EXPORT Vector jointPosition(Joint jointIx) const;
/**
* 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
*/
LEAP_EXPORT Bone bone(Bone::Type boneIx) const;
/**
* 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
*/
LEAP_EXPORT Type type() const;
/**
* Returns an invalid Finger object.
*
* You can use the instance returned by this function in comparisons testing
* whether a given Finger instance is valid or invalid. (You can also use the
* Finger::isValid() function.)
*
* \include Finger_invalid.txt
*
* @returns The invalid Finger instance.
* @since 1.0
*/
LEAP_EXPORT static const Finger& invalid();
/**
* 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
*/
std::string toString() const {
const char* cstr = toCString();
std::string str(cstr);
deleteCString(cstr);
return str;
}
private:
LEAP_EXPORT const char* toCString() const;
};
/**
* The Tool class represents a tracked tool.
*
* Tools are Pointable objects that the Leap Motion software has classified as a tool.
*
* Get valid Tool objects from a Frame object.
*
* \image html images/Leap_Tool.png
*
* Note that Tool objects can be invalid, which means that they do not contain
* valid tracking data and do not correspond to a physical tool. Invalid Tool
* objects can be the result of asking for a Tool object using an ID from an
* earlier frame when no Tool objects with that ID exist in the current frame.
* A Tool object created from the Tool constructor is also invalid.
* Test for validity with the Tool::isValid() function.
* @since 1.0
*/
class Tool : public Pointable {
public:
// For internal use only.
Tool(ToolImplementation*);
/**
* Constructs a Tool object.
*
* An uninitialized tool is considered invalid.
* Get valid Tool objects from a Frame object.
*
* \include Tool_Tool.txt
*
* @since 1.0
*/
LEAP_EXPORT Tool();
/**
* If the specified Pointable object represents a tool, creates a copy
* of it as a Tool object; otherwise, creates an invalid Tool object.
*
* \include Tool_Tool_copy.txt
*
* @since 1.0
*/
LEAP_EXPORT explicit Tool(const Pointable&);
/**
* Returns an invalid Tool object.
*
* You can use the instance returned by this function in comparisons testing
* whether a given Tool instance is valid or invalid. (You can also use the
* Tool::isValid() function.)
*
* \include Tool_invalid.txt
*
* @returns The invalid Tool instance.
* @since 1.0
*/
LEAP_EXPORT static const Tool& invalid();
/**
* A string containing a brief, human readable description of the Tool object.
*
* @returns A description of the Tool object as a string.
* @since 1.0
*/