JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
KinectDevice.h
Go to the documentation of this file.
1#pragma once
2
3
4#ifdef ENABLE_KINECT_SDK
5
6
7#include <NuiApi.h>
8
9#include "ExClass.h"
10#include "Vector.h"
11
12#include "KinectFaceTracker.h"
13
14
15// Lib
16#pragma comment(lib, "Kinect10.lib")
17
18
19/*
20mode:
21 NUI_INITIALIZE_FLAG_USES_COLOR カメライメージ
22 NUI_INITIALIZE_FLAG_USES_DEPTH デプス
23 NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX デプスとユーザーラベル
24 NUI_INITIALIZE_FLAG_USES_SKELETON スケルトン
25*/
26
27
28#define KINECT_JOINT_NUM NUI_SKELETON_POSITION_COUNT // 20
29#define KINECT_USERS_NUM 7
30//#define KINECT_USERS_NUM NUI_SKELETON_COUNT (6)
31
32
33#define KINECT_SKEL_PROFILE_ALL 2 // OpenNIに合わせる
34#define KINECT_SKEL_PROFILE_UPPER 3
35
36
37//
38namespace jbxwl {
39
40//
41// Image クラス
42//
43class CKinectImage : public EventHandler
44{
45public:
46 CKinectImage(void);
47 virtual ~CKinectImage(void) { free();}
48
49public:
50 HANDLE m_stream;
51 uByte* m_data;
52 int m_data_len;
53
54 int m_xsize;
55 int m_ysize;
56 int m_nfps;
57
58public:
59 void free(void);
60 void make_data(void);
61};
62
63
64//
65// Depth クラス
66//
67class CKinectDepth : public EventHandler
68{
69public:
70 CKinectDepth(void);
71 virtual ~CKinectDepth(void) { free();}
72
73public:
74 HANDLE m_stream;
75 uByte* m_data;
76 int m_data_len;
77
78 BOOL has_map;
79 int* m_xmap_i2d;
80 int* m_ymap_i2d;
81 int* m_xmap_d2i;
82 int* m_ymap_d2i;
83 int m_map_len;
84
85 int m_xsize;
86 int m_ysize;
87 int m_nfps;
88
89 int userLabel[KINECT_USERS_NUM];
90
91public:
92 void free(void);
93 void make_data(void);
94 void make_map(void);
95 void delete_map(void);
96 void correct_map(int cx, int cy);
97
98 int get_user_index(int i, int j);
99 uWord get_depth(int i, int j);
100
101 void get_users(void);
102 void get_image_coord(int* i, int* j);
103
104};
105
106
107//
108// Skeleton クラス
109//
110class CKinectSkeleton : public EventHandler
111{
112public:
113 CKinectSkeleton(void);
114 virtual ~CKinectSkeleton(void) { free();}
115
116public:
117 HANDLE m_stream;
118 NUI_SKELETON_DATA m_data;
119
120public:
121 void free(void);
122};
123
124
125
126
128// Device クラス
129
130class CKinectDevice
131{
132public:
133 CKinectDevice(void);
134 virtual ~CKinectDevice(void);
135
136 INuiSensor* context;
137 CKinectImage* image;
138 CKinectDepth* depth;
139 CKinectSkeleton* skeleton;
140 CKinectFaceTracker* face;
141
142 NUI_IMAGE_FRAME imageFrame;
143 NUI_IMAGE_FRAME depthFrame;
144 NUI_SKELETON_FRAME skltnFrame;
145
146 int m_count;
147 int m_state;
148 CString m_err_mesg;
149
150 int m_xsize;
151 int m_ysize;
152 int m_nfps;
153
154 //
155 NUI_TRANSFORM_SMOOTH_PARAMETERS* smoothParam;
156
157 //
158 Vector4 jointPosData[KINECT_JOINT_NUM];
159
160public:
161 BOOL init(DWORD mode, BOOL use_image);
162 void free(void);
163 void clear_JointsData(void);
164
165 BOOL create_Context(DWORD mode, int index=0);
166
167 BOOL create_Image(void);
168 BOOL create_Depth(void);
169 BOOL create_Skeleton(int profile);
170 BOOL create_Face(void);
171
172 void delete_Context(void);
173 void delete_Image(void);
174 void delete_Depth(void);
175 void delete_Skeleton(void);
176 void delete_Face(void);
177
178 BOOL wait_Image(DWORD msec=INFINITE);
179 BOOL wait_Depth(DWORD msec=INFINITE);
180 int wait_Skeleton(int tuser, int duser, DWORD msec=INFINITE); // return tracking user
181
182 BOOL start_Detection(int profile);
183 BOOL stop_Detection(void);
184
185 int get_TrackingUser(int duser);
186
187};
188
189
190} // namespace
191
192
193#endif