t1 / TFDContents / Assets / Standard Assets / Windows / Kinect / Body.cs @ 9
이력 | 보기 | 이력해설 | 다운로드 (17.9 KB)
1 |
#if !(UNITY_WSA_10_0 && NETFX_CORE) |
---|---|
2 |
using RootSystem = System; |
3 |
using System.Linq; |
4 |
using System.Collections.Generic; |
5 |
namespace Windows.Kinect |
6 |
{ |
7 |
// |
8 |
// Windows.Kinect.Body |
9 |
// |
10 |
public sealed partial class Body : Helper.INativeWrapper |
11 | |
12 |
{ |
13 |
internal RootSystem.IntPtr _pNative; |
14 |
RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } |
15 | |
16 |
// Constructors and Finalizers |
17 |
internal Body(RootSystem.IntPtr pNative) |
18 |
{ |
19 |
_pNative = pNative; |
20 |
Windows_Kinect_Body_AddRefObject(ref _pNative); |
21 |
} |
22 | |
23 |
~Body() |
24 |
{ |
25 |
Dispose(false); |
26 |
} |
27 | |
28 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
29 |
private static extern void Windows_Kinect_Body_ReleaseObject(ref RootSystem.IntPtr pNative); |
30 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
31 |
private static extern void Windows_Kinect_Body_AddRefObject(ref RootSystem.IntPtr pNative); |
32 |
private void Dispose(bool disposing) |
33 |
{ |
34 |
if (_pNative == RootSystem.IntPtr.Zero) |
35 |
{ |
36 |
return; |
37 |
} |
38 | |
39 |
__EventCleanup(); |
40 | |
41 |
Helper.NativeObjectCache.RemoveObject<Body>(_pNative); |
42 |
Windows_Kinect_Body_ReleaseObject(ref _pNative); |
43 | |
44 |
_pNative = RootSystem.IntPtr.Zero; |
45 |
} |
46 | |
47 | |
48 |
// Public Properties |
49 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
50 |
private static extern int Windows_Kinect_Body_get_Activities(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.Activity[] outKeys, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.DetectionResult[] outValues, int outCollectionSize); |
51 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
52 |
private static extern int Windows_Kinect_Body_get_Activities_Length(RootSystem.IntPtr pNative); |
53 |
public RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Activity, Windows.Kinect.DetectionResult> Activities |
54 |
{ |
55 |
get |
56 |
{ |
57 |
if (_pNative == RootSystem.IntPtr.Zero) |
58 |
{ |
59 |
throw new RootSystem.ObjectDisposedException("Body"); |
60 |
} |
61 | |
62 |
int outCollectionSize = Windows_Kinect_Body_get_Activities_Length(_pNative); |
63 |
var outKeys = new Windows.Kinect.Activity[outCollectionSize]; |
64 |
var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; |
65 |
var managedDictionary = new RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Activity, Windows.Kinect.DetectionResult>(); |
66 | |
67 |
outCollectionSize = Windows_Kinect_Body_get_Activities(_pNative, outKeys, outValues, outCollectionSize); |
68 |
Helper.ExceptionHelper.CheckLastError(); |
69 |
for(int i=0;i<outCollectionSize;i++) |
70 |
{ |
71 |
managedDictionary.Add(outKeys[i], outValues[i]); |
72 |
} |
73 |
return managedDictionary; |
74 |
} |
75 |
} |
76 | |
77 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
78 |
private static extern int Windows_Kinect_Body_get_Appearance(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.Appearance[] outKeys, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.DetectionResult[] outValues, int outCollectionSize); |
79 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
80 |
private static extern int Windows_Kinect_Body_get_Appearance_Length(RootSystem.IntPtr pNative); |
81 |
public RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Appearance, Windows.Kinect.DetectionResult> Appearance |
82 |
{ |
83 |
get |
84 |
{ |
85 |
if (_pNative == RootSystem.IntPtr.Zero) |
86 |
{ |
87 |
throw new RootSystem.ObjectDisposedException("Body"); |
88 |
} |
89 | |
90 |
int outCollectionSize = Windows_Kinect_Body_get_Appearance_Length(_pNative); |
91 |
var outKeys = new Windows.Kinect.Appearance[outCollectionSize]; |
92 |
var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; |
93 |
var managedDictionary = new RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Appearance, Windows.Kinect.DetectionResult>(); |
94 | |
95 |
outCollectionSize = Windows_Kinect_Body_get_Appearance(_pNative, outKeys, outValues, outCollectionSize); |
96 |
Helper.ExceptionHelper.CheckLastError(); |
97 |
for(int i=0;i<outCollectionSize;i++) |
98 |
{ |
99 |
managedDictionary.Add(outKeys[i], outValues[i]); |
100 |
} |
101 |
return managedDictionary; |
102 |
} |
103 |
} |
104 | |
105 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
106 |
private static extern Windows.Kinect.FrameEdges Windows_Kinect_Body_get_ClippedEdges(RootSystem.IntPtr pNative); |
107 |
public Windows.Kinect.FrameEdges ClippedEdges |
108 |
{ |
109 |
get |
110 |
{ |
111 |
if (_pNative == RootSystem.IntPtr.Zero) |
112 |
{ |
113 |
throw new RootSystem.ObjectDisposedException("Body"); |
114 |
} |
115 | |
116 |
return Windows_Kinect_Body_get_ClippedEdges(_pNative); |
117 |
} |
118 |
} |
119 | |
120 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
121 |
private static extern Windows.Kinect.DetectionResult Windows_Kinect_Body_get_Engaged(RootSystem.IntPtr pNative); |
122 |
public Windows.Kinect.DetectionResult Engaged |
123 |
{ |
124 |
get |
125 |
{ |
126 |
if (_pNative == RootSystem.IntPtr.Zero) |
127 |
{ |
128 |
throw new RootSystem.ObjectDisposedException("Body"); |
129 |
} |
130 | |
131 |
return Windows_Kinect_Body_get_Engaged(_pNative); |
132 |
} |
133 |
} |
134 | |
135 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
136 |
private static extern int Windows_Kinect_Body_get_Expressions(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.Expression[] outKeys, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.DetectionResult[] outValues, int outCollectionSize); |
137 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
138 |
private static extern int Windows_Kinect_Body_get_Expressions_Length(RootSystem.IntPtr pNative); |
139 |
public RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Expression, Windows.Kinect.DetectionResult> Expressions |
140 |
{ |
141 |
get |
142 |
{ |
143 |
if (_pNative == RootSystem.IntPtr.Zero) |
144 |
{ |
145 |
throw new RootSystem.ObjectDisposedException("Body"); |
146 |
} |
147 | |
148 |
int outCollectionSize = Windows_Kinect_Body_get_Expressions_Length(_pNative); |
149 |
var outKeys = new Windows.Kinect.Expression[outCollectionSize]; |
150 |
var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; |
151 |
var managedDictionary = new RootSystem.Collections.Generic.Dictionary<Windows.Kinect.Expression, Windows.Kinect.DetectionResult>(); |
152 | |
153 |
outCollectionSize = Windows_Kinect_Body_get_Expressions(_pNative, outKeys, outValues, outCollectionSize); |
154 |
Helper.ExceptionHelper.CheckLastError(); |
155 |
for(int i=0;i<outCollectionSize;i++) |
156 |
{ |
157 |
managedDictionary.Add(outKeys[i], outValues[i]); |
158 |
} |
159 |
return managedDictionary; |
160 |
} |
161 |
} |
162 | |
163 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
164 |
private static extern Windows.Kinect.TrackingConfidence Windows_Kinect_Body_get_HandLeftConfidence(RootSystem.IntPtr pNative); |
165 |
public Windows.Kinect.TrackingConfidence HandLeftConfidence |
166 |
{ |
167 |
get |
168 |
{ |
169 |
if (_pNative == RootSystem.IntPtr.Zero) |
170 |
{ |
171 |
throw new RootSystem.ObjectDisposedException("Body"); |
172 |
} |
173 | |
174 |
return Windows_Kinect_Body_get_HandLeftConfidence(_pNative); |
175 |
} |
176 |
} |
177 | |
178 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
179 |
private static extern Windows.Kinect.HandState Windows_Kinect_Body_get_HandLeftState(RootSystem.IntPtr pNative); |
180 |
public Windows.Kinect.HandState HandLeftState |
181 |
{ |
182 |
get |
183 |
{ |
184 |
if (_pNative == RootSystem.IntPtr.Zero) |
185 |
{ |
186 |
throw new RootSystem.ObjectDisposedException("Body"); |
187 |
} |
188 | |
189 |
return Windows_Kinect_Body_get_HandLeftState(_pNative); |
190 |
} |
191 |
} |
192 | |
193 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
194 |
private static extern Windows.Kinect.TrackingConfidence Windows_Kinect_Body_get_HandRightConfidence(RootSystem.IntPtr pNative); |
195 |
public Windows.Kinect.TrackingConfidence HandRightConfidence |
196 |
{ |
197 |
get |
198 |
{ |
199 |
if (_pNative == RootSystem.IntPtr.Zero) |
200 |
{ |
201 |
throw new RootSystem.ObjectDisposedException("Body"); |
202 |
} |
203 | |
204 |
return Windows_Kinect_Body_get_HandRightConfidence(_pNative); |
205 |
} |
206 |
} |
207 | |
208 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
209 |
private static extern Windows.Kinect.HandState Windows_Kinect_Body_get_HandRightState(RootSystem.IntPtr pNative); |
210 |
public Windows.Kinect.HandState HandRightState |
211 |
{ |
212 |
get |
213 |
{ |
214 |
if (_pNative == RootSystem.IntPtr.Zero) |
215 |
{ |
216 |
throw new RootSystem.ObjectDisposedException("Body"); |
217 |
} |
218 | |
219 |
return Windows_Kinect_Body_get_HandRightState(_pNative); |
220 |
} |
221 |
} |
222 | |
223 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
224 |
private static extern bool Windows_Kinect_Body_get_IsRestricted(RootSystem.IntPtr pNative); |
225 |
public bool IsRestricted |
226 |
{ |
227 |
get |
228 |
{ |
229 |
if (_pNative == RootSystem.IntPtr.Zero) |
230 |
{ |
231 |
throw new RootSystem.ObjectDisposedException("Body"); |
232 |
} |
233 | |
234 |
return Windows_Kinect_Body_get_IsRestricted(_pNative); |
235 |
} |
236 |
} |
237 | |
238 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
239 |
private static extern bool Windows_Kinect_Body_get_IsTracked(RootSystem.IntPtr pNative); |
240 |
public bool IsTracked |
241 |
{ |
242 |
get |
243 |
{ |
244 |
if (_pNative == RootSystem.IntPtr.Zero) |
245 |
{ |
246 |
throw new RootSystem.ObjectDisposedException("Body"); |
247 |
} |
248 | |
249 |
return Windows_Kinect_Body_get_IsTracked(_pNative); |
250 |
} |
251 |
} |
252 | |
253 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
254 |
private static extern int Windows_Kinect_Body_get_JointOrientations(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.JointType[] outKeys, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.JointOrientation[] outValues, int outCollectionSize); |
255 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
256 |
private static extern int Windows_Kinect_Body_get_JointOrientations_Length(RootSystem.IntPtr pNative); |
257 |
public RootSystem.Collections.Generic.Dictionary<Windows.Kinect.JointType, Windows.Kinect.JointOrientation> JointOrientations |
258 |
{ |
259 |
get |
260 |
{ |
261 |
if (_pNative == RootSystem.IntPtr.Zero) |
262 |
{ |
263 |
throw new RootSystem.ObjectDisposedException("Body"); |
264 |
} |
265 | |
266 |
int outCollectionSize = Windows_Kinect_Body_get_JointOrientations_Length(_pNative); |
267 |
var outKeys = new Windows.Kinect.JointType[outCollectionSize]; |
268 |
var outValues = new Windows.Kinect.JointOrientation[outCollectionSize]; |
269 |
var managedDictionary = new RootSystem.Collections.Generic.Dictionary<Windows.Kinect.JointType, Windows.Kinect.JointOrientation>(); |
270 | |
271 |
outCollectionSize = Windows_Kinect_Body_get_JointOrientations(_pNative, outKeys, outValues, outCollectionSize); |
272 |
Helper.ExceptionHelper.CheckLastError(); |
273 |
for(int i=0;i<outCollectionSize;i++) |
274 |
{ |
275 |
managedDictionary.Add(outKeys[i], outValues[i]); |
276 |
} |
277 |
return managedDictionary; |
278 |
} |
279 |
} |
280 | |
281 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
282 |
private static extern int Windows_Kinect_Body_get_Joints(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.JointType[] outKeys, [RootSystem.Runtime.InteropServices.Out] Windows.Kinect.Joint[] outValues, int outCollectionSize); |
283 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
284 |
private static extern int Windows_Kinect_Body_get_Joints_Length(RootSystem.IntPtr pNative); |
285 |
public RootSystem.Collections.Generic.Dictionary<Windows.Kinect.JointType, Windows.Kinect.Joint> Joints |
286 |
{ |
287 |
get |
288 |
{ |
289 |
if (_pNative == RootSystem.IntPtr.Zero) |
290 |
{ |
291 |
throw new RootSystem.ObjectDisposedException("Body"); |
292 |
} |
293 | |
294 |
int outCollectionSize = Windows_Kinect_Body_get_Joints_Length(_pNative); |
295 |
var outKeys = new Windows.Kinect.JointType[outCollectionSize]; |
296 |
var outValues = new Windows.Kinect.Joint[outCollectionSize]; |
297 |
var managedDictionary = new RootSystem.Collections.Generic.Dictionary<Windows.Kinect.JointType, Windows.Kinect.Joint>(); |
298 | |
299 |
outCollectionSize = Windows_Kinect_Body_get_Joints(_pNative, outKeys, outValues, outCollectionSize); |
300 |
Helper.ExceptionHelper.CheckLastError(); |
301 |
for(int i=0;i<outCollectionSize;i++) |
302 |
{ |
303 |
managedDictionary.Add(outKeys[i], outValues[i]); |
304 |
} |
305 |
return managedDictionary; |
306 |
} |
307 |
} |
308 | |
309 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
310 |
private static extern Windows.Kinect.TrackingState Windows_Kinect_Body_get_LeanTrackingState(RootSystem.IntPtr pNative); |
311 |
public Windows.Kinect.TrackingState LeanTrackingState |
312 |
{ |
313 |
get |
314 |
{ |
315 |
if (_pNative == RootSystem.IntPtr.Zero) |
316 |
{ |
317 |
throw new RootSystem.ObjectDisposedException("Body"); |
318 |
} |
319 | |
320 |
return Windows_Kinect_Body_get_LeanTrackingState(_pNative); |
321 |
} |
322 |
} |
323 | |
324 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
325 |
private static extern ulong Windows_Kinect_Body_get_TrackingId(RootSystem.IntPtr pNative); |
326 |
public ulong TrackingId |
327 |
{ |
328 |
get |
329 |
{ |
330 |
if (_pNative == RootSystem.IntPtr.Zero) |
331 |
{ |
332 |
throw new RootSystem.ObjectDisposedException("Body"); |
333 |
} |
334 | |
335 |
return Windows_Kinect_Body_get_TrackingId(_pNative); |
336 |
} |
337 |
} |
338 | |
339 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
340 |
private static extern int Windows_Kinect_Body_get_JointCount(); |
341 |
public static int JointCount |
342 |
{ |
343 |
get |
344 |
{ |
345 |
return Windows_Kinect_Body_get_JointCount(); |
346 |
} |
347 |
} |
348 | |
349 | |
350 |
// Public Methods |
351 |
private void __EventCleanup() |
352 |
{ |
353 |
} |
354 |
} |
355 | |
356 |
} |
357 |
#endif |