JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
KinectWin.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef ENABLE_KINECT_SDK
4
5
6#include "KinectDevice.h"
7#include "KinectAudio.h"
8
9#include "NiToolWin.h"
10#include "Rotation.h"
11#include "RingBuffer.h"
12
13#include "NiSpeech.h"
14
15
16//
17namespace jbxwl {
18
19
20
21class CKinectWin
22{
23public:
24 CKinectWin(void);
25 virtual ~CKinectWin(void);
26
27private:
28 CKinectDevice* device;
29 CKinectAudio* audio;
30#ifdef ENABLE_NI_SPEECH
31 CNiSpeech* speech;
32#endif
33
34public:
35 CString m_err_mesg;
36
37 int m_image_scale;
38 int m_depth_scale;
39 int m_skeleton_line;
40
41 BOOL m_is_detected;
42 BOOL m_is_tracking;
43 BOOL m_is_mirroring;
44
45 BOOL m_use_image;
46 BOOL m_use_led;
47 BOOL m_use_motor;
48 BOOL m_use_face;
49 BOOL m_use_speech;
50
51 // 実際に使用できるかどうか.
52 BOOL m_enable_face;
53 BOOL m_enable_speech;
54 BOOL m_enable_motor;
55
56 BOOL m_use_knct_smth;
57
58 int m_profile;
59
60 NUI_TRANSFORM_SMOOTH_PARAMETERS smoothParam;
61
62 double m_confidence;
63 double m_ground_level;
64
65 int tracking_user;
66 int tracking_deny;
67
68public:
69 ExCmnHead* pViewData;
70 ExCmnHead* pDepthData;
71
72 BOOL hasDepthData;
73 BOOL isDetectShadow;
74 BOOL isDetectFace;
75
76public:
77 BOOL init(void);
78 void free(void);
79 void deleteDevice(void);
80
81 CString get_err_message(void); // { return m_err_mesg;}
82
83public:
84 //
85 void clearJointsData(void);
86 void clearAvatarDetected(void);
87 BOOL checkAvatarDetected(void);
88
89 BOOL openUSBDevice(void) { return TRUE;}
90 void closeUSBDevice(void) {}
91 void setLEDColor(int col) {} // { if (m_use_led) set_LEDColor(col);}
92 void setTiltMotor(int ang);
93
94 void setMirroring(BOOL mirror);
95 int getDevState(void) { if (device==NULL) return NI_STATE_DETECT_STOPPED; else return device->m_state;}
96
97 BOOL startDetection(void);
98 BOOL stopDetection(void);
99 BOOL restartDetection(void);
100
101 int getTrackingUser(void) { if (device!=NULL) return device->get_TrackingUser(tracking_deny); else return 0;}
102 void setDenyTrackingSearch(int user) { tracking_deny = user;}
103
104 //
105 Vector4 joint_PositionData(int joint);
106
107 void getJointsPosData(void);
108 void getJointsRotData(void) {}
109
110 //
111 void makeDisplayImage(void);
112 void makeDisplayDepth(CExView* pview);
113 BOOL trackingJoints(void);
114
115 //
116 BOOL detectShadow(void);
117 void paintShadow(void);
118 void drawSkeleton(int col, int line);
119 void drawJointConnection(int j1, int j2, int col, int line);
120 void set2DCoordinate(void);
121
122 //
123 BOOL initRingBuffer(void);
124 void freeRingBuffer(void);
125 void clearRingBuffer(void);
126 void backup2RingBuffer(void);
127
128 Vector4 jointPositionData(int joint);
129
130public:
131 // Face
132 Quaternion<double> getFaceRotation(void);
133
134public:
135#ifdef ENABLE_NI_SPEECH
136 // Speech
137 BOOL initSpeech(void);
138 BOOL createSpeech(LPCTSTR lang, LPCTSTR grfile);
139 BOOL startSpeech(double confidence);
140 void stopSpeech(void);
141 void deleteSpeech(BOOL rls=TRUE); // rls: メンバをリリースするか?
142
143 void setSpeechConfidence(double confd) { if (speech!=NULL) speech->setConfidence(confd);}
144
145 virtual CNiSpeech* makeSpeech(void) { CNiSpeech* spch = new CNiSpeech(); return spch;}
146#endif
147
148public:
149 virtual void saveJointsData(void) {}
150 virtual void loggingJointsData(void) {}
151
152 virtual void checkBoneLength(void) {}
153 virtual void checkGroundLevel(void) {}
154
155 virtual void convertJointsData(void) {}
156 virtual void drawAddition(int col, int line) {}
157
158 virtual void lostTrackingUser(int uid) {}
159 virtual void detectTrackingUser(int uid) {}
160
161 virtual void callback_status_changed(BOOL success, const OLECHAR* instanceName, const OLECHAR* deviceName);
162
163protected:
164 void setDevState(int state) { if (device!=NULL) device->m_state = state;}
165
166public:
167 // Data
168 Vector<double> startPos;
169 Vector<double> currentPos;
170
171 Vector<double> posVect[KINECT_JOINT_NUM];
172 Quaternion<double> rotQuat[KINECT_JOINT_NUM];
173 Vector<int> crdVect[KINECT_JOINT_NUM]; // for 2D Image
174
175 double jntAngl[KINECT_JOINT_NUM]; // angle between joints.
176
177 CRingBuffer posRing[KINECT_JOINT_NUM];
178 CRingBuffer rotRing[KINECT_JOINT_NUM];
179
180// device Iterface
181public:
182 BOOL hasContext(void) { if (device!=NULL && device->context!=NULL) return TRUE; else return FALSE;}
183 BOOL hasImageGen(void) { if (device!=NULL && device->image!=NULL) return TRUE; else return FALSE;}
184 BOOL hasDepthGen(void) { if (device!=NULL && device->depth!=NULL) return TRUE; else return FALSE;}
185
186 BOOL createImage(void) { if (device!=NULL) return device->create_Image(); else return FALSE;}
187 BOOL createDepth(void) { if (device!=NULL) return device->create_Depth(); else return FALSE;}
188 void deleteImage(void) { if (device!=NULL) device->delete_Image();}
189 void deleteDepth(void) { if (device!=NULL) device->delete_Depth();}
190
191
192 BOOL waitImage(void) { if (device!=NULL) return device->wait_Image(); else return FALSE;}
193 BOOL waitDepth(void) { if (device!=NULL) return device->wait_Depth(); else return FALSE;}
194
195 //
196 BOOL faceDetect(FT_VECTOR3D* hint)
197 {
198 if (device!=NULL && device->face!=NULL) return device->face->detect(hint);
199 else return FALSE;
200 }
201
202 void drawFaceRect(ExCmnHead* viewdata, int scale, BOOL mirror, int col, int line)
203 {
204 if (device!=NULL && device->face!=NULL) {
205 device->face->drawFaceRect(pViewData, m_image_scale, m_is_mirroring, col, line);
206 }
207 }
208
209 //
210 int getXSize(void) { if (device!=NULL) return device->m_xsize; else return 0;}
211 int getYSize(void) { if (device!=NULL) return device->m_ysize; else return 0;}
212 int getFPS(void) { if (device!=NULL) return device->m_nfps; else return 0;}
213};
214
215
216
217
219// CallBack
220
221void CALLBACK KinectStatusProc(HRESULT hr, const OLECHAR* instanceName, const OLECHAR* deviceName, void* pUserData);
222
223
224} // namespace
225
226
227#endif
Speech Platform クラス ヘッダ