Body.cs 17 KB

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