LongExposureInfraredFrame.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using RootSystem = System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Windows.Kinect
  5. {
  6. //
  7. // Windows.Kinect.LongExposureInfraredFrame
  8. //
  9. public sealed partial class LongExposureInfraredFrame : RootSystem.IDisposable, Helper.INativeWrapper
  10. {
  11. internal RootSystem.IntPtr _pNative;
  12. RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } }
  13. // Constructors and Finalizers
  14. internal LongExposureInfraredFrame(RootSystem.IntPtr pNative)
  15. {
  16. _pNative = pNative;
  17. Windows_Kinect_LongExposureInfraredFrame_AddRefObject(ref _pNative);
  18. }
  19. ~LongExposureInfraredFrame()
  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_LongExposureInfraredFrame_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_LongExposureInfraredFrame_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<LongExposureInfraredFrame>(_pNative);
  35. if (disposing)
  36. {
  37. Windows_Kinect_LongExposureInfraredFrame_Dispose(_pNative);
  38. }
  39. Windows_Kinect_LongExposureInfraredFrame_ReleaseObject(ref _pNative);
  40. _pNative = RootSystem.IntPtr.Zero;
  41. }
  42. // Public Properties
  43. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  44. private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrame_get_FrameDescription(RootSystem.IntPtr pNative);
  45. public Windows.Kinect.FrameDescription FrameDescription
  46. {
  47. get
  48. {
  49. if (_pNative == RootSystem.IntPtr.Zero)
  50. {
  51. throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame");
  52. }
  53. RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrame_get_FrameDescription(_pNative);
  54. Helper.ExceptionHelper.CheckLastError();
  55. if (objectPointer == RootSystem.IntPtr.Zero)
  56. {
  57. return null;
  58. }
  59. return Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.FrameDescription>(objectPointer, n => new Windows.Kinect.FrameDescription(n));
  60. }
  61. }
  62. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  63. private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrame_get_LongExposureInfraredFrameSource(RootSystem.IntPtr pNative);
  64. public Windows.Kinect.LongExposureInfraredFrameSource LongExposureInfraredFrameSource
  65. {
  66. get
  67. {
  68. if (_pNative == RootSystem.IntPtr.Zero)
  69. {
  70. throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame");
  71. }
  72. RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrame_get_LongExposureInfraredFrameSource(_pNative);
  73. Helper.ExceptionHelper.CheckLastError();
  74. if (objectPointer == RootSystem.IntPtr.Zero)
  75. {
  76. return null;
  77. }
  78. return Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.LongExposureInfraredFrameSource>(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameSource(n));
  79. }
  80. }
  81. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  82. private static extern long Windows_Kinect_LongExposureInfraredFrame_get_RelativeTime(RootSystem.IntPtr pNative);
  83. public RootSystem.TimeSpan RelativeTime
  84. {
  85. get
  86. {
  87. if (_pNative == RootSystem.IntPtr.Zero)
  88. {
  89. throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame");
  90. }
  91. return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_LongExposureInfraredFrame_get_RelativeTime(_pNative));
  92. }
  93. }
  94. // Public Methods
  95. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  96. private static extern void Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize);
  97. public void CopyFrameDataToArray(ushort[] frameData)
  98. {
  99. if (_pNative == RootSystem.IntPtr.Zero)
  100. {
  101. throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame");
  102. }
  103. var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned));
  104. var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject();
  105. Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length);
  106. Helper.ExceptionHelper.CheckLastError();
  107. }
  108. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  109. private static extern void Windows_Kinect_LongExposureInfraredFrame_Dispose(RootSystem.IntPtr pNative);
  110. public void Dispose()
  111. {
  112. if (_pNative == RootSystem.IntPtr.Zero)
  113. {
  114. return;
  115. }
  116. Dispose(true);
  117. RootSystem.GC.SuppressFinalize(this);
  118. }
  119. private void __EventCleanup()
  120. {
  121. }
  122. }
  123. }