00001
00002
00003
00004
00005
00006
00007
00008
00009 #if !defined(__Leap_h__)
00010 #define __Leap_h__
00011
00012 #include "LeapMath.h"
00013 #include <string>
00014 #include <vector>
00015 #include <cstring>
00016
00017
00018 #if defined(_MSC_VER) && (_MSC_VER < 1600)
00019 typedef __int32 int32_t;
00020 typedef __int64 int64_t;
00021 typedef unsigned __int32 uint32_t;
00022 typedef unsigned __int64 uint64_t;
00023 #else
00024 #include <stdint.h>
00025 #endif
00026
00027
00028 #if defined(_MSC_VER) // Visual C++
00029 #if LEAP_API_INTERNAL
00030 #define LEAP_EXPORT
00031 #elif LEAP_API_IMPLEMENTATION
00032 #define LEAP_EXPORT __declspec(dllexport)
00033 #else
00034 #define LEAP_EXPORT __declspec(dllimport)
00035 #endif
00036 #define LEAP_EXPORT_CLASS
00037 #define LEAP_EXPORT_PLUGIN __declspec(dllexport)
00038 #elif !defined(SWIG)
00039 #define LEAP_EXPORT __attribute__((visibility("default")))
00040 #define LEAP_EXPORT_CLASS __attribute__((visibility("default")))
00041 #define LEAP_EXPORT_PLUGIN __attribute__((visibility("default")))
00042 #else
00043 #define LEAP_EXPORT
00044 #define LEAP_EXPORT_CLASS
00045 #define LEAP_EXPORT_PLUGIN
00046 #endif
00047
00048 namespace Leap {
00049
00050
00051 class LEAP_EXPORT_CLASS Interface {
00052 public:
00053 struct Implementation {
00054 LEAP_EXPORT virtual ~Implementation() {}
00055 };
00056 protected:
00057 LEAP_EXPORT Interface(void* owner);
00058 LEAP_EXPORT Interface(Implementation* reference, void* owner);
00059 LEAP_EXPORT Interface(const Interface& rhs);
00060 Interface(class SharedObject* object);
00061 LEAP_EXPORT Interface& operator=(const Interface& rhs);
00062 LEAP_EXPORT virtual ~Interface();
00063 template<typename T> T* get() const { return static_cast<T*>(reference()); }
00064 class SharedObject* m_object;
00065 LEAP_EXPORT static void deleteCString(const char* cstr);
00066 private:
00067 LEAP_EXPORT Implementation* reference() const;
00068 };
00069
00070
00071 class PointableImplementation;
00072 class BoneImplementation;
00073 class FingerImplementation;
00074 class ToolImplementation;
00075 class HandImplementation;
00076 class GestureImplementation;
00077 class ScreenImplementation;
00078 class DeviceImplementation;
00079 class ImageImplementation;
00080 class InteractionBoxImplementation;
00081 class BugReportImplementation;
00082 class FrameImplementation;
00083 class ControllerImplementation;
00084 class MaskImplementation;
00085 class TrackedQuadImplementation;
00086 template<typename T> class ListBaseImplementation;
00087
00088
00089 class PointableList;
00090 class FingerList;
00091 class ToolList;
00092 class HandList;
00093 class GestureList;
00094 class ImageList;
00095 class MaskList;
00096 class Hand;
00097 class Gesture;
00098 class Screen;
00099 class InteractionBox;
00100 class Frame;
00101 class Listener;
00102
00129 class Pointable : public Interface {
00130 public:
00131
00137 enum Zone {
00143 ZONE_NONE = 0,
00149 ZONE_HOVERING = 1,
00154 ZONE_TOUCHING = 2,
00155 #ifdef SWIGCSHARP
00156
00157 ZONENONE = ZONE_NONE,
00158 ZONEHOVERING = ZONE_HOVERING,
00159 ZONETOUCHING = ZONE_TOUCHING,
00160 #endif
00161 };
00162
00163
00164 Pointable(PointableImplementation*);
00165
00166 Pointable(FingerImplementation*);
00167
00168 Pointable(ToolImplementation*);
00169
00180 LEAP_EXPORT Pointable();
00181
00200 LEAP_EXPORT int32_t id() const;
00201
00211 LEAP_EXPORT Frame frame() const;
00212
00225 LEAP_EXPORT Hand hand() const;
00226
00235 LEAP_EXPORT Vector tipPosition() const;
00236
00245 LEAP_EXPORT Vector tipVelocity() const;
00246
00261 LEAP_EXPORT Vector direction() const;
00262
00271 LEAP_EXPORT float width() const;
00272
00281 LEAP_EXPORT float length() const;
00282
00291 LEAP_EXPORT bool isFinger() const;
00292
00301 LEAP_EXPORT bool isTool() const;
00302
00315 LEAP_EXPORT bool isExtended() const;
00316
00325 LEAP_EXPORT bool isValid() const;
00326
00353 LEAP_EXPORT Zone touchZone() const;
00354
00376 LEAP_EXPORT float touchDistance() const;
00377
00392 LEAP_EXPORT Vector stabilizedTipPosition() const;
00393
00402 LEAP_EXPORT float timeVisible() const;
00403
00416 LEAP_EXPORT static const Pointable& invalid();
00417
00427 LEAP_EXPORT bool operator==(const Pointable&) const;
00428
00438 LEAP_EXPORT bool operator!=(const Pointable&) const;
00439
00447 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Pointable&);
00448
00455 std::string toString() const {
00456 const char* cstr = toCString();
00457 std::string str(cstr);
00458 deleteCString(cstr);
00459 return str;
00460 }
00461 private:
00462 LEAP_EXPORT const char* toCString() const;
00463
00464 };
00465
00470 class Arm : public Interface {
00471 public:
00472
00473 Arm(HandImplementation*);
00474
00484 LEAP_EXPORT Arm();
00485
00493 LEAP_EXPORT float width() const;
00494
00502 LEAP_EXPORT Vector direction() const;
00503
00534 LEAP_EXPORT Matrix basis() const;
00535
00546 LEAP_EXPORT Vector elbowPosition() const;
00547
00559 LEAP_EXPORT Vector wristPosition() const;
00560
00569 LEAP_EXPORT Vector center() const;
00570
00579 LEAP_EXPORT bool isValid() const;
00580
00589 LEAP_EXPORT static const Arm& invalid();
00590
00600 LEAP_EXPORT bool operator==(const Arm&) const;
00601
00611 LEAP_EXPORT bool operator!=(const Arm&) const;
00612
00620 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Arm&);
00621
00630 std::string toString() const {
00631 const char* cstr = toCString();
00632 std::string str(cstr);
00633 deleteCString(cstr);
00634 return str;
00635 }
00636 private:
00637 LEAP_EXPORT const char* toCString() const;
00638
00639 };
00640
00662 class Bone : public Interface {
00663 public:
00671 enum Type {
00672 TYPE_METACARPAL = 0,
00673 TYPE_PROXIMAL = 1,
00674 TYPE_INTERMEDIATE = 2,
00675 TYPE_DISTAL = 3,
00676 };
00677
00678
00679 Bone(BoneImplementation*);
00680
00690 LEAP_EXPORT Bone();
00691
00702 LEAP_EXPORT Vector prevJoint() const;
00703
00714 LEAP_EXPORT Vector nextJoint() const;
00715
00724 LEAP_EXPORT Vector center() const;
00725
00734 LEAP_EXPORT Vector direction() const;
00735
00744 LEAP_EXPORT float length() const;
00745
00754 LEAP_EXPORT float width() const;
00755
00765 LEAP_EXPORT Type type() const;
00766
00800 LEAP_EXPORT Matrix basis() const;
00801
00810 LEAP_EXPORT bool isValid() const;
00811
00824 LEAP_EXPORT static const Bone& invalid();
00825
00833 LEAP_EXPORT bool operator==(const Bone&) const;
00834
00842 LEAP_EXPORT bool operator!=(const Bone&) const;
00843
00849 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Bone&);
00850
00859 std::string toString() const {
00860 const char* cstr = toCString();
00861 std::string str(cstr);
00862 deleteCString(cstr);
00863 return str;
00864 }
00865
00866 private:
00867 LEAP_EXPORT const char* toCString() const;
00868 };
00869
00891 class Finger : public Pointable {
00892 public:
00896 enum Joint {
00897 JOINT_MCP = 0,
00898 JOINT_PIP = 1,
00899 JOINT_DIP = 2,
00900 JOINT_TIP = 3
00901 };
00902
00910 enum Type {
00911 TYPE_THUMB = 0,
00912 TYPE_INDEX = 1,
00913 TYPE_MIDDLE = 2,
00914 TYPE_RING = 3,
00915 TYPE_PINKY = 4
00916 };
00917
00918
00919 Finger(FingerImplementation*);
00920
00928 LEAP_EXPORT Finger();
00929
00938 LEAP_EXPORT explicit Finger(const Pointable&);
00939
00944 LEAP_EXPORT Vector jointPosition(Joint jointIx) const;
00945
00956 LEAP_EXPORT Bone bone(Bone::Type boneIx) const;
00957
00967 LEAP_EXPORT Type type() const;
00968
00981 LEAP_EXPORT static const Finger& invalid();
00982
00991 std::string toString() const {
00992 const char* cstr = toCString();
00993 std::string str(cstr);
00994 deleteCString(cstr);
00995 return str;
00996 }
00997
00998 private:
00999 LEAP_EXPORT const char* toCString() const;
01000 };
01001
01019 class Tool : public Pointable {
01020 public:
01021
01022 Tool(ToolImplementation*);
01023
01034 LEAP_EXPORT Tool();
01035
01044 LEAP_EXPORT explicit Tool(const Pointable&);
01045
01058 LEAP_EXPORT static const Tool& invalid();
01059
01066 std::string toString() const {
01067 const char* cstr = toCString();
01068 std::string str(cstr);
01069 deleteCString(cstr);
01070 return str;
01071 }
01072
01073 private:
01074 LEAP_EXPORT const char* toCString() const;
01075 };
01076
01096 class Hand : public Interface {
01097 public:
01098
01099 Hand(HandImplementation*);
01100
01111 LEAP_EXPORT Hand();
01112
01128 LEAP_EXPORT int32_t id() const;
01129
01139 LEAP_EXPORT Frame frame() const;
01140
01153 LEAP_EXPORT PointableList pointables() const;
01154
01176 LEAP_EXPORT Pointable pointable(int32_t id) const;
01177
01189 LEAP_EXPORT FingerList fingers() const;
01190
01211 LEAP_EXPORT Finger finger(int32_t id) const;
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01229 LEAP_EXPORT ToolList tools() const;
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01257 LEAP_EXPORT Tool tool(int32_t id) const;
01258
01267 LEAP_EXPORT Vector palmPosition() const;
01268
01283 LEAP_EXPORT Vector stabilizedPalmPosition() const;
01284
01293 LEAP_EXPORT Vector palmVelocity() const;
01294
01312 LEAP_EXPORT Vector palmNormal() const;
01313
01322 LEAP_EXPORT float palmWidth() const;
01323
01338 LEAP_EXPORT Vector direction() const;
01339
01359 LEAP_EXPORT Matrix basis() const;
01360
01372 LEAP_EXPORT Arm arm() const;
01373
01380 LEAP_EXPORT Vector wristPosition() const;
01381
01394 LEAP_EXPORT Vector sphereCenter() const;
01395
01407 LEAP_EXPORT float sphereRadius() const;
01408
01422 LEAP_EXPORT float pinchStrength() const;
01423
01436 LEAP_EXPORT float grabStrength() const;
01437
01457 LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
01458
01475 LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
01476
01496 LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
01497
01519 LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
01520
01543 LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
01544
01562 LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
01563
01580 LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
01581
01606 LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
01607
01624 LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
01625
01634 LEAP_EXPORT float timeVisible() const;
01635
01645 LEAP_EXPORT float confidence() const;
01646
01655 LEAP_EXPORT bool isLeft() const;
01656
01665 LEAP_EXPORT bool isRight() const;
01666
01675 LEAP_EXPORT bool isValid() const;
01676
01689 LEAP_EXPORT static const Hand& invalid();
01690
01700 LEAP_EXPORT bool operator==(const Hand&) const;
01701
01711 LEAP_EXPORT bool operator!=(const Hand&) const;
01712
01720 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Hand&);
01721
01728 std::string toString() const {
01729 const char* cstr = toCString();
01730 std::string str(cstr);
01731 deleteCString(cstr);
01732 return str;
01733 }
01734
01735 private:
01736 LEAP_EXPORT const char* toCString() const;
01737 };
01738
01812 class Gesture : public Interface {
01813 public:
01814
01815 Gesture(GestureImplementation*);
01816
01821 enum Type {
01826 TYPE_INVALID = -1,
01831 TYPE_SWIPE = 1,
01836 TYPE_CIRCLE = 4,
01841 TYPE_SCREEN_TAP = 5,
01846 TYPE_KEY_TAP = 6,
01847 #ifdef SWIGCSHARP
01848
01849 TYPEINVALID = TYPE_INVALID,
01850 TYPESWIPE = TYPE_SWIPE,
01851 TYPECIRCLE = TYPE_CIRCLE,
01852 TYPESCREENTAP = TYPE_SCREEN_TAP,
01853 TYPEKEYTAP = TYPE_KEY_TAP,
01854 #endif
01855 };
01856
01861 enum State {
01866 STATE_INVALID = -1,
01871 STATE_START = 1,
01876 STATE_UPDATE = 2,
01881 STATE_STOP = 3,
01882 #ifdef SWIGCSHARP
01883
01884 STATEINVALID = STATE_INVALID,
01885 STATESTART = STATE_START,
01886 STATEUPDATE = STATE_UPDATE,
01887 STATESTOP = STATE_STOP,
01888 #endif
01889 };
01890
01899 LEAP_EXPORT Gesture();
01900
01908 LEAP_EXPORT Gesture(const Gesture& rhs);
01909
01918 LEAP_EXPORT Type type() const;
01919
01932 LEAP_EXPORT State state() const;
01933
01946 LEAP_EXPORT int32_t id() const;
01947
01962 LEAP_EXPORT int64_t duration() const;
01963
01973 LEAP_EXPORT float durationSeconds() const;
01974
01983 LEAP_EXPORT Frame frame() const;
01984
01995 LEAP_EXPORT HandList hands() const;
01996
02007 LEAP_EXPORT PointableList pointables() const;
02008
02025 LEAP_EXPORT bool isValid() const;
02026
02036 LEAP_EXPORT bool operator==(const Gesture& rhs) const;
02037
02047 LEAP_EXPORT bool operator!=(const Gesture& rhs) const;
02048
02057 std::string toString() const {
02058 const char* cstr = toCString();
02059 std::string str(cstr);
02060 deleteCString(cstr);
02061 return str;
02062 }
02063
02076 LEAP_EXPORT static const Gesture& invalid();
02077
02078 private:
02079 LEAP_EXPORT const char* toCString() const;
02080 };
02081
02119 class SwipeGesture : public Gesture
02120 {
02121 public:
02130 static Type classType() { return TYPE_SWIPE; }
02131
02132 LEAP_EXPORT SwipeGesture();
02133
02143 LEAP_EXPORT SwipeGesture(const Gesture& rhs);
02144
02154 LEAP_EXPORT Vector startPosition() const;
02155
02165 LEAP_EXPORT Vector position() const;
02166
02181 LEAP_EXPORT Vector direction() const;
02182
02192 LEAP_EXPORT float speed() const;
02193
02202 LEAP_EXPORT Pointable pointable() const;
02203 };
02204
02251 class CircleGesture : public Gesture
02252 {
02253 public:
02262 static Type classType() { return TYPE_CIRCLE; }
02263
02271 LEAP_EXPORT CircleGesture();
02272
02282 LEAP_EXPORT CircleGesture(const Gesture& rhs);
02283
02291 LEAP_EXPORT Vector center() const;
02292
02307 LEAP_EXPORT Vector normal() const;
02308
02327 LEAP_EXPORT float progress() const;
02328
02337 LEAP_EXPORT float radius() const;
02338
02347 LEAP_EXPORT Pointable pointable() const;
02348 };
02349
02393 class ScreenTapGesture : public Gesture
02394 {
02395 public:
02404 static Type classType() { return TYPE_SCREEN_TAP; }
02405
02413 LEAP_EXPORT ScreenTapGesture();
02414
02424 LEAP_EXPORT ScreenTapGesture(const Gesture& rhs);
02425
02434 LEAP_EXPORT Vector position() const;
02435
02444 LEAP_EXPORT Vector direction() const;
02445
02452 LEAP_EXPORT float progress() const;
02453
02462 LEAP_EXPORT Pointable pointable() const;
02463 };
02464
02509 class KeyTapGesture : public Gesture
02510 {
02511 public:
02520 static Type classType() { return TYPE_KEY_TAP; }
02521
02529 LEAP_EXPORT KeyTapGesture();
02530
02540 LEAP_EXPORT KeyTapGesture(const Gesture& rhs);
02541
02550 LEAP_EXPORT Vector position() const;
02551
02561 LEAP_EXPORT Vector direction() const;
02562
02569 LEAP_EXPORT float progress() const;
02570
02579 LEAP_EXPORT Pointable pointable() const;
02580 };
02581
02582
02583
02584
02585 class Screen : public Interface {
02586 public:
02587
02588 Screen(ScreenImplementation*);
02589
02590 LEAP_EXPORT Screen();
02591
02592 LEAP_EXPORT int32_t id() const;
02593
02594 LEAP_EXPORT Vector intersect(const Pointable& pointable, bool normalize, float clampRatio = 1.0f) const;
02595
02596 LEAP_EXPORT Vector intersect(const Vector& position, const Vector& direction, bool normalize, float clampRatio = 1.0f) const;
02597
02598 LEAP_EXPORT Vector project(const Vector& position, bool normalize, float clampRatio = 1.0f) const;
02599
02600 LEAP_EXPORT Vector horizontalAxis() const;
02601
02602 LEAP_EXPORT Vector verticalAxis() const;
02603
02604 LEAP_EXPORT Vector bottomLeftCorner() const;
02605
02606 LEAP_EXPORT Vector normal() const;
02607
02608 LEAP_EXPORT int widthPixels() const;
02609
02610 LEAP_EXPORT int heightPixels() const;
02611
02612 LEAP_EXPORT float distanceToPoint(const Vector& point) const;
02613
02614 LEAP_EXPORT bool isValid() const;
02615
02616 LEAP_EXPORT static const Screen& invalid();
02617
02618 LEAP_EXPORT bool operator==(const Screen&) const;
02619
02620 LEAP_EXPORT bool operator!=(const Screen&) const;
02621
02622 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Screen&);
02623
02624 std::string toString() const {
02625 const char* cstr = toCString();
02626 std::string str(cstr);
02627 deleteCString(cstr);
02628 return str;
02629 }
02630
02631 private:
02632 LEAP_EXPORT const char* toCString() const;
02633 };
02634
02651 class Device : public Interface {
02652 public:
02653
02658 enum Type
02659 {
02664 TYPE_PERIPHERAL = 1,
02669 TYPE_LAPTOP,
02674 TYPE_KEYBOARD
02675 };
02676
02677
02678 Device(DeviceImplementation*);
02679
02691 LEAP_EXPORT Device();
02692
02707 LEAP_EXPORT float horizontalViewAngle() const;
02708
02723 LEAP_EXPORT float verticalViewAngle() const;
02724
02738 LEAP_EXPORT float range() const;
02739
02749 LEAP_EXPORT float baseline() const;
02750
02766 LEAP_EXPORT float distanceToBoundary(const Vector& position) const;
02767
02776 LEAP_EXPORT bool isEmbedded() const;
02777
02784 LEAP_EXPORT bool isStreaming() const;
02785
02786
02793 LEAP_EXPORT bool isFlipped() const;
02794
02806 LEAP_EXPORT Type type() const;
02807
02817 std::string serialNumber() const {
02818 const char* cstr = serialNumberCString();
02819 std::string str(cstr);
02820 deleteCString(cstr);
02821 return str;
02822 }
02823
02824
02825
02826
02827
02828
02829
02830
02831
02832
02833 LEAP_EXPORT Vector position() const;
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854 LEAP_EXPORT Matrix orientation() const;
02855
02864 LEAP_EXPORT bool isValid() const;
02865
02878 LEAP_EXPORT static const Device& invalid();
02879
02889 LEAP_EXPORT bool operator==(const Device&) const;
02890
02900 LEAP_EXPORT bool operator!=(const Device&) const;
02901
02909 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Device&);
02910
02917 std::string toString() const {
02918 const char* cstr = toCString();
02919 std::string str(cstr);
02920 deleteCString(cstr);
02921 return str;
02922 }
02923
02924 private:
02925 LEAP_EXPORT const char* toCString() const;
02926 LEAP_EXPORT const char* serialNumberCString() const;
02927 };
02928
02942 class Image : public Interface {
02943 public:
02944
02945
02946 Image(ImageImplementation*);
02947
02958 LEAP_EXPORT Image();
02959
02967 LEAP_EXPORT int64_t sequenceId() const;
02968
02978 LEAP_EXPORT int32_t id() const;
02979
02991 LEAP_EXPORT const unsigned char* data() const;
02992
03029 LEAP_EXPORT const float* distortion() const;
03030
03031
03032
03033
03034
03035
03036
03037
03038 void data(unsigned char* dst) const {
03039 const unsigned char* src = data();
03040 memcpy(dst, src, width() * height() * bytesPerPixel() * sizeof(unsigned char));
03041 }
03042
03043
03044
03045
03046
03047
03048
03049
03050 void distortion(float* dst) const {
03051 const float* src = distortion();
03052 memcpy(dst, src, distortionWidth() * distortionHeight() * sizeof(float));
03053 }
03054
03055
03056
03057
03058
03059 void* dataPointer() const {
03060 return (void*) data();
03061 }
03062
03063
03064
03065
03066
03067 void* distortionPointer() const {
03068 return (void*) distortion();
03069 }
03070
03078 LEAP_EXPORT int width() const;
03079
03087 LEAP_EXPORT int height() const;
03088
03099 LEAP_EXPORT int bytesPerPixel() const;
03100
03107 enum FormatType {
03108 INFRARED = 0
03109 };
03110
03118 LEAP_EXPORT FormatType format() const;
03119
03131 LEAP_EXPORT int distortionWidth() const;
03132
03142 LEAP_EXPORT int distortionHeight() const;
03143
03154 LEAP_EXPORT float rayOffsetX() const;
03155
03166 LEAP_EXPORT float rayOffsetY() const;
03167
03178 LEAP_EXPORT float rayScaleX() const;
03179
03190 LEAP_EXPORT float rayScaleY() const;
03191
03211 LEAP_EXPORT Vector rectify(const Vector& uv) const;
03212
03237 LEAP_EXPORT Vector warp(const Vector& xy) const;
03238
03244 LEAP_EXPORT int64_t timestamp() const;
03245
03252 LEAP_EXPORT bool isValid() const;
03253
03264 LEAP_EXPORT static const Image& invalid();
03265
03273 LEAP_EXPORT bool operator==(const Image&) const;
03274
03283 LEAP_EXPORT bool operator!=(const Image&) const;
03284
03290 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Image&);
03291
03298 std::string toString() const {
03299 const char* cstr = toCString();
03300 std::string str(cstr);
03301 deleteCString(cstr);
03302 return str;
03303 }
03304
03305 private:
03306 LEAP_EXPORT const char* toCString() const;
03307 };
03308
03327 class Mask : public Interface {
03328 public:
03329
03330
03331 Mask(MaskImplementation*);
03332
03339 LEAP_EXPORT Mask();
03340
03347 LEAP_EXPORT int64_t sequenceId() const;
03348
03354 LEAP_EXPORT int32_t id() const;
03355
03365 LEAP_EXPORT const unsigned char* data() const;
03366
03367 void data(unsigned char* dst) const {
03368 const unsigned char* src = data();
03369 memcpy(dst, src, width() * height() * sizeof(unsigned char));
03370 }
03371
03372 void* dataPointer() const {
03373 return (void*) data();
03374 }
03375
03381 LEAP_EXPORT int width() const;
03382
03388 LEAP_EXPORT int height() const;
03389
03395 LEAP_EXPORT int offsetX() const;
03396
03402 LEAP_EXPORT int offsetY() const;
03403
03408 LEAP_EXPORT bool isValid() const;
03409
03413 LEAP_EXPORT static const Mask& invalid();
03414
03418 LEAP_EXPORT bool operator==(const Mask&) const;
03419
03423 LEAP_EXPORT bool operator!=(const Mask&) const;
03424
03428 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Mask&);
03429
03430 std::string toString() const {
03431 const char* cstr = toCString();
03432 std::string str(cstr);
03433 deleteCString(cstr);
03434 return str;
03435 }
03436
03437 private:
03438 LEAP_EXPORT const char* toCString() const;
03439 };
03440
03441
03442 template<typename L, typename T>
03443 class ConstListIterator {
03444 public:
03445 ConstListIterator<L,T>() : m_list(0), m_index(-1) {}
03446 ConstListIterator<L,T>(const L& list, int index) : m_list(&list), m_index(index) {}
03447
03448 const T operator*() const { return (*m_list)[m_index]; }
03449 const ConstListIterator<L,T> operator++(int) { ConstListIterator<L,T> ip(*this); ++m_index; return ip; }
03450 const ConstListIterator<L,T>& operator++() { ++m_index; return *this; }
03451 bool operator!=(const ConstListIterator<L,T>& rhs) const { return m_index != rhs.m_index; }
03452 bool operator==(const ConstListIterator<L,T>& rhs) const { return m_index == rhs.m_index; }
03453
03454 typedef std::ptrdiff_t difference_type;
03455 typedef T value_type;
03456 typedef const T* pointer;
03457 typedef const T& reference;
03458 typedef std::forward_iterator_tag iterator_category;
03459
03460 private:
03461 const L* m_list;
03462 int m_index;
03463 };
03464
03476 class PointableList : public Interface {
03477 public:
03478
03479 PointableList(const ListBaseImplementation<Pointable>&);
03480
03485 LEAP_EXPORT PointableList();
03486
03495 LEAP_EXPORT int count() const;
03496
03505 LEAP_EXPORT bool isEmpty() const;
03506
03516 LEAP_EXPORT Pointable operator[](int index) const;
03517
03524 LEAP_EXPORT PointableList& append(const PointableList& other);
03525
03532 LEAP_EXPORT PointableList& append(const FingerList& other);
03533
03540 LEAP_EXPORT PointableList& append(const ToolList& other);
03541
03551 LEAP_EXPORT Pointable leftmost() const;
03552
03562 LEAP_EXPORT Pointable rightmost() const;
03563
03564
03574 LEAP_EXPORT Pointable frontmost() const;
03575
03583 LEAP_EXPORT PointableList extended() const;
03584
03592 typedef ConstListIterator<PointableList, Pointable> const_iterator;
03593
03601 LEAP_EXPORT const_iterator begin() const;
03602
03610 LEAP_EXPORT const_iterator end() const;
03611 };
03612
03622 class FingerList : public Interface {
03623 public:
03624
03625 FingerList(const ListBaseImplementation<Finger>&);
03626
03631 LEAP_EXPORT FingerList();
03632
03641 LEAP_EXPORT int count() const;
03642
03651 LEAP_EXPORT bool isEmpty() const;
03652
03662 LEAP_EXPORT Finger operator[](int index) const;
03663
03670 LEAP_EXPORT FingerList& append(const FingerList& other);
03671
03681 LEAP_EXPORT Finger leftmost() const;
03682
03692 LEAP_EXPORT Finger rightmost() const;
03693
03703 LEAP_EXPORT Finger frontmost() const;
03704
03714 LEAP_EXPORT FingerList extended() const;
03715
03725 LEAP_EXPORT FingerList fingerType(Finger::Type type) const;
03726
03734 typedef ConstListIterator<FingerList, Finger> const_iterator;
03735
03743 LEAP_EXPORT const_iterator begin() const;
03744
03752 LEAP_EXPORT const_iterator end() const;
03753 };
03754
03764 class ToolList : public Interface {
03765 public:
03766
03767 ToolList(const ListBaseImplementation<Tool>&);
03768
03773 LEAP_EXPORT ToolList();
03774
03783 LEAP_EXPORT int count() const;
03784
03793 LEAP_EXPORT bool isEmpty() const;
03794
03804 LEAP_EXPORT Tool operator[](int index) const;
03805
03812 LEAP_EXPORT ToolList& append(const ToolList& other);
03813
03823 LEAP_EXPORT Tool leftmost() const;
03824
03834 LEAP_EXPORT Tool rightmost() const;
03835
03845 LEAP_EXPORT Tool frontmost() const;
03846
03854 typedef ConstListIterator<ToolList, Tool> const_iterator;
03855
03862 LEAP_EXPORT const_iterator begin() const;
03863
03871 LEAP_EXPORT const_iterator end() const;
03872 };
03873
03883 class HandList : public Interface {
03884 public:
03885
03886 HandList(const ListBaseImplementation<Hand>&);
03887
03892 LEAP_EXPORT HandList();
03893
03901 LEAP_EXPORT int count() const;
03902
03911 LEAP_EXPORT bool isEmpty() const;
03912
03922 LEAP_EXPORT Hand operator[](int index) const;
03923
03929 LEAP_EXPORT HandList& append(const HandList& other);
03930
03942 LEAP_EXPORT Hand leftmost() const;
03943
03955 LEAP_EXPORT Hand rightmost() const;
03956
03966 LEAP_EXPORT Hand frontmost() const;
03967
03975 typedef ConstListIterator<HandList, Hand> const_iterator;
03976
03984 LEAP_EXPORT const_iterator begin() const;
03985
03993 LEAP_EXPORT const_iterator end() const;
03994 };
03995
04002 class GestureList : public Interface {
04003 public:
04004
04005 GestureList(const ListBaseImplementation<Gesture>&);
04006
04011 LEAP_EXPORT GestureList();
04012
04021 LEAP_EXPORT int count() const;
04022
04031 LEAP_EXPORT bool isEmpty() const;
04032
04042 LEAP_EXPORT Gesture operator[](int index) const;
04043
04050 LEAP_EXPORT GestureList& append(const GestureList& other);
04051
04058 typedef ConstListIterator<GestureList, Gesture> const_iterator;
04059
04067 LEAP_EXPORT const_iterator begin() const;
04068
04076 LEAP_EXPORT const_iterator end() const;
04077 };
04078
04079
04080
04081
04082 class ScreenList : public Interface {
04083 public:
04084
04085 ScreenList(const ListBaseImplementation<Screen>&);
04086
04087 LEAP_EXPORT ScreenList();
04088
04089 LEAP_EXPORT int count() const;
04090
04091 LEAP_EXPORT bool isEmpty() const;
04092
04093 LEAP_EXPORT Screen operator[](int index) const;
04094
04095 typedef ConstListIterator<ScreenList, Screen> const_iterator;
04096
04097 LEAP_EXPORT const_iterator begin() const;
04098
04099 LEAP_EXPORT const_iterator end() const;
04100
04101 LEAP_EXPORT Screen closestScreenHit(const Pointable& pointable) const;
04102
04103 LEAP_EXPORT Screen closestScreenHit(const Vector& position, const Vector& direction) const;
04104
04105 LEAP_EXPORT Screen closestScreen(const Vector& position) const;
04106 };
04107
04114 class DeviceList : public Interface {
04115 public:
04116
04117 DeviceList(const ListBaseImplementation<Device>&);
04118
04123 LEAP_EXPORT DeviceList();
04124
04130 LEAP_EXPORT int count() const;
04131
04140 LEAP_EXPORT bool isEmpty() const;
04141
04148 LEAP_EXPORT Device operator[](int index) const;
04149
04156 LEAP_EXPORT DeviceList& append(const DeviceList& other);
04157
04162 typedef ConstListIterator<DeviceList, Device> const_iterator;
04163
04168 LEAP_EXPORT const_iterator begin() const;
04169
04174 LEAP_EXPORT const_iterator end() const;
04175 };
04176
04187 class ImageList : public Interface {
04188 public:
04189
04190 ImageList(const ListBaseImplementation<Image>&);
04191
04196 LEAP_EXPORT ImageList();
04197
04204 LEAP_EXPORT int count() const;
04205
04214 LEAP_EXPORT bool isEmpty() const;
04215
04222 LEAP_EXPORT Image operator[](int index) const;
04223
04230 LEAP_EXPORT ImageList& append(const ImageList& other);
04231
04236 typedef ConstListIterator<ImageList, Image> const_iterator;
04237
04242 LEAP_EXPORT const_iterator begin() const;
04243
04248 LEAP_EXPORT const_iterator end() const;
04249 };
04250
04264 class TrackedQuad : public Interface {
04265 public:
04266
04267
04268 TrackedQuad(TrackedQuadImplementation*);
04269
04277 LEAP_EXPORT TrackedQuad();
04278
04284 LEAP_EXPORT float width() const;
04285
04291 LEAP_EXPORT float height() const;
04292
04299 LEAP_EXPORT int resolutionX() const;
04300
04307 LEAP_EXPORT int resolutionY() const;
04308
04315 LEAP_EXPORT bool visible() const;
04316
04322 LEAP_EXPORT Matrix orientation() const;
04323
04330 LEAP_EXPORT Vector position() const;
04331
04342 LEAP_EXPORT MaskList masks() const;
04343
04351 LEAP_EXPORT ImageList images() const;
04352
04358 LEAP_EXPORT bool isValid() const;
04359
04364 LEAP_EXPORT static const TrackedQuad& invalid();
04365
04370 LEAP_EXPORT bool operator==(const TrackedQuad&) const;
04371
04376 LEAP_EXPORT bool operator!=(const TrackedQuad&) const;
04377
04382 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const TrackedQuad&);
04383
04384 std::string toString() const {
04385 const char* cstr = toCString();
04386 std::string str(cstr);
04387 deleteCString(cstr);
04388 return str;
04389 }
04390
04391 private:
04392 LEAP_EXPORT const char* toCString() const;
04393 };
04394
04402 class MaskList : public Interface {
04403 public:
04404
04405 MaskList(const ListBaseImplementation<Mask>&);
04406
04411 LEAP_EXPORT MaskList();
04412
04417 LEAP_EXPORT int count() const;
04418
04423 LEAP_EXPORT bool isEmpty() const;
04424
04429 LEAP_EXPORT Mask operator[](int index) const;
04430
04435 LEAP_EXPORT MaskList& append(const MaskList& other);
04436
04437 typedef ConstListIterator<MaskList, Mask> const_iterator;
04438
04443 LEAP_EXPORT const_iterator begin() const;
04444
04449 LEAP_EXPORT const_iterator end() const;
04450 };
04451
04469 class InteractionBox : public Interface {
04470 public:
04471
04472 InteractionBox(InteractionBoxImplementation*);
04473
04474 LEAP_EXPORT InteractionBox();
04475
04491 LEAP_EXPORT Vector normalizePoint(const Vector& position, bool clamp = true) const;
04492
04505 LEAP_EXPORT Vector denormalizePoint(const Vector& normalizedPosition) const;
04506
04516 LEAP_EXPORT Vector center() const;
04517
04526 LEAP_EXPORT float width() const;
04527
04536 LEAP_EXPORT float height() const;
04537
04546 LEAP_EXPORT float depth() const;
04547
04556 LEAP_EXPORT bool isValid() const;
04557
04570 LEAP_EXPORT static const InteractionBox& invalid();
04571
04581 LEAP_EXPORT bool operator==(const InteractionBox&) const;
04582
04592 LEAP_EXPORT bool operator!=(const InteractionBox&) const;
04593
04601 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const InteractionBox&);
04602
04609 std::string toString() const {
04610 const char* cstr = toCString();
04611 std::string str(cstr);
04612 deleteCString(cstr);
04613 return str;
04614 }
04615
04616 private:
04617 LEAP_EXPORT const char* toCString() const;
04618 };
04619
04634 class Frame : public Interface {
04635 public:
04636
04637 Frame(FrameImplementation*);
04638
04653 LEAP_EXPORT Frame();
04654
04671 LEAP_EXPORT int64_t id() const;
04672
04684 LEAP_EXPORT int64_t timestamp() const;
04685
04695 LEAP_EXPORT HandList hands() const;
04696
04717 LEAP_EXPORT Hand hand(int32_t id) const;
04718
04730 LEAP_EXPORT PointableList pointables() const;
04731
04752 LEAP_EXPORT Pointable pointable(int32_t id) const;
04753
04765 LEAP_EXPORT FingerList fingers() const;
04766
04787 LEAP_EXPORT Finger finger(int32_t id) const;
04788
04798 LEAP_EXPORT ToolList tools() const;
04799
04820 LEAP_EXPORT Tool tool(int32_t id) const;
04821
04839 LEAP_EXPORT Gesture gesture(int32_t id) const;
04840
04852 LEAP_EXPORT GestureList gestures() const;
04853
04867 LEAP_EXPORT GestureList gestures(const Frame& sinceFrame) const;
04868
04875 LEAP_EXPORT ImageList images() const;
04876
04898 LEAP_EXPORT Vector translation(const Frame& sinceFrame) const;
04899
04915 LEAP_EXPORT float translationProbability(const Frame& sinceFrame) const;
04916
04937 LEAP_EXPORT Vector rotationAxis(const Frame& sinceFrame) const;
04938
04961 LEAP_EXPORT float rotationAngle(const Frame& sinceFrame) const;
04962
04986 LEAP_EXPORT float rotationAngle(const Frame& sinceFrame, const Vector& axis) const;
04987
05006 LEAP_EXPORT Matrix rotationMatrix(const Frame& sinceFrame) const;
05007
05023 LEAP_EXPORT float rotationProbability(const Frame& sinceFrame) const;
05024
05048 LEAP_EXPORT float scaleFactor(const Frame& sinceFrame) const;
05049
05065 LEAP_EXPORT float scaleProbability(const Frame& sinceFrame) const;
05066
05076 LEAP_EXPORT InteractionBox interactionBox() const;
05077
05091 LEAP_EXPORT float currentFramesPerSecond() const;
05092
05112 LEAP_EXPORT bool isValid() const;
05113
05126 LEAP_EXPORT static const Frame& invalid();
05127
05137 LEAP_EXPORT bool operator==(const Frame&) const;
05138
05148 LEAP_EXPORT bool operator!=(const Frame&) const;
05149
05157 LEAP_EXPORT friend std::ostream& operator<<(std::ostream&, const Frame&);
05158
05169 LEAP_EXPORT TrackedQuad trackedQuad() const;
05170
05179 std::string serialize() const {
05180 size_t length = 0;
05181 const char* cstr = serializeCString(length);
05182 std::string str(cstr, length);
05183 deleteCString(cstr);
05184 return str;
05185 }
05186
05214 void deserialize(const std::string& str) {
05215 deserializeCString(str.data(), str.length());
05216 }
05217
05218
05219
05220
05221
05222 void serialize(unsigned char* ptr) const {
05223 size_t length;
05224 const unsigned char* cstr = reinterpret_cast<const unsigned char*>(serializeCString(length));
05225 memcpy(ptr, cstr, length * sizeof(unsigned char));
05226 }
05227
05228
05229
05230
05231
05232
05233 int serializeLength() const {
05234 size_t length = 0;
05235 serializeCString(length);
05236 return static_cast<int>(length);
05237 }
05238
05239
05240
05241
05242
05243 void deserialize(const unsigned char* ptr, int length) {
05244 deserializeCString(reinterpret_cast<const char*>(ptr), static_cast<size_t>(length));
05245 }
05246
05253 std::string toString() const {
05254 const char* cstr = toCString();
05255 std::string str(cstr);
05256 deleteCString(cstr);
05257 return str;
05258 }
05259
05260 private:
05261 LEAP_EXPORT const char* toCString() const;
05262 LEAP_EXPORT const char* serializeCString(size_t& length) const;
05263 LEAP_EXPORT void deserializeCString(const char* str, size_t length);
05264 };
05265
05266
05267 class BugReport : public Interface {
05268 public:
05269
05270 BugReport(BugReportImplementation*);
05271
05272 LEAP_EXPORT BugReport();
05273
05274
05275
05276 LEAP_EXPORT bool beginRecording();
05277
05278 LEAP_EXPORT void endRecording();
05279
05280
05281 LEAP_EXPORT bool isActive() const;
05282
05283
05284 LEAP_EXPORT float progress() const;
05285
05286 LEAP_EXPORT float duration() const;
05287 };
05288
05326 class Config : public Interface {
05327 public:
05337 LEAP_EXPORT Config();
05338
05345 enum ValueType {
05350 TYPE_UNKNOWN = 0,
05355 TYPE_BOOLEAN = 1,
05360 TYPE_INT32 = 2,
05365 TYPE_FLOAT = 6,
05370 TYPE_STRING = 8,
05371 #ifdef SWIGCSHARP
05372
05373 TYPEUNKNOWN = TYPE_UNKNOWN,
05374 TYPEBOOLEAN = TYPE_BOOLEAN,
05375 TYPEINT32 = TYPE_INT32,
05376 TYPEFLOAT = TYPE_FLOAT,
05377 TYPESTRING = TYPE_STRING,
05378 #endif
05379 };
05380
05391 ValueType type(const std::string& key) const {
05392 return typeCString(key.c_str());
05393 }
05394
05402 bool getBool(const std::string& key) const {
05403 return getBoolCString(key.c_str());
05404 }
05405
05413 bool setBool(const std::string& key, bool value) {
05414 return setBoolCString(key.c_str(), value);
05415 }
05416
05424 int32_t getInt32(const std::string& key) const {
05425 return getInt32CString(key.c_str());
05426 }
05427
05435 bool setInt32(const std::string& key, int32_t value) {
05436 return setInt32CString(key.c_str(), value);
05437 }
05438
05446 float getFloat(const std::string& key) const {
05447 return getFloatCString(key.c_str());
05448 }
05449
05457 bool setFloat(const std::string& key, float value) {
05458 return setFloatCString(key.c_str(), value);
05459 }
05460
05468 std::string getString(const std::string& key) const {
05469 const char* cstr = getStringCString(key.c_str());
05470 std::string str(cstr);
05471 deleteCString(cstr);
05472 return str;
05473 }
05474
05482 bool setString(const std::string& key, const std::string& value) {
05483 return setStringCString(key.c_str(), value.c_str());
05484 }
05485
05502 LEAP_EXPORT bool save();
05503 private:
05504 LEAP_EXPORT ValueType typeCString(const char* key) const;
05505 LEAP_EXPORT bool getBoolCString(const char* key) const;
05506 LEAP_EXPORT bool setBoolCString(const char* key, bool value);
05507 LEAP_EXPORT int32_t getInt32CString(const char* key) const;
05508 LEAP_EXPORT bool setInt32CString(const char* key, int32_t value);
05509 LEAP_EXPORT float getFloatCString(const char* key) const;
05510 LEAP_EXPORT bool setFloatCString(const char* key, float value);
05511 LEAP_EXPORT const char* getStringCString(const char* key) const;
05512 LEAP_EXPORT bool setStringCString(const char* key, const char* value);
05513 };
05514
05558 class LEAP_EXPORT_CLASS Controller : public Interface {
05559 public:
05560
05561 Controller(ControllerImplementation*);
05562
05572 LEAP_EXPORT Controller();
05573 LEAP_EXPORT virtual ~Controller();
05587 LEAP_EXPORT Controller(Listener& listener);
05588
05606 LEAP_EXPORT bool isConnected() const;
05607
05613 LEAP_EXPORT bool isServiceConnected() const;
05614
05630 LEAP_EXPORT bool hasFocus() const;
05631
05669 enum PolicyFlag {
05674 POLICY_DEFAULT = 0,
05679 POLICY_BACKGROUND_FRAMES = (1 << 0),
05680
05685 POLICY_IMAGES = (1 << 1),
05686
05691 POLICY_OPTIMIZE_HMD = (1 << 2),
05692
05693 #ifdef SWIGCSHARP
05694
05695 POLICYDEFAULT = POLICY_DEFAULT,
05696 POLICYBACKGROUNDFRAMES = POLICY_BACKGROUND_FRAMES,
05697 #endif
05698 };
05699
05704 LEAP_EXPORT PolicyFlag policyFlags() const;
05705
05710 LEAP_EXPORT void setPolicyFlags(PolicyFlag flags) const;
05711
05729 LEAP_EXPORT void setPolicy(PolicyFlag policy) const;
05730
05744 LEAP_EXPORT void clearPolicy(PolicyFlag policy) const;
05745
05764 LEAP_EXPORT bool isPolicySet(PolicyFlag policy) const;
05765
05787 LEAP_EXPORT bool addListener(Listener& listener);
05788
05801 LEAP_EXPORT bool removeListener(Listener& listener);
05802
05824 LEAP_EXPORT Frame frame(int history = 0) const;
05825
05838 LEAP_EXPORT ImageList images() const;
05839
05849 LEAP_EXPORT Config config() const;
05850
05866 LEAP_EXPORT DeviceList devices() const;
05867
05868
05869
05870
05871 LEAP_EXPORT ScreenList locatedScreens() const;
05872
05873
05874 LEAP_EXPORT BugReport bugReport() const;
05875
05895 LEAP_EXPORT void enableGesture(Gesture::Type type, bool enable = true) const;
05896
05907 LEAP_EXPORT bool isGestureEnabled(Gesture::Type type) const;
05908
05919 LEAP_EXPORT TrackedQuad trackedQuad() const;
05920
05927 LEAP_EXPORT int64_t now() const;
05928 };
05929
05943 class LEAP_EXPORT_CLASS Listener {
05944 public:
05949 LEAP_EXPORT Listener() {}
05950
05954 LEAP_EXPORT virtual ~Listener() {}
05955
05964 LEAP_EXPORT virtual void onInit(const Controller&) {}
05965
05980 LEAP_EXPORT virtual void onConnect(const Controller&) {}
05981
05998 LEAP_EXPORT virtual void onDisconnect(const Controller&) {}
05999
06009 LEAP_EXPORT virtual void onExit(const Controller&) {}
06010
06028 LEAP_EXPORT virtual void onFrame(const Controller&) {}
06029
06042 LEAP_EXPORT virtual void onFocusGained(const Controller&) {}
06043
06056 LEAP_EXPORT virtual void onFocusLost(const Controller&) {}
06057
06058
06059
06060
06061
06070 LEAP_EXPORT virtual void onServiceConnect(const Controller&) {}
06082 LEAP_EXPORT virtual void onServiceDisconnect(const Controller&) {}
06083
06096 LEAP_EXPORT virtual void onDeviceChange(const Controller&) {}
06097
06107 LEAP_EXPORT virtual void onImages(const Controller&) {}
06108
06109 };
06110 }
06111
06112 #endif // __Leap_h__