Nuitrack  1.11.2
3D Skeleton Tracking Middleware
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Events Groups Pages
GestureData.h
1 #ifndef NUITRACK_GESTUREDATA_H_
2 #define NUITRACK_GESTUREDATA_H_
3 
4 #include "nuitrack/types/ObjectData.h"
5 #include "nuitrack/types/Gesture.h"
6 #include "nuitrack/capi/GestureRecognizer_CAPI.h"
7 
8 namespace tdv
9 {
10 namespace nuitrack
11 {
16 class GestureData: public ObjectData<GestureData>
17 {
18 public:
20  GestureData(GestureRecognizerData* pimpl)
21  {
22  _pimpl = pimpl;
23  nuitrack_AddGestureRecognizerDataRef(pimpl);
24  }
25 
26  virtual ~GestureData()
27  {
28  nuitrack_DestroyGestureRecognizerData(_pimpl);
29  }
30 
38  uint64_t getTimestamp() const
39  {
40  return nuitrack_GetUserGesturesTimestamp(_pimpl);
41  }
42 
46  int getNumGestures() const
47  {
48  return nuitrack_GetUserGesturesNumGestures(_pimpl);
49  }
50 
56  const std::vector<Gesture> getGestures() const
57  {
58  std::vector<Gesture> gesturesVector;
59 
60  GestureRecognizerData* dataHolder = _pimpl;
61 
62 
63  size_t numUsers = nuitrack_GetUserGesturesNumGestures(dataHolder);
64 
65  for(size_t i = 0; i < numUsers; i++)
66  {
67  Gesture g;
68  nuitrack_GetUserGesture(dataHolder, i, &g);
69  gesturesVector.push_back(g);
70  }
71 
72  return gesturesVector;
73  }
74 
75 private:
76  GestureRecognizerData* _pimpl;
77 };
78 
79 
84 class UserStateData : public ObjectData<UserStateData>
85 {
86 public:
88  UserStateData(UsersStateChanges* pimpl)
89  {
90  _pimpl = pimpl;
91  nuitrack_AddUsersStateChangesRef(pimpl);
92  }
93 
94  virtual ~UserStateData()
95  {
96  nuitrack_DestroyUsersStateChanges(_pimpl);
97  }
98 
102  int getNumUserStates() const
103  {
104  return nuitrack_GetNumUsersStateChanges(_pimpl);
105  }
106 
114  uint64_t getTimestamp() const
115  {
116  return nuitrack_GetUsersStateChangesTimestamp(_pimpl);
117  }
118 
124  const std::vector<UserState> getUserStates() const
125  {
126  std::vector<UserState> usersVector;
127 
128  UsersStateChanges* dataHolder = _pimpl;
129 
130  size_t numUsers = nuitrack_GetNumUsersStateChanges(dataHolder);
131 
132  for(size_t i = 0; i < numUsers; i++)
133  {
134  UserState g;
135  nuitrack_GetUserStateChange(dataHolder, i, &g);
136  usersVector.push_back(g);
137  }
138 
139  return usersVector;
140  }
141 
142 private:
143  UsersStateChanges* _pimpl;
144 };
145 
146 
152 class UserGesturesStateData: public ObjectData<UserGesturesStateData>
153 {
154 public:
156  UserGesturesStateData(GestureRecognizerUserGesturesStateData* pimpl)
157  {
158  _pimpl = pimpl;
159  nuitrack_AddUsersStateDataRef(pimpl);
160  }
161 
162  virtual ~UserGesturesStateData()
163  {
164  nuitrack_DestroyUsersStateData(_pimpl);
165  }
166 
170  int getNumUsers() const
171  {
172  return nuitrack_GetNumUsersGestures(_pimpl);
173  }
174 
182  uint64_t getTimestamp() const
183  {
184  return nuitrack_GetUsersGesturesStateTimestamp(_pimpl);
185  }
186 
192  const std::vector<UserGesturesState> getUserGesturesStates() const
193  {
194  std::vector<UserGesturesState> usersVector;
195 
196  GestureRecognizerUserGesturesStateData* dataHolder = _pimpl;
197 
198 
199  int numUsers = nuitrack_GetNumUsersGestures(dataHolder);
200 
201  for(int i = 0; i < numUsers; i++)
202  {
203  UserGesturesState ugs;
204  UserGesturesState ugsTemp;
205 
206  nuitrack_GetUserStateData(dataHolder, i, &ugsTemp);
207  ugs.userId = ugsTemp.userId;
208  ugs.state = ugsTemp.state;
209 
210  int numGestures = nuitrack_GetNumUserGestureState(dataHolder, i);
211  for(int j = 0; j < numGestures; j++)
212  {
213  GestureState gs;
214  nuitrack_GetUserGestureState(dataHolder, i, j, &gs);
215  ugs.gestures.push_back(gs);
216  }
217 
218  usersVector.push_back(ugs);
219  }
220 
221  return usersVector;
222  }
223 
224 private:
225  GestureRecognizerUserGesturesStateData* _pimpl;
226 };
227 
228 } // namespace nuitrack
229 } // namespace tdv
230 
231 #endif /* NUITRACK_GESTUREDATA_H_ */
Generalized template for data with a timestamp.
Definition: ObjectData.h:39
Stores the results of user state estimation.
Definition: GestureData.h:84
int getNumGestures() const
Returns the number of gestures detected.
Definition: GestureData.h:46
Describes a gesture with a binding to a user.
Definition: Gesture.h:41
UserGesturesStateData(GestureRecognizerUserGesturesStateData *pimpl)
Definition: GestureData.h:156
Stores the results of gesture estimation.
Definition: GestureData.h:16
uint64_t getTimestamp() const
Returns the data timestamp in microseconds.
Definition: GestureData.h:38
UserStateData(UsersStateChanges *pimpl)
Definition: GestureData.h:88
Describes a state of a particular user.
Definition: Gesture.h:58
int getNumUsers() const
Returns the number of tracked users.
Definition: GestureData.h:170
Stores the results of estimation of the state of gestures for every tracked user. ...
Definition: GestureData.h:152
int getNumUserStates() const
Returns the number of user states detected.
Definition: GestureData.h:102
uint64_t getTimestamp() const
Returns the data timestamp in microseconds.
Definition: GestureData.h:114
const std::vector< UserState > getUserStates() const
Returns descriptions of detected states of users.
Definition: GestureData.h:124
const std::vector< Gesture > getGestures() const
Returns descriptions of detected gestures.
Definition: GestureData.h:56
Describes the user's state, supplemented by information about the actions currently being performed...
Definition: Gesture.h:93
const std::vector< UserGesturesState > getUserGesturesStates() const
Returns information about the gestures of the tracked users.
Definition: GestureData.h:192
Describes the state of a gesture.
Definition: Gesture.h:75
GestureData(GestureRecognizerData *pimpl)
Definition: GestureData.h:20
uint64_t getTimestamp() const
Returns the data timestamp in microseconds.
Definition: GestureData.h:182