Nuitrack  1.11.2
3D Skeleton Tracking Middleware
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Events Groups Pages
SkeletonData.h
1 #ifndef NUITRACK_SKELETONDATA_H_
2 #define NUITRACK_SKELETONDATA_H_
3 
4 #include <memory>
5 
6 #include "nuitrack/types/Skeleton.h"
7 #include "nuitrack/types/ObjectData.h"
8 #include "nuitrack/capi/SkeletonTracker_CAPI.h"
9 
10 namespace tdv
11 {
12 namespace nuitrack
13 {
14 
19 class SkeletonData: public ObjectData<SkeletonData>
20 {
21 public:
22  SkeletonData(SkeletonTrackerData* pimpl)
23  {
24  _pimpl = pimpl;
25  nuitrack_AddSkeletonTrackerDataRef(pimpl);
26  }
27 
28  virtual ~SkeletonData()
29  {
30  nuitrack_DestroySkeletonTrackerData(_pimpl);
31  }
32 
38  int getNumSkeletons() const
39  {
40  return nuitrack_GetNumUsers(_pimpl);
41  }
42 
48  const std::vector<Skeleton> getSkeletons() const
49  {
50 
51  SkeletonTrackerData* dataHolder = _pimpl;
52 
53  std::vector<Skeleton> usersVector;
54 
55  size_t numUsers = nuitrack_GetNumUsers(dataHolder);
56  size_t maxJoints = 25;
57 
58  for (size_t i = 0; i < numUsers; i++)
59  {
60  Skeleton skeleton;
61  int id = nuitrack_GetSkeletonID(dataHolder, i);
62  skeleton.id = id;
63 
64  for (size_t j = 0; j < maxJoints; j++)
65  {
66  Joint joint;
67  nuitrack_GetSkeletonJoint(dataHolder, i, (JointType)j, &joint);
68  skeleton.joints.push_back(joint);
69  }
70 
71  usersVector.push_back(skeleton);
72  }
73 
74  return usersVector;
75  }
76 
84  uint64_t getTimestamp() const
85  {
86  return nuitrack_GetSkeletonTrackerTimestamp(_pimpl);
87  }
88 
89 private:
90  SkeletonTrackerData* _pimpl;
91 };
92 
93 }
94 }
95 
96 #endif /* NUITRACK_SKELETONDATA_H_ */
Generalized template for data with a timestamp.
Definition: ObjectData.h:39
const std::vector< Skeleton > getSkeletons() const
Get current user skeletons.
Definition: SkeletonData.h:48
int getNumSkeletons() const
Get current number of skeletons.
Definition: SkeletonData.h:38
Stores the data of all available skeletons at a certain point in time.
Definition: SkeletonData.h:19
uint64_t getTimestamp() const
Returns the data timestamp in microseconds.
Definition: SkeletonData.h:84
Stores the joint data.
Definition: Skeleton.h:56
JointType
Joint index meaning (please note that JOINT_LEFT_FINGERTIP, JOINT_RIGHT_FINGERTIP, JOINT_LEFT_FOOT, JOINT_RIGHT_FOOT are not used in the current version).
Definition: Skeleton.h:18
Stores the data of the skeleton.
Definition: Skeleton.h:108
int id
User Id. The same as other(UserTracker, HandTracker, GestureRecognizer) modules uses.
Definition: Skeleton.h:113
std::vector< Joint > joints
Array of joints. Where each index is ::JointType.
Definition: Skeleton.h:118