t1 / TFDContents / Assets / Standard Assets / Windows / Kinect / DepthFrame.cs @ 9
이력 | 보기 | 이력해설 | 다운로드 (7.51 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.DepthFrame |
| 9 |
// |
| 10 |
public sealed partial class DepthFrame : RootSystem.IDisposable, 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 DepthFrame(RootSystem.IntPtr pNative) |
| 18 |
{
|
| 19 |
_pNative = pNative; |
| 20 |
Windows_Kinect_DepthFrame_AddRefObject(ref _pNative); |
| 21 |
} |
| 22 |
|
| 23 |
~DepthFrame() |
| 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_DepthFrame_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_DepthFrame_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<DepthFrame>(_pNative); |
| 42 |
|
| 43 |
if (disposing) |
| 44 |
{
|
| 45 |
Windows_Kinect_DepthFrame_Dispose(_pNative); |
| 46 |
} |
| 47 |
Windows_Kinect_DepthFrame_ReleaseObject(ref _pNative); |
| 48 |
|
| 49 |
_pNative = RootSystem.IntPtr.Zero; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
// Public Properties |
| 54 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 55 |
private static extern RootSystem.IntPtr Windows_Kinect_DepthFrame_get_DepthFrameSource(RootSystem.IntPtr pNative); |
| 56 |
public Windows.Kinect.DepthFrameSource DepthFrameSource |
| 57 |
{
|
| 58 |
get |
| 59 |
{
|
| 60 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 61 |
{
|
| 62 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 63 |
} |
| 64 |
|
| 65 |
RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrame_get_DepthFrameSource(_pNative); |
| 66 |
Helper.ExceptionHelper.CheckLastError(); |
| 67 |
if (objectPointer == RootSystem.IntPtr.Zero) |
| 68 |
{
|
| 69 |
return null; |
| 70 |
} |
| 71 |
|
| 72 |
return Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.DepthFrameSource>(objectPointer, n => new Windows.Kinect.DepthFrameSource(n)); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 77 |
private static extern ushort Windows_Kinect_DepthFrame_get_DepthMaxReliableDistance(RootSystem.IntPtr pNative); |
| 78 |
public ushort DepthMaxReliableDistance |
| 79 |
{
|
| 80 |
get |
| 81 |
{
|
| 82 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 83 |
{
|
| 84 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 85 |
} |
| 86 |
|
| 87 |
return Windows_Kinect_DepthFrame_get_DepthMaxReliableDistance(_pNative); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 92 |
private static extern ushort Windows_Kinect_DepthFrame_get_DepthMinReliableDistance(RootSystem.IntPtr pNative); |
| 93 |
public ushort DepthMinReliableDistance |
| 94 |
{
|
| 95 |
get |
| 96 |
{
|
| 97 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 98 |
{
|
| 99 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 100 |
} |
| 101 |
|
| 102 |
return Windows_Kinect_DepthFrame_get_DepthMinReliableDistance(_pNative); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 107 |
private static extern RootSystem.IntPtr Windows_Kinect_DepthFrame_get_FrameDescription(RootSystem.IntPtr pNative); |
| 108 |
public Windows.Kinect.FrameDescription FrameDescription |
| 109 |
{
|
| 110 |
get |
| 111 |
{
|
| 112 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 113 |
{
|
| 114 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 115 |
} |
| 116 |
|
| 117 |
RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrame_get_FrameDescription(_pNative); |
| 118 |
Helper.ExceptionHelper.CheckLastError(); |
| 119 |
if (objectPointer == RootSystem.IntPtr.Zero) |
| 120 |
{
|
| 121 |
return null; |
| 122 |
} |
| 123 |
|
| 124 |
return Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.FrameDescription>(objectPointer, n => new Windows.Kinect.FrameDescription(n)); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 129 |
private static extern long Windows_Kinect_DepthFrame_get_RelativeTime(RootSystem.IntPtr pNative); |
| 130 |
public RootSystem.TimeSpan RelativeTime |
| 131 |
{
|
| 132 |
get |
| 133 |
{
|
| 134 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 135 |
{
|
| 136 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 137 |
} |
| 138 |
|
| 139 |
return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_DepthFrame_get_RelativeTime(_pNative)); |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
// Public Methods |
| 145 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 146 |
private static extern void Windows_Kinect_DepthFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); |
| 147 |
public void CopyFrameDataToArray(ushort[] frameData) |
| 148 |
{
|
| 149 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 150 |
{
|
| 151 |
throw new RootSystem.ObjectDisposedException("DepthFrame");
|
| 152 |
} |
| 153 |
|
| 154 |
var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); |
| 155 |
var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); |
| 156 |
Windows_Kinect_DepthFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); |
| 157 |
Helper.ExceptionHelper.CheckLastError(); |
| 158 |
} |
| 159 |
|
| 160 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
|
| 161 |
private static extern void Windows_Kinect_DepthFrame_Dispose(RootSystem.IntPtr pNative); |
| 162 |
public void Dispose() |
| 163 |
{
|
| 164 |
if (_pNative == RootSystem.IntPtr.Zero) |
| 165 |
{
|
| 166 |
return; |
| 167 |
} |
| 168 |
|
| 169 |
Dispose(true); |
| 170 |
RootSystem.GC.SuppressFinalize(this); |
| 171 |
} |
| 172 |
|
| 173 |
private void __EventCleanup() |
| 174 |
{
|
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
} |
| 179 |
#endif |