Nuitrack  1.11.2
3D Skeleton Tracking Middleware
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Events Groups Pages
HandTrackerData.h
1 #ifndef NUITRACK_HANDTRACKERDATA_H_
2 #define NUITRACK_HANDTRACKERDATA_H_
3 
4 #include "nuitrack/types/ObjectData.h"
5 #include "nuitrack/types/Hand.h"
6 #include "nuitrack/capi/HandTracker_CAPI.h"
7 #include <vector>
8 
9 namespace tdv
10 {
11 namespace nuitrack
12 {
17 class HandTrackerData : public ObjectData<HandTrackerData>
18 {
19 public:
21  HandTrackerData(HandTrackerDataInner* pimpl)
22  {
23  _pimpl = pimpl;
24  nuitrack_AddHandTrackerDataRef(_pimpl);
25  }
26 
27  virtual ~HandTrackerData()
28  {
29  nuitrack_DestroyHandTrackerData(_pimpl);
30  }
31 
39  uint64_t getTimestamp() const
40  {
41  return nuitrack_GetHandTrackerDataTimestamp(_pimpl);
42  }
43 
47  int getNumUsers() const
48  {
49  return nuitrack_HandTrackerGetNumUsers(_pimpl);
50  }
51 
57  const std::vector<UserHands> getUsersHands() const
58  {
59  HandTrackerDataInner* dataHolder = _pimpl;
60 
61  size_t numUsers = nuitrack_HandTrackerGetNumUsers(dataHolder);
62 
63  std::vector<UserHands> userHands;
64 
65  int userId = 0;
66  tdv::nuitrack::Hand leftHand;
67  tdv::nuitrack::Hand rightHand;
68  for(size_t i = 0; i < numUsers; i++)
69  {
70  nuitrack_HandTrackerGetUserHands(dataHolder, i, &userId, &leftHand, &rightHand);
71  UserHands newHand;
72  newHand.userId = userId;
73  newHand.leftHand = Hand::Ptr(new tdv::nuitrack::Hand(leftHand));
74  newHand.rightHand = Hand::Ptr(new tdv::nuitrack::Hand(rightHand));
75  userHands.push_back(newHand);
76  }
77 
78  return userHands;
79  }
80 
81 private:
82  HandTrackerDataInner* _pimpl;
83 };
84 
85 } /* namespace nuitrack */
86 } /* namespace tdv */
87 
88 #endif /* NUITRACK_HANDTRACKERDATA_H_ */
Generalized template for data with a timestamp.
Definition: ObjectData.h:39
int getNumUsers() const
Returns the number of users handled by the hand tracker.
Definition: HandTrackerData.h:47
Stores information about the user's hand.
Definition: Hand.h:14
Stores information about the user's hand.
Definition: Hand.h:36
const std::vector< UserHands > getUsersHands() const
Returns information about the hands of the tracked users.
Definition: HandTrackerData.h:57
Hand::Ptr leftHand
User left hand data.
Definition: Hand.h:43
std::shared_ptr< Hand > Ptr
Definition: Hand.h:19
HandTrackerData(HandTrackerDataInner *pimpl)
Definition: HandTrackerData.h:21
uint64_t getTimestamp() const
Returns the data timestamp in microseconds.
Definition: HandTrackerData.h:39
Hand::Ptr rightHand
User right hand data.
Definition: Hand.h:44
Stores hand tracking results related to a specific point in time.
Definition: HandTrackerData.h:17