PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusLeapMotion.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef __vtkPlusLeapMotion_h
8 #define __vtkPlusLeapMotion_h
9 
10 #include "vtkPlusDataCollectionExport.h"
11 #include "vtkPlusDevice.h"
12 
13 // LeapMotion includes
14 #include <LeapC.h>
15 
23 class vtkPlusDataSource;
24 class vtkIGSIORecursiveCriticalSection;
25 
26 class vtkPlusDataCollectionExport vtkPlusLeapMotion : public vtkPlusDevice
27 {
28 public:
29  static vtkPlusLeapMotion* New();
31  void PrintSelf(ostream& os, vtkIndent indent);
32 
33  virtual bool IsTracker() const { return true; }
34 
36  PlusStatus Probe();
37 
39  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* config);
40 
42  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* config);
43 
44  vtkGetMacro(LeapHMDPolicy, bool);
45  vtkSetMacro(LeapHMDPolicy, bool);
46  vtkBooleanMacro(LeapHMDPolicy, bool);
47 
48  vtkGetMacro(RefusePauseResumePolicy, bool);
49  vtkSetMacro(RefusePauseResumePolicy, bool);
50  vtkBooleanMacro(RefusePauseResumePolicy, bool);
51 
52  vtkGetMacro(InvertImage, bool);
53  vtkSetMacro(InvertImage, bool);
54  vtkBooleanMacro(InvertImage, bool);
55 
56 protected:
59 
60  virtual PlusStatus InternalConnect();
62  virtual PlusStatus InternalUpdate();
65  virtual PlusStatus NotifyConfigured();
66 
67  enum Finger
68  {
69  Finger_Thumb, // Yeah yeah... not a finger... hush.
73  Finger_Pinky
74  };
75  enum Bone
76  {
77  Bone_Metacarpal, // Closest to heart
80  Bone_Distal // Furthest from heart (aka, finger tip)
81  };
82  PlusStatus ToolTimeStampedUpdateBone(std::string boneName, eLeapHandType handIndex, Finger fingerIndex, Bone boneIndex);
83  PlusStatus ToolTimeStampedUpdatePalm(const std::string& name, eLeapHandType hand);
84 
85  void SetFrame(const LEAP_TRACKING_EVENT* trackingEvent);
86  LEAP_TRACKING_EVENT* GetFrame();
87  void SetHeadPose(const LEAP_HEAD_POSE_EVENT* headPose);
88  LEAP_HEAD_POSE_EVENT* GetHeadPose();
89 
90 protected:
91  // Leap events
92  PlusStatus OnConnectionEvent(const LEAP_CONNECTION_EVENT* connectionEvent);
93  PlusStatus OnConnectionLostEvent(const LEAP_CONNECTION_LOST_EVENT* connectionLostEvent);
94  PlusStatus OnDeviceEvent(const LEAP_DEVICE_EVENT* deviceEvent);
95  PlusStatus OnDeviceLostEvent(const LEAP_DEVICE_EVENT* deviceEvent);
96  PlusStatus OnDeviceFailureEvent(const LEAP_DEVICE_FAILURE_EVENT* deviceFailureEvent);
97  PlusStatus OnPolicyEvent(const LEAP_POLICY_EVENT* policyEvent);
98  PlusStatus OnTrackingEvent(const LEAP_TRACKING_EVENT* trackingEvent);
99  PlusStatus OnLogEvent(const LEAP_LOG_EVENT* logEvent);
100  PlusStatus OnLogEvents(const LEAP_LOG_EVENTS* logEvents);
101  PlusStatus OnConfigChangeEvent(const LEAP_CONFIG_CHANGE_EVENT* configChangeEvent);
102  PlusStatus OnConfigResponseEvent(const LEAP_CONFIG_RESPONSE_EVENT* configResponseEvent);
103  PlusStatus OnImageEvent(const LEAP_IMAGE_EVENT* imageEvent);
104  PlusStatus OnPointMappingChangeEvent(const LEAP_POINT_MAPPING_CHANGE_EVENT* pointMappingChangeEvent);
105  PlusStatus OnHeadPoseEvent(const LEAP_HEAD_POSE_EVENT* headPoseEvent);
106 
107 protected:
108  std::string ResultToString(eLeapRS);
109  std::string EventToString(_eLeapEventType);
110 
111 protected:
117 
118  LEAP_CONNECTION Connection;
119  unsigned int PollTimeoutMs;
120  LEAP_CONNECTION_MESSAGE LastMessage;
121  LEAP_TRACKING_EVENT LastTrackingEvent;
122  LEAP_HEAD_POSE_EVENT LastHeadPoseEvent;
123 
126 
127  vtkIGSIORecursiveCriticalSection* Mutex;
128 
129 private:
131  void operator=(const vtkPlusLeapMotion&);
132 };
133 
134 #endif
unsigned int PollTimeoutMs
Interface for the LeapMotion hand tracker.
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus InternalStopRecording()
LEAP_CONNECTION Connection
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
LEAP_HEAD_POSE_EVENT LastHeadPoseEvent
LEAP_CONNECTION_MESSAGE LastMessage
virtual PlusStatus InternalConnect()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
vtkPlusDataSource * RightCameraSource
LEAP_TRACKING_EVENT LastTrackingEvent
vtkPlusDataSource * LeftCameraSource
virtual PlusStatus Probe()
virtual bool IsTracker() const
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
virtual PlusStatus InternalStartRecording()
vtkIGSIORecursiveCriticalSection * Mutex
virtual PlusStatus NotifyConfigured()
virtual PlusStatus InternalDisconnect()
virtual PlusStatus InternalUpdate()
static vtkPlusDevice * New()
Interface to a 3D positioning tool, video source, or generalized data stream.