-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKinectInfo.h
139 lines (117 loc) · 4.23 KB
/
KinectInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*!
* @file KinectInfo.h
* @author Clinton Freeman
* @date 5/14/2011
*
* Initializes Kinect connection.
*
* @todo This file contains two things that represent the same thing: a
* KinectInfo class and a kinectInfo_t struct. I would much prefer
* to use the class since this is the "proper C++ thing to do", but it
* turns out that for a variety of reasons unbeknownst to me at the
* time of this writing, it's a major pain in the ass to do so. It's
* a worthy goal to pursue a conversion to the class form, and most
* of the work should be done.
*/
#ifndef KINECTINFO_H
#define KINECTINFO_H
// OpenNI
#include <XnOpenNI.h>
#include <XnCodecIDs.h>
#include <XnCppWrapper.h>
class KinectInfo
{
static KinectInfo* instance;
xn::Context context;
xn::DepthGenerator depthGenerator;
xn::UserGenerator userGenerator;
XnChar strPose[20];
XnBool bNeedsPose;
XnBool bDrawBackground;
XnBool bDrawPixels;
XnBool bDrawSkeleton;
XnBool bPrintID;
XnBool bPrintState;
XnBool bPaused;
XnBool bRecording;
XnBool bQuit;
XnBool bConnected;
// actual callbacks
void newUser
(xn::UserGenerator& generator, XnUserID nId, void* pCookie);
void lostUser
(xn::UserGenerator& generator, XnUserID nId, void* pCookie);
void poseDetected
(xn::PoseDetectionCapability& capability, const XnChar* strPose,
XnUserID nId, void* pCookie);
void calibrationStart
(xn::SkeletonCapability& capability, XnUserID nId, void* pCookie);
void calibrationEnd
(xn::SkeletonCapability& capability, XnUserID nId, XnBool bSuccess,
void* pCookie);
// wrappers
friend void __stdcall wrapNewUser
(xn::UserGenerator& generator, XnUserID nId, void* pCookie);
friend void __stdcall wrapLostUser
(xn::UserGenerator& generator, XnUserID nId, void* pCookie);
friend void __stdcall wrapPoseDetected
(xn::PoseDetectionCapability& capability, const XnChar* strPose,
XnUserID nId, void* pCookie);
friend void __stdcall wrapCalibrationStart
(xn::SkeletonCapability& capability, XnUserID nId, void* pCookie);
friend void __stdcall wrapCalibrationEnd
(xn::SkeletonCapability& capability, XnUserID nId, XnBool bSuccess,
void* pCookie);
public:
// getters
inline xn::Context& getContext() { return context; }
inline xn::DepthGenerator& getDepthGenerator() { return depthGenerator; }
inline xn::UserGenerator& getUserGenerator() { return userGenerator; }
inline XnBool needsPose() { return bNeedsPose; }
inline XnBool shouldDrawBackground() { return bDrawBackground; }
inline XnBool shouldDrawPixels() { return bDrawPixels; }
inline XnBool shouldDrawSkeleton() { return bDrawSkeleton; }
inline XnBool shouldPrintID() { return bPrintID; }
inline XnBool shouldPrintState() { return bPrintState; }
inline XnBool isPaused() { return bPaused; }
inline XnBool isRecording() { return bRecording; }
inline XnBool shouldQuit() { return bQuit; }
inline XnBool isConnected() { return bConnected; }
// setters
inline void setNeedsPose(XnBool b) { bNeedsPose = b; }
inline void setDrawBackground(XnBool b) { bDrawBackground = b; }
inline void setDrawPixels(XnBool b) { bDrawPixels = b; }
inline void setDrawSkeleton(XnBool b) { bDrawSkeleton = b; }
inline void setPrintID(XnBool b) { bPrintID = b; }
inline void setPrintState(XnBool b) { bPrintState = b; }
inline void setPaused(XnBool b) { bPaused = b; }
inline void setRecording(XnBool b) { bRecording = b; }
inline void setQuit(XnBool b) { bQuit = b; }
inline void setConnected(XnBool b) { bConnected = b; }
static KinectInfo* getInstance();
static void destroyInstance();
protected:
KinectInfo();
~KinectInfo();
};
//extern KinectInfo* kinectInfo;
struct kinectInfo_t
{
xn::Context context;
xn::DepthGenerator depthGenerator;
xn::UserGenerator userGenerator;
XnChar strPose[20];
XnBool bNeedPose;
XnBool bDrawBackground;
XnBool bDrawPixels;
XnBool bDrawSkeleton;
XnBool bPrintID;
XnBool bPrintState;
XnBool bPause;
XnBool bRecord;
XnBool bQuit;
XnBool bConnected;
};
extern kinectInfo_t kinectInfo;
void initKinect();
#endif // KINECTINFO_H