From 0327d9e57546c2edf3a718566824c148ca287f10 Mon Sep 17 00:00:00 2001 From: Chikashi Miyama Date: Sun, 30 Jun 2019 14:46:10 +0200 Subject: [PATCH] add kinect module --- CylVision/Assembly-CSharp.csproj | 22 +- CylVision/Assets/ThridParty.meta | 8 + CylVision/Assets/ThridParty/Editor.meta | 8 + .../Editor/KinectCopyPluginDataHelper.cs | 70 ++ .../Editor/KinectCopyPluginDataHelper.cs.meta | 11 + CylVision/Assets/ThridParty/KinectScript.meta | 8 + .../KinectScript/CameraIntrinsics.cs | 58 ++ .../KinectScript/CameraIntrinsics.cs.meta | 11 + .../ThridParty/KinectScript/CollectionMap.cs | 26 + .../KinectScript/CollectionMap.cs.meta | 11 + .../ThridParty/KinectScript/EventPump.cs | 78 +++ .../ThridParty/KinectScript/EventPump.cs.meta | 11 + .../KinectScript/ExceptionHelper.cs | 50 ++ .../KinectScript/ExceptionHelper.cs.meta | 11 + .../ThridParty/KinectScript/INativeWrapper.cs | 12 + .../KinectScript/INativeWrapper.cs.meta | 11 + .../ThridParty/KinectScript/KinectBuffer.cs | 129 ++++ .../KinectScript/KinectBuffer.cs.meta | 11 + .../KinectScript/KinectSpecialCases.cs | 604 ++++++++++++++++++ .../KinectScript/KinectSpecialCases.cs.meta | 11 + .../KinectScript/NativeObjectCache.cs | 136 ++++ .../KinectScript/NativeObjectCache.cs.meta | 11 + .../ThridParty/KinectScript/NativeWrapper.cs | 28 + .../KinectScript/NativeWrapper.cs.meta | 11 + .../ThridParty/KinectScript/SmartGCHandle.cs | 42 ++ .../KinectScript/SmartGCHandle.cs.meta | 11 + .../KinectScript/ThreadSafeDictionary.cs | 61 ++ .../KinectScript/ThreadSafeDictionary.cs.meta | 11 + CylVision/Assets/ThridParty/KinectView.meta | 8 + .../ThridParty/KinectView/MainScene.unity | Bin 0 -> 29728 bytes .../KinectView/MainScene.unity.meta | 7 + .../ThridParty/KinectView/Materials.meta | 8 + .../KinectView/Materials/BoneMaterial.mat | Bin 0 -> 4272 bytes .../Materials/BoneMaterial.mat.meta | 4 + .../Assets/ThridParty/KinectView/Scripts.meta | 8 + .../KinectView/Scripts/BodySourceManager.cs | 70 ++ .../Scripts/BodySourceManager.cs.meta | 8 + .../KinectView/Scripts/BodySourceView.cs | 179 ++++++ .../KinectView/Scripts/BodySourceView.cs.meta | 8 + .../KinectView/Scripts/ColorSourceManager.cs | 78 +++ .../Scripts/ColorSourceManager.cs.meta | 8 + .../KinectView/Scripts/ColorSourceView.cs | 30 + .../Scripts/ColorSourceView.cs.meta | 8 + .../KinectView/Scripts/DepthSourceManager.cs | 59 ++ .../Scripts/DepthSourceManager.cs.meta | 8 + .../KinectView/Scripts/DepthSourceView.cs | 252 ++++++++ .../Scripts/DepthSourceView.cs.meta | 8 + .../KinectView/Scripts/DisableOnStart.cs | 11 + .../KinectView/Scripts/DisableOnStart.cs.meta | 8 + .../Scripts/InfraredSourceManager.cs | 85 +++ .../Scripts/InfraredSourceManager.cs.meta | 8 + .../KinectView/Scripts/InfraredSourceView.cs | 29 + .../Scripts/InfraredSourceView.cs.meta | 8 + .../KinectView/Scripts/MultiSourceManager.cs | 100 +++ .../Scripts/MultiSourceManager.cs.meta | 8 + CylVision/Assets/ThridParty/Windows.meta | 8 + CylVision/Assets/ThridParty/Windows/Data.meta | 8 + .../Windows/Data/PropertyChangedEventArgs.cs | 73 +++ .../Data/PropertyChangedEventArgs.cs.meta | 11 + .../Assets/ThridParty/Windows/Kinect.meta | 8 + .../ThridParty/Windows/Kinect/Activity.cs | 18 + .../Windows/Kinect/Activity.cs.meta | 11 + .../ThridParty/Windows/Kinect/Appearance.cs | 14 + .../Windows/Kinect/Appearance.cs.meta | 11 + .../ThridParty/Windows/Kinect/AudioBeam.cs | 240 +++++++ .../Windows/Kinect/AudioBeam.cs.meta | 11 + .../Windows/Kinect/AudioBeamFrame.cs | 114 ++++ .../Windows/Kinect/AudioBeamFrame.cs.meta | 11 + .../Kinect/AudioBeamFrameArrivedEventArgs.cs | 75 +++ .../AudioBeamFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/AudioBeamFrameList.cs | 71 ++ .../Windows/Kinect/AudioBeamFrameList.cs.meta | 11 + .../Windows/Kinect/AudioBeamFrameReader.cs | 309 +++++++++ .../Kinect/AudioBeamFrameReader.cs.meta | 11 + .../Windows/Kinect/AudioBeamFrameReference.cs | 101 +++ .../Kinect/AudioBeamFrameReference.cs.meta | 11 + .../Windows/Kinect/AudioBeamMode.cs | 15 + .../Windows/Kinect/AudioBeamMode.cs.meta | 11 + .../Windows/Kinect/AudioBeamSubFrame.cs | 212 ++++++ .../Windows/Kinect/AudioBeamSubFrame.cs.meta | 11 + .../Windows/Kinect/AudioBodyCorrelation.cs | 68 ++ .../Kinect/AudioBodyCorrelation.cs.meta | 11 + .../ThridParty/Windows/Kinect/AudioSource.cs | 361 +++++++++++ .../Windows/Kinect/AudioSource.cs.meta | 11 + .../Assets/ThridParty/Windows/Kinect/Body.cs | 355 ++++++++++ .../ThridParty/Windows/Kinect/Body.cs.meta | 11 + .../ThridParty/Windows/Kinect/BodyFrame.cs | 144 +++++ .../Windows/Kinect/BodyFrame.cs.meta | 11 + .../Kinect/BodyFrameArrivedEventArgs.cs | 75 +++ .../Kinect/BodyFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/BodyFrameReader.cs | 297 +++++++++ .../Windows/Kinect/BodyFrameReader.cs.meta | 11 + .../Windows/Kinect/BodyFrameReference.cs | 89 +++ .../Windows/Kinect/BodyFrameReference.cs.meta | 11 + .../Windows/Kinect/BodyFrameSource.cs | 308 +++++++++ .../Windows/Kinect/BodyFrameSource.cs.meta | 11 + .../Windows/Kinect/BodyIndexFrame.cs | 147 +++++ .../Windows/Kinect/BodyIndexFrame.cs.meta | 11 + .../Kinect/BodyIndexFrameArrivedEventArgs.cs | 75 +++ .../BodyIndexFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/BodyIndexFrameReader.cs | 297 +++++++++ .../Kinect/BodyIndexFrameReader.cs.meta | 11 + .../Windows/Kinect/BodyIndexFrameReference.cs | 89 +++ .../Kinect/BodyIndexFrameReference.cs.meta | 11 + .../Windows/Kinect/BodyIndexFrameSource.cs | 289 +++++++++ .../Kinect/BodyIndexFrameSource.cs.meta | 11 + .../Windows/Kinect/CameraSpacePoint.cs | 47 ++ .../Windows/Kinect/CameraSpacePoint.cs.meta | 11 + .../Windows/Kinect/ColorCameraSettings.cs | 113 ++++ .../Kinect/ColorCameraSettings.cs.meta | 11 + .../ThridParty/Windows/Kinect/ColorFrame.cs | 218 +++++++ .../Windows/Kinect/ColorFrame.cs.meta | 11 + .../Kinect/ColorFrameArrivedEventArgs.cs | 75 +++ .../Kinect/ColorFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/ColorFrameReader.cs | 297 +++++++++ .../Windows/Kinect/ColorFrameReader.cs.meta | 11 + .../Windows/Kinect/ColorFrameReference.cs | 89 +++ .../Kinect/ColorFrameReference.cs.meta | 11 + .../Windows/Kinect/ColorFrameSource.cs | 308 +++++++++ .../Windows/Kinect/ColorFrameSource.cs.meta | 11 + .../Windows/Kinect/ColorImageFormat.cs | 19 + .../Windows/Kinect/ColorImageFormat.cs.meta | 11 + .../Windows/Kinect/ColorSpacePoint.cs | 46 ++ .../Windows/Kinect/ColorSpacePoint.cs.meta | 11 + .../Windows/Kinect/CoordinateMapper.cs | 336 ++++++++++ .../Windows/Kinect/CoordinateMapper.cs.meta | 11 + .../CoordinateMappingChangedEventArgs.cs | 51 ++ .../CoordinateMappingChangedEventArgs.cs.meta | 11 + .../ThridParty/Windows/Kinect/DepthFrame.cs | 177 +++++ .../Windows/Kinect/DepthFrame.cs.meta | 11 + .../Kinect/DepthFrameArrivedEventArgs.cs | 75 +++ .../Kinect/DepthFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/DepthFrameReader.cs | 297 +++++++++ .../Windows/Kinect/DepthFrameReader.cs.meta | 11 + .../Windows/Kinect/DepthFrameReference.cs | 89 +++ .../Kinect/DepthFrameReference.cs.meta | 11 + .../Windows/Kinect/DepthFrameSource.cs | 319 +++++++++ .../Windows/Kinect/DepthFrameSource.cs.meta | 11 + .../Windows/Kinect/DepthSpacePoint.cs | 46 ++ .../Windows/Kinect/DepthSpacePoint.cs.meta | 11 + .../Windows/Kinect/DetectionResult.cs | 17 + .../Windows/Kinect/DetectionResult.cs.meta | 11 + .../ThridParty/Windows/Kinect/Expression.cs | 15 + .../Windows/Kinect/Expression.cs.meta | 11 + .../Windows/Kinect/FrameCapturedEventArgs.cs | 98 +++ .../Kinect/FrameCapturedEventArgs.cs.meta | 11 + .../Windows/Kinect/FrameCapturedStatus.cs | 16 + .../Kinect/FrameCapturedStatus.cs.meta | 11 + .../Windows/Kinect/FrameDescription.cs | 158 +++++ .../Windows/Kinect/FrameDescription.cs.meta | 11 + .../ThridParty/Windows/Kinect/FrameEdges.cs | 19 + .../Windows/Kinect/FrameEdges.cs.meta | 11 + .../Windows/Kinect/FrameSourceTypes.cs | 22 + .../Windows/Kinect/FrameSourceTypes.cs.meta | 11 + .../ThridParty/Windows/Kinect/HandState.cs | 18 + .../Windows/Kinect/HandState.cs.meta | 11 + .../Windows/Kinect/InfraredFrame.cs | 147 +++++ .../Windows/Kinect/InfraredFrame.cs.meta | 11 + .../Kinect/InfraredFrameArrivedEventArgs.cs | 75 +++ .../InfraredFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/InfraredFrameReader.cs | 297 +++++++++ .../Kinect/InfraredFrameReader.cs.meta | 11 + .../Windows/Kinect/InfraredFrameReference.cs | 89 +++ .../Kinect/InfraredFrameReference.cs.meta | 11 + .../Windows/Kinect/InfraredFrameSource.cs | 289 +++++++++ .../Kinect/InfraredFrameSource.cs.meta | 11 + .../Kinect/IsAvailableChangedEventArgs.cs | 68 ++ .../IsAvailableChangedEventArgs.cs.meta | 11 + .../Assets/ThridParty/Windows/Kinect/Joint.cs | 47 ++ .../ThridParty/Windows/Kinect/Joint.cs.meta | 11 + .../Windows/Kinect/JointOrientation.cs | 46 ++ .../Windows/Kinect/JointOrientation.cs.meta | 11 + .../ThridParty/Windows/Kinect/JointType.cs | 38 ++ .../Windows/Kinect/JointType.cs.meta | 11 + .../Kinect/KinectAudioCalibrationState.cs | 16 + .../KinectAudioCalibrationState.cs.meta | 11 + .../Windows/Kinect/KinectCapabilities.cs | 20 + .../Windows/Kinect/KinectCapabilities.cs.meta | 11 + .../ThridParty/Windows/Kinect/KinectSensor.cs | 498 +++++++++++++++ .../Windows/Kinect/KinectSensor.cs.meta | 11 + .../Windows/Kinect/KinectUnityAddinUtils.cs | 19 + .../Kinect/KinectUnityAddinUtils.cs.meta | 11 + .../Kinect/LongExposureInfraredFrame.cs | 147 +++++ .../Kinect/LongExposureInfraredFrame.cs.meta | 11 + ...ngExposureInfraredFrameArrivedEventArgs.cs | 75 +++ ...osureInfraredFrameArrivedEventArgs.cs.meta | 11 + .../Kinect/LongExposureInfraredFrameReader.cs | 297 +++++++++ .../LongExposureInfraredFrameReader.cs.meta | 11 + .../LongExposureInfraredFrameReference.cs | 89 +++ ...LongExposureInfraredFrameReference.cs.meta | 11 + .../Kinect/LongExposureInfraredFrameSource.cs | 289 +++++++++ .../LongExposureInfraredFrameSource.cs.meta | 11 + .../Windows/Kinect/MultiSourceFrame.cs | 187 ++++++ .../Windows/Kinect/MultiSourceFrame.cs.meta | 11 + .../MultiSourceFrameArrivedEventArgs.cs | 75 +++ .../MultiSourceFrameArrivedEventArgs.cs.meta | 11 + .../Windows/Kinect/MultiSourceFrameReader.cs | 312 +++++++++ .../Kinect/MultiSourceFrameReader.cs.meta | 11 + .../Kinect/MultiSourceFrameReference.cs | 72 +++ .../Kinect/MultiSourceFrameReference.cs.meta | 11 + .../Windows/Kinect/TrackingConfidence.cs | 15 + .../Windows/Kinect/TrackingConfidence.cs.meta | 11 + .../Windows/Kinect/TrackingState.cs | 16 + .../Windows/Kinect/TrackingState.cs.meta | 11 + .../ThridParty/Windows/Kinect/Vector4.cs | 48 ++ .../ThridParty/Windows/Kinect/Vector4.cs.meta | 11 + 206 files changed, 13379 insertions(+), 11 deletions(-) create mode 100644 CylVision/Assets/ThridParty.meta create mode 100644 CylVision/Assets/ThridParty/Editor.meta create mode 100644 CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs create mode 100644 CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/EventPump.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/EventPump.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs create mode 100644 CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/MainScene.unity create mode 100644 CylVision/Assets/ThridParty/KinectView/MainScene.unity.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Materials.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat create mode 100644 CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs.meta create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs create mode 100644 CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Data.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Body.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Body.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs.meta create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs create mode 100644 CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs.meta diff --git a/CylVision/Assembly-CSharp.csproj b/CylVision/Assembly-CSharp.csproj index 9de0552..de0234b 100644 --- a/CylVision/Assembly-CSharp.csproj +++ b/CylVision/Assembly-CSharp.csproj @@ -54,13 +54,17 @@ - - - - - - - + + + + + + + + + + + @@ -71,10 +75,6 @@ - - - - diff --git a/CylVision/Assets/ThridParty.meta b/CylVision/Assets/ThridParty.meta new file mode 100644 index 0000000..3b25a7a --- /dev/null +++ b/CylVision/Assets/ThridParty.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca30ef5db57550d4c80d44a639774594 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Editor.meta b/CylVision/Assets/ThridParty/Editor.meta new file mode 100644 index 0000000..dc9e5b0 --- /dev/null +++ b/CylVision/Assets/ThridParty/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d679b93fcd19ce040b8f9a6cfda5b25d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs b/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs new file mode 100644 index 0000000..b94333d --- /dev/null +++ b/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections.Generic; +using System.IO; + +public static class KinectCopyPluginDataHelper +{ + private const string DataDirSuffix = "_Data"; + private const string PluginsDirName = "Plugins"; + + private static Dictionary TargetToDirName = new Dictionary() + { + {BuildTarget.StandaloneWindows, "x86"}, + {BuildTarget.StandaloneWindows64, "x86_64"} + }; + + public static void CopyPluginData(BuildTarget target, string buildTargetPath, string subDirToCopy) + { + string subDirName; + if (!TargetToDirName.TryGetValue (target, out subDirName)) + { + // No work to do + return; + } + + // Get Required Paths + var buildName = Path.GetFileNameWithoutExtension(buildTargetPath); + var targetDir = Directory.GetParent(buildTargetPath); + var separator = Path.DirectorySeparatorChar; + + var buildDataDir = targetDir.FullName + separator + buildName + DataDirSuffix + separator; + var tgtPluginsDir = buildDataDir + separator + PluginsDirName + separator + subDirToCopy + separator; + var srcPluginsDir = Application.dataPath + separator + PluginsDirName + separator + subDirName + separator + subDirToCopy + separator; + + CopyAll (new DirectoryInfo (srcPluginsDir), new DirectoryInfo(tgtPluginsDir)); + } + + /// + /// Recursive Copy Directory Method + /// + private static void CopyAll(DirectoryInfo source, DirectoryInfo target) + { + // Check if the source directory exists, if not, don't do any work. + if (!Directory.Exists(source.FullName)) + { + return; + } + + // Check if the target directory exists, if not, create it. + if (!Directory.Exists(target.FullName)) + { + Directory.CreateDirectory(target.FullName); + } + + // Copy each file into it’s new directory. + foreach (var fileInfo in source.GetFiles()) + { + fileInfo.CopyTo (Path.Combine (target.ToString (), fileInfo.Name), true); + } + + // Copy each subdirectory using recursion. + foreach (var subDirInfo in source.GetDirectories()) + { + DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(subDirInfo.Name); + CopyAll(subDirInfo, nextTargetSubDir); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs.meta b/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs.meta new file mode 100644 index 0000000..bd8a732 --- /dev/null +++ b/CylVision/Assets/ThridParty/Editor/KinectCopyPluginDataHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a103df75c03c9c54096627354fdb1398 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript.meta b/CylVision/Assets/ThridParty/KinectScript.meta new file mode 100644 index 0000000..69deb8f --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac64ad8b219357b4a8aa514e7c2b4b3a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs b/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs new file mode 100644 index 0000000..3add3d3 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs @@ -0,0 +1,58 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.CameraIntrinsics + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct CameraIntrinsics + { + public float FocalLengthX { get; set; } + public float FocalLengthY { get; set; } + public float PrincipalPointX { get; set; } + public float PrincipalPointY { get; set; } + public float RadialDistortionSecondOrder { get; set; } + public float RadialDistortionFourthOrder { get; set; } + public float RadialDistortionSixthOrder { get; set; } + + public override int GetHashCode() + { + return FocalLengthX.GetHashCode() ^ FocalLengthY.GetHashCode() ^ + PrincipalPointX.GetHashCode() ^ PrincipalPointY.GetHashCode() ^ + RadialDistortionSecondOrder.GetHashCode() ^ RadialDistortionFourthOrder.GetHashCode() ^ + RadialDistortionSixthOrder.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is CameraIntrinsics)) + { + return false; + } + + return this.Equals((CameraIntrinsics)obj); + } + + public bool Equals(CameraIntrinsics obj) + { + return FocalLengthX.Equals(obj.FocalLengthX) && FocalLengthY.Equals(obj.FocalLengthY) && + PrincipalPointX.Equals(obj.PrincipalPointX) && PrincipalPointY.Equals(obj.PrincipalPointY) && + RadialDistortionSecondOrder.Equals(obj.RadialDistortionSecondOrder) && + RadialDistortionFourthOrder.Equals(obj.RadialDistortionFourthOrder) && + RadialDistortionSixthOrder.Equals(obj.RadialDistortionSixthOrder); + } + + public static bool operator ==(CameraIntrinsics a, CameraIntrinsics b) + { + return a.Equals(b); + } + + public static bool operator !=(CameraIntrinsics a, CameraIntrinsics b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs.meta b/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs.meta new file mode 100644 index 0000000..142dd12 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/CameraIntrinsics.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc11ab9581163ba44b721acb44ce8763 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs b/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs new file mode 100644 index 0000000..e730778 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Helper +{ + class CollectionMap : Helper.ThreadSafeDictionary where TValue : new() + { + public bool TryAddDefault(TKey key) + { + lock (_impl) + { + if (!_impl.ContainsKey(key)) + { + _impl.Add(key, new TValue()); + return true; + } + else + { + return false; + } + } + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs.meta b/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs.meta new file mode 100644 index 0000000..cc2270a --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/CollectionMap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b404867256ddca245871a9152fd54294 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/EventPump.cs b/CylVision/Assets/ThridParty/KinectScript/EventPump.cs new file mode 100644 index 0000000..c2dc3c0 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/EventPump.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + internal class EventPump : UnityEngine.MonoBehaviour + { + private static object s_Lock = new object(); + private Queue m_Queue = new Queue(); + + public static EventPump Instance + { + get; + private set; + } + + public static void EnsureInitialized() + { + try + { + if (EventPump.Instance == null) + { + lock (s_Lock) + { + if (EventPump.Instance == null) + { + UnityEngine.GameObject parent = new UnityEngine.GameObject("Kinect Desktop Event Pump"); + EventPump.Instance = parent.AddComponent(); + DontDestroyOnLoad(parent); + } + } + } + } + catch + { + UnityEngine.Debug.LogError("Events must be registered on the main thread."); + return; + } + } + + private void Update() + { + lock (m_Queue) + { + while (m_Queue.Count > 0) + { + var action = m_Queue.Dequeue(); + try + { + action.Invoke(); + } + catch { } + } + } + } + + private void OnApplicationQuit() + { + var sensor = Windows.Kinect.KinectSensor.GetDefault(); + if (sensor != null && sensor.IsOpen) + { + sensor.Close(); + } + + NativeObjectCache.Flush(); + } + + public void Enqueue(Action action) + { + lock (m_Queue) + { + m_Queue.Enqueue(action); + } + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/EventPump.cs.meta b/CylVision/Assets/ThridParty/KinectScript/EventPump.cs.meta new file mode 100644 index 0000000..9e0097c --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/EventPump.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: debd3e6b79ccfa7439ef3bc59b8d30e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs b/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs new file mode 100644 index 0000000..4d89ac3 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs @@ -0,0 +1,50 @@ +using System; +using System.Runtime.InteropServices; + +namespace Helper +{ + public static class ExceptionHelper + { + private const int E_NOTIMPL = unchecked((int)0x80004001); + private const int E_OUTOFMEMORY = unchecked((int)0x8007000E); + private const int E_INVALIDARG = unchecked((int)0x80070057); + private const int E_POINTER = unchecked((int) 0x80004003); + private const int E_PENDING = unchecked((int)0x8000000A); + private const int E_FAIL = unchecked((int)0x80004005); + + public static void CheckLastError() + { + int hr = Marshal.GetLastWin32Error(); + + if ((hr == E_PENDING) || (hr == E_FAIL)) + { + // Ignore E_PENDING/E_FAIL - We use this to indicate no pending or missed frames + return; + } + + if (hr < 0) + { + Exception exception = Marshal.GetExceptionForHR(hr); + string message = string.Format("This API has returned an exception from an HRESULT: 0x{0:X}", hr); + + switch (hr) + { + case E_NOTIMPL: + throw new NotImplementedException(message, exception); + + case E_OUTOFMEMORY: + throw new OutOfMemoryException(message, exception); + + case E_INVALIDARG: + throw new ArgumentException(message, exception); + + case E_POINTER: + throw new ArgumentNullException(message, exception); + + default: + throw new InvalidOperationException(message, exception); + } + } + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs.meta b/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs.meta new file mode 100644 index 0000000..68ff2c1 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/ExceptionHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86085617855511d45b0648e6b62e1584 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs b/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs new file mode 100644 index 0000000..32a562c --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + internal interface INativeWrapper + { + System.IntPtr nativePtr { get; } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs.meta b/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs.meta new file mode 100644 index 0000000..d0ada92 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/INativeWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 010db25b57d940546a60549c96171b70 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs b/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs new file mode 100644 index 0000000..c62cb42 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs @@ -0,0 +1,129 @@ +using RootSystem = System; +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Windows.Kinect +{ + // NOTE: This uses an IBuffer under the covers, it is renamed here to give parity to our managed APIs. + public class KinectBuffer : Helper.INativeWrapper, IDisposable + { + internal RootSystem.IntPtr _pNative; + + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal KinectBuffer(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Storage_Streams_IBuffer_AddRefObject(ref _pNative); + } + + ~KinectBuffer() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private static extern void Windows_Storage_Streams_IBuffer_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private static extern void Windows_Storage_Streams_IBuffer_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Storage_Streams_IBuffer_Dispose(_pNative); + } + + Windows_Storage_Streams_IBuffer_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern uint Windows_Storage_Streams_IBuffer_get_Capacity(RootSystem.IntPtr pNative); + public uint Capacity + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectBuffer"); + } + + uint capacity = Windows_Storage_Streams_IBuffer_get_Capacity(_pNative); + Helper.ExceptionHelper.CheckLastError(); + return capacity; + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern uint Windows_Storage_Streams_IBuffer_get_Length(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Storage_Streams_IBuffer_put_Length(RootSystem.IntPtr pNative, uint value); + public uint Length + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectBuffer"); + } + + uint length = Windows_Storage_Streams_IBuffer_get_Length(_pNative); + Helper.ExceptionHelper.CheckLastError(); + return length; + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectBuffer"); + } + + Windows_Storage_Streams_IBuffer_put_Length(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private static extern void Windows_Storage_Streams_IBuffer_Dispose(RootSystem.IntPtr pNative); + // Constructors and Finalizers + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectBuffer"); + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Storage_Streams_IBuffer_get_UnderlyingBuffer(RootSystem.IntPtr pNative); + public IntPtr UnderlyingBuffer + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectBuffer"); + } + + RootSystem.IntPtr value = Windows_Storage_Streams_IBuffer_get_UnderlyingBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + return value; + } + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs.meta b/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs.meta new file mode 100644 index 0000000..1a3fcfe --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/KinectBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a27f97f1b27134f4bbee290cf18c791c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs b/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs new file mode 100644 index 0000000..09a668b --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs @@ -0,0 +1,604 @@ +using RootSystem = System; +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Windows.Kinect +{ + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct PointF + { + public float X { get; set; } + public float Y { get; set; } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is PointF)) + { + return false; + } + + return this.Equals((ColorSpacePoint)obj); + } + + public bool Equals(ColorSpacePoint obj) + { + return (X == obj.X) && (Y == obj.Y); + } + + public static bool operator ==(PointF a, PointF b) + { + return a.Equals(b); + } + + public static bool operator !=(PointF a, PointF b) + { + return !(a.Equals(b)); + } + } + + public sealed partial class AudioBeamSubFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToIntPtr(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, uint frameDataSize); + public void CopyFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToIntPtr(_pNative, frameData, size); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeamSubFrame_LockAudioBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockAudioBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeamSubFrame_LockAudioBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + } + + public sealed partial class AudioBeamFrame + { + private Windows.Kinect.AudioBeamSubFrame[] _subFrames = null; + + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + if (_subFrames != null) + { + foreach (var subFrame in _subFrames) + { + subFrame.Dispose(); + } + + _subFrames = null; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioBeamFrame_ReleaseObject(ref _pNative); + + if (disposing) + { + Windows_Kinect_AudioBeamFrame_Dispose(_pNative); + } + + _pNative = RootSystem.IntPtr.Zero; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private static extern void Windows_Kinect_AudioBeamFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern int Windows_Kinect_AudioBeamFrame_get_SubFrames(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private static extern int Windows_Kinect_AudioBeamFrame_get_SubFrames_Length(RootSystem.IntPtr pNative); + public RootSystem.Collections.Generic.IList SubFrames + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrame"); + } + + if (_subFrames == null) + { + int collectionSize = Windows_Kinect_AudioBeamFrame_get_SubFrames_Length(_pNative); + var outCollection = new RootSystem.IntPtr[collectionSize]; + _subFrames = new Windows.Kinect.AudioBeamSubFrame[collectionSize]; + + collectionSize = Windows_Kinect_AudioBeamFrame_get_SubFrames(_pNative, outCollection, collectionSize); + Helper.ExceptionHelper.CheckLastError(); + + for (int i = 0; i < collectionSize; i++) + { + if (outCollection[i] == RootSystem.IntPtr.Zero) + { + continue; + } + + var obj = Helper.NativeObjectCache.GetObject(outCollection[i]); + if (obj == null) + { + obj = new Windows.Kinect.AudioBeamSubFrame(outCollection[i]); + Helper.NativeObjectCache.AddObject(outCollection[i], obj); + } + + _subFrames[i] = obj; + } + } + + return _subFrames; + } + } + } + + public sealed partial class BodyFrame + { + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Kinect_BodyFrame_GetAndRefreshBodyData(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] bodies, int bodiesSize); + public void GetAndRefreshBodyData(RootSystem.Collections.Generic.IList bodies) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrame"); + } + + int _bodies_idx = 0; + var _bodies = new RootSystem.IntPtr[bodies.Count]; + for (int i = 0; i < bodies.Count; i++) + { + if (bodies[i] == null) + { + bodies[i] = new Body(); + } + + _bodies[_bodies_idx] = bodies[i].GetIntPtr(); + _bodies_idx++; + } + + Windows_Kinect_BodyFrame_GetAndRefreshBodyData(_pNative, _bodies, bodies.Count); + Helper.ExceptionHelper.CheckLastError(); + + for (int i = 0; i < bodies.Count; i++) + { + bodies[i].SetIntPtr(_bodies[i]); + } + } + } + + public sealed partial class Body + { + internal void SetIntPtr(RootSystem.IntPtr value) { _pNative = value; } + internal RootSystem.IntPtr GetIntPtr() { return _pNative; } + + internal Body() { } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_Body_get_Lean(RootSystem.IntPtr pNative); + public Windows.Kinect.PointF Lean + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + var objectPointer = Windows_Kinect_Body_get_Lean(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + var obj = (Windows.Kinect.PointF)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.PointF)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + } + } + + public sealed partial class ColorFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_ColorFrame_CopyRawFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_ColorFrame_CopyRawFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize); + public void CopyRawFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + Windows_Kinect_ColorFrame_CopyRawFrameDataToIntPtr(_pNative, frameData, size); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_ColorFrame_CopyConvertedFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_ColorFrame_CopyConvertedFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize, Windows.Kinect.ColorImageFormat colorFormat); + public void CopyConvertedFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size, Windows.Kinect.ColorImageFormat colorFormat) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + Windows_Kinect_ColorFrame_CopyConvertedFrameDataToIntPtr(_pNative, frameData, size, colorFormat); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrame_LockRawImageBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockRawImageBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrame_LockRawImageBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + + } + + public sealed partial class DepthFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_DepthFrame_CopyFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_DepthFrame_CopyFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize); + public void CopyFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + Windows_Kinect_DepthFrame_CopyFrameDataToIntPtr(_pNative, frameData, size / sizeof(ushort)); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrame_LockImageBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockImageBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrame_LockImageBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + } + + public sealed partial class BodyIndexFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_BodyIndexFrame_CopyFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_BodyIndexFrame_CopyFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize); + public void CopyFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + Windows_Kinect_BodyIndexFrame_CopyFrameDataToIntPtr(_pNative, frameData, size); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrame_LockImageBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockImageBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrame_LockImageBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + + } + + public sealed partial class InfraredFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_InfraredFrame_CopyFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_InfraredFrame_CopyFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize); + public void CopyFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + Windows_Kinect_InfraredFrame_CopyFrameDataToIntPtr(_pNative, frameData, size / sizeof(ushort)); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrame_LockImageBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockImageBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrame_LockImageBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + + } + + public sealed partial class KinectSensor + { + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + if (IsOpen) + { + Close(); + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_KinectSensor_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + } + + public sealed partial class LongExposureInfraredFrame + { + [RootSystem.Runtime.InteropServices.DllImport( + "KinectUnityAddin", + EntryPoint = "Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToArray", + CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, + SetLastError = true)] + private static extern void Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToIntPtr(RootSystem.IntPtr pNative, IntPtr frameData, uint frameDataSize); + public void CopyFrameDataToIntPtr(RootSystem.IntPtr frameData, uint size) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToIntPtr(_pNative, frameData, size / sizeof(ushort)); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrame_LockImageBuffer(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectBuffer LockImageBuffer() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrame_LockImageBuffer(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectBuffer(n)); + } + + } + + public sealed partial class CoordinateMapper + { + private PointF[] _DepthFrameToCameraSpaceTable = null; + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern RootSystem.IntPtr Windows_Kinect_CoordinateMapper_GetDepthCameraIntrinsics(RootSystem.IntPtr pNative); + public Windows.Kinect.CameraIntrinsics GetDepthCameraIntrinsics() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var objectPointer = Windows_Kinect_CoordinateMapper_GetDepthCameraIntrinsics(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + var obj = (Windows.Kinect.CameraIntrinsics)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.CameraIntrinsics)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern int Windows_Kinect_CoordinateMapper_GetDepthFrameToCameraSpaceTable(RootSystem.IntPtr pNative, RootSystem.IntPtr outCollection, uint outCollectionSize); + public Windows.Kinect.PointF[] GetDepthFrameToCameraSpaceTable() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + if (_DepthFrameToCameraSpaceTable == null) + { + var desc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription; + _DepthFrameToCameraSpaceTable = new PointF[desc.Width * desc.Height]; + + var pointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(_DepthFrameToCameraSpaceTable, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _points = pointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_GetDepthFrameToCameraSpaceTable(_pNative, _points, (uint)_DepthFrameToCameraSpaceTable.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + return _DepthFrameToCameraSpaceTable; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Kinect_CoordinateMapper_MapColorFrameToDepthSpace( + RootSystem.IntPtr pNative, + RootSystem.IntPtr depthFrameData, + uint depthFrameDataSize, + RootSystem.IntPtr depthSpacePoints, + uint depthSpacePointsSize); + public void MapColorFrameToDepthSpaceUsingIntPtr(RootSystem.IntPtr depthFrameData, uint depthFrameSize, RootSystem.IntPtr depthSpacePoints, uint depthSpacePointsSize) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + uint length = depthFrameSize / sizeof(UInt16); + Windows_Kinect_CoordinateMapper_MapColorFrameToDepthSpace(_pNative, depthFrameData, length, depthSpacePoints, depthSpacePointsSize); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Kinect_CoordinateMapper_MapColorFrameToCameraSpace( + RootSystem.IntPtr pNative, + RootSystem.IntPtr depthFrameData, + uint depthFrameDataSize, + RootSystem.IntPtr cameraSpacePoints, + uint cameraSpacePointsSize); + public void MapColorFrameToCameraSpaceUsingIntPtr(RootSystem.IntPtr depthFrameData, int depthFrameSize, RootSystem.IntPtr cameraSpacePoints, uint cameraSpacePointsSize) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + uint length = (uint)depthFrameSize / sizeof(UInt16); + Windows_Kinect_CoordinateMapper_MapColorFrameToCameraSpace(_pNative, depthFrameData, length, cameraSpacePoints, cameraSpacePointsSize); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthFrameToColorSpace( + RootSystem.IntPtr pNative, + RootSystem.IntPtr depthFrameData, + uint depthFrameDataSize, + RootSystem.IntPtr colorSpacePoints, + uint colorSpacePointsSize); + public void MapDepthFrameToColorSpaceUsingIntPtr(RootSystem.IntPtr depthFrameData, int depthFrameSize, RootSystem.IntPtr colorSpacePoints, uint colorSpacePointsSize) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + uint length = (uint)depthFrameSize / sizeof(UInt16); + Windows_Kinect_CoordinateMapper_MapDepthFrameToColorSpace(_pNative, depthFrameData, length, colorSpacePoints, colorSpacePointsSize); + Helper.ExceptionHelper.CheckLastError(); + } + + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention = RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError = true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthFrameToCameraSpace( + RootSystem.IntPtr pNative, + IntPtr depthFrameData, + uint depthFrameDataSize, + RootSystem.IntPtr cameraSpacePoints, + uint cameraSpacePointsSize); + public void MapDepthFrameToCameraSpaceUsingIntPtr(RootSystem.IntPtr depthFrameData, int depthFrameSize, RootSystem.IntPtr cameraSpacePoints, uint cameraSpacePointsSize) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + uint length = (uint)depthFrameSize / sizeof(UInt16); + Windows_Kinect_CoordinateMapper_MapDepthFrameToCameraSpace(_pNative, depthFrameData, length, cameraSpacePoints, cameraSpacePointsSize); + Helper.ExceptionHelper.CheckLastError(); + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs.meta b/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs.meta new file mode 100644 index 0000000..3be1544 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/KinectSpecialCases.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c59b79770236fae42a76e291570f2447 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs b/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs new file mode 100644 index 0000000..0155367 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + public static class NativeObjectCache + { + private static object _lock = new object(); + private static Dictionary> _objectCache = new Dictionary>(); + public static void AddObject(IntPtr nativePtr, T obj) where T : class + { + lock (_lock) + { + Dictionary objCache = null; + + if (!_objectCache.TryGetValue(typeof(T), out objCache) || objCache == null) + { + objCache = new Dictionary(); + _objectCache[typeof(T)] = objCache; + } + + objCache[nativePtr] = new WeakReference(obj); + } + } + + public static void Flush() + { + lock(_lock) + { + foreach (var byType in _objectCache.ToArray()) + { + foreach(var kvp in byType.Value.ToArray()) + { + IDisposable disp = kvp.Value.Target as IDisposable; + if(disp != null) + { + disp.Dispose(); + } + + } + } + } + } + + public static void RemoveObject(IntPtr nativePtr) + { + lock (_lock) + { + Dictionary objCache = null; + + if (!_objectCache.TryGetValue(typeof(T), out objCache) || objCache == null) + { + objCache = new Dictionary(); + _objectCache[typeof(T)] = objCache; + } + + if (objCache.ContainsKey(nativePtr)) + { + objCache.Remove(nativePtr); + } + } + } + + public static T GetObject(IntPtr nativePtr) where T : class + { + lock (_lock) + { + Dictionary objCache = null; + + if (!_objectCache.TryGetValue(typeof(T), out objCache) || objCache == null) + { + objCache = new Dictionary(); + _objectCache[typeof(T)] = objCache; + } + + WeakReference reference = null; + if (objCache.TryGetValue(nativePtr, out reference)) + { + if (reference != null) + { + T obj = reference.Target as T; + if (obj != null) + { + return (T)obj; + } + } + } + + return null; + } + } + + public static T CreateOrGetObject(IntPtr nativePtr, Func create) where T : class + { + T outputValue = null; + + lock (_lock) + { + Dictionary objCache = null; + + if (!_objectCache.TryGetValue(typeof(T), out objCache) || objCache == null) + { + objCache = new Dictionary(); + _objectCache[typeof(T)] = objCache; + } + + WeakReference reference = null; + if (objCache.TryGetValue(nativePtr, out reference)) + { + if ((reference != null) && reference.IsAlive) + { + outputValue = reference.Target as T; + } + } + + if (outputValue == null) + { + if (create != null) + { + outputValue = create(nativePtr); + objCache[nativePtr] = new WeakReference(outputValue); + } + else if(typeof(T) == typeof(System.Object)) + { + //T is an object, so lets just pass back our IntPtr, which is an object. + outputValue = (T)(System.Object)nativePtr; + } + } + } + + return outputValue; + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs.meta b/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs.meta new file mode 100644 index 0000000..c9384ef --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/NativeObjectCache.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 96cf7d466b0b0bb4d92fb09d817ad613 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs b/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs new file mode 100644 index 0000000..1bde8c9 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + public static class NativeWrapper + { + public static System.IntPtr GetNativePtr(Object obj) + { + if(obj == null) + { + return System.IntPtr.Zero; + } + + var nativeWrapperIface = obj as INativeWrapper; + if(nativeWrapperIface != null) + { + return nativeWrapperIface.nativePtr; + } + else + { + throw new ArgumentException("Object must wrap native type"); + } + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs.meta b/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs.meta new file mode 100644 index 0000000..0b3c227 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/NativeWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0eb32acf7ae62044194131ae0f7e4516 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs b/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs new file mode 100644 index 0000000..aac853b --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + public class SmartGCHandle : IDisposable + { + private GCHandle handle; + public SmartGCHandle(GCHandle handle) + { + this.handle = handle; + } + + ~SmartGCHandle() + { + Dispose(false); + } + + public System.IntPtr AddrOfPinnedObject() + { + return handle.AddrOfPinnedObject(); + } + + public virtual void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + this.handle.Free(); + } + + public static implicit operator GCHandle(SmartGCHandle other) + { + + return other.handle; + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs.meta b/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs.meta new file mode 100644 index 0000000..3b28232 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/SmartGCHandle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: adc912eeb5de2014f9ca670eca6ac808 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs b/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs new file mode 100644 index 0000000..6759a4c --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Linq; + +namespace Helper +{ + public class ThreadSafeDictionary + { + protected readonly Dictionary _impl = new Dictionary(); + public TValue this[TKey key] + { + get + { + lock (_impl) + { + return _impl[key]; + } + } + set + { + lock (_impl) + { + _impl[key] = value; + } + } + } + + public void Add(TKey key, TValue value) + { + lock (_impl) + { + _impl.Add(key, value); + } + } + + public bool TryGetValue(TKey key, out TValue value) + { + lock (_impl) + { + return _impl.TryGetValue(key, out value); + } + } + + public bool Remove(TKey key) + { + lock (_impl) + { + return _impl.Remove(key); + } + } + + public void Clear() + { + lock (_impl) + { + _impl.Clear(); + } + } + } +} \ No newline at end of file diff --git a/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs.meta b/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs.meta new file mode 100644 index 0000000..0d5229d --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectScript/ThreadSafeDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b31ad795626855f41842734c10d2a41f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectView.meta b/CylVision/Assets/ThridParty/KinectView.meta new file mode 100644 index 0000000..f069fb7 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: abc0bdd9d88ff784ba2ef62dea99f5cb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectView/MainScene.unity b/CylVision/Assets/ThridParty/KinectView/MainScene.unity new file mode 100644 index 0000000000000000000000000000000000000000..e33c365481238b2b398a372a12a5c3809e9bda70 GIT binary patch literal 29728 zcmeHQeUMzmaes#;BEW$72$nyvS0F$pF(43_s=#UY?(}iC4jp$A5Qm_9cl+*ct-XDh zw|nBwhGJ6$2PNe)PC2m+0gJf&hd=nJN}Nz}8N`Pxq=Hj8RVmx4B;bT3#CD}9Q+!mB znDnoE`fbm9Z{(TkQ>|^aYP6*u&NPD+gu>|VQ}d&vt>m)J)mke~HZQg!Y9wy-Q~l8-nhqyN z!z607q^)2TRXvIxBvkLCe|Q&yTWa-ac!=q|4H%RZ33)*p4O_Dg2@D}wBxXh^cX$|X zw4$UD)|viFsg%|#qMcPGuy_AS2^#17D)N$1r5gaIQe<&pZ{CF z{(<$%$Yjq2Qu72ORbZ!kE>O<}+Wm%ff#987Rg114iL2u0W&Iq;bKXztqNJ?<)742T z@_%wp(z`*I5_^5llghI(6wSA0^SbgqQkN@tW#e>%)YVseZvj%Cjgf_VtCnZueWr3( zHcAGmD;sMIkg$7Qrpt(JQcq>4yXM}mH3)jU);I00mDc@o7d}E7y@lUf_$D;jTljC< zg)ffBNJt@)T3GK72I2;VsN@a)#SxBC<^7(4xVn^gd#vl$)$Oq^T35HH$VG!g*ooNX zBlR5ZZU;e6_08=zCk2P>^X#R=jX0rj@?bnSPXb5#1sEXblCz7A@I0m^8?}Yo$^JXa zD5oLQG^Sh>nV%19E~X4kWn=QTiRoI>Y;j!L>N8*(9NA4LlcFYh5_d+6t%W4Ia0u~( zVVXsrL~ol(s47_ABzoISLPE+-qSaMOI5UY?gnLJ#=4@v!J=G=cW}U3@R@kad$%emk zDrnVN5R|#!GYK2b={T9oYdz(?x6|`v;E=T*3tz{~ z{M^qcuUvp#Z_p9(G)c$ycq*)q#Ski50njB@F9xehtYfC@ao7qLb6OGQNK(GU$%)2KP|tCEyYDC!=rJt#tcJ6dkT;k!pXH|*i(H44BO*JB`EcUVXO7D zJj>8Hjbg+*U#kIuo#n<;dj;Is<3^=sxv?5g%R7d2wpOpwX+PUhtNCC>u#mGVALtIrfEOO{%tn+Wa<)mLm? zNZY7cANRRHZ?1_H0e!g+`U3ti-aK6NXuqzIb|8bM|?vV6RD_Ph(24E5E*0ZOw9fp4RkmW~187toZAm>hzErG&iNGdTqWmUk@8{8sRBY4|_U~ zY;~!_bv)8#lX|rjPnY)6xG=At3+Xm9?2FN$&BilHI6qsPV)bH`YfzSUWn?UBDOJW+ zzxrIv?dJ0erf(IjVhz+Ri2aT7}V^mu%pZQw0%&p6! z9*Y`PiXAj&a663KwaQl6U==Q?&i#h_volO)qLu^jVkx-_qJ6t~;cE?&BIY#A83jnr zG2S*b#JM-3HZ=YSJQ8!OBT#8Lu{LD6}!ptF;EAt1_~d zL6Op4jxS8oY|vEJrXuO7H4idy`JTcgXc<10xwNO&8YoRq2k|9K*laZf+8lvgq@?5O z(`8eRKMaJesoAkOZn3)d%|eF>Z-lHpP)2gEDvrO?P^9W@1sdPNdp9owTvs+ zL0Mk%yM#`yN@Hr40*Y&ph8JG)W$p^ zwUKT`%&jXM)KMhcS2*-x-SjnUq);i_SC}TiwLxVs?W?s$gvW{dn)+2j*L2w$BH(MA zUYC7qB<<$9?3*M(O6d-SdpeR$U$js^&x2zOtlp!(aMHZUFPB<&5S!>MTJY(mlDn7nr2`&*zk&{+W@f=s6|6w{L>x{gca zkIu|tEK!~>2{-q?Tf&3!3yj?|eM~sEP55M6W*0XAg=@wx=&q-t*4b2~GKmsMQJkVq z-$Zg!c7c&H(1Wb^zQN>aDQhmeMjPLV5ipjr(b=VDZK~rAlf2pc07q8loXa=d+?mv7 z@HH7IGS8YgGg`0{vlc|ZYvs_!=g4E79iOM5am3<`t-ZLC)}%n3kzB38xUtu5udGc8 z%8Vo~a&ArfcB9LhwAMmZb1! z|1Gs7uj(A>jpJK5uutA1qyTsJ?95w!UI1Jo$=;&#%9nMLH%K>7NY{W9yXb--&x!Ah zm8ga~Z^DTmU$EuEi62vt@++y0%0jgkZ?84!OT21nbz4rQ;%T>opy$uMH7upO zy&Ei7S6fceH`7%>bkxRVv~4@GmAT0p85@oZ^62{RbbfUG-CK!y5$ZC!{>IIg%jjC) zxoC7fr`e6JY&O#?!4x{&voskmdfNcsVs~+Kt=ZOHWzNmDwp)>Oe7A-5m~IY6jTv{g zXdP!B3;LtTbOxV99=31H1>eKo5>}(}`G|h30h8z3c0uQ{@NNu(CwpY+Tl_8~Va+}- zOlmzh5=BP|dHUn?aceM+_tYX5FnhEBmJ1bP_CNuMIr8?9S$SN>7NY2!p-%0KjPsG` zr$EmoRu^r#SH6tal@Zn+t_dEKUSvv!h6m#p7@1nG$r5qfxil|9P^;I96lKT$SPh4J zZ&~}(UBex@%Q31%hH2l>F)UV-skkfVSlF16o_i`RV^6TQD~*|=Kye0BGyrd)x~VQX zOimpHQseF{8hR$HwP0m4Q)G3PPLZIDMa{Ur!1pjg-0H1tzde1N)m1>&0UD@T$4md*s0~rI6UPtneJIg?KBcF~D9bNLoujfMN zzPY^g$*qrYZk|qa829}iZkyj!J_UO$tkxC;`P`q0+*!%Lb`V?~{3jF>8TNF^uNTyi z$jODc&rwODkQYBBex6%lTkde2mnp}ql#4@renI&S1nX@)abLdo+hrsQ8c)B8 z^4p`mQ5_zK{*)E_crXN-RCg3C;pJWsxRct_wVax;uJ`M(`^)Hxl|H+oqJU^dR2b7NZqP zN`~)U@TCZB=A6k%xk6LcK+4ypv@WB2J7Ypu>RyP>?ufO=xnZ%pU`5IkS54_L;W?7s zn6N&iwx46db0n!HBtcSw&D6HpZL?r1E-n(t)$Z|mI?89e;%$~4y0h(cxoL=udrD!r zu_aEf4-@(MK)Zns%2HENWdoG14JWm9DKJy;5vt~UrfuHos$t7GbDnz|w3()&Zl?>4 z#BeoJ#ouO26&X0UPrka#b?ySxZQX8l`!AAO5(cv#sb9|V8RpjSqjgUM zHzqPI^i8n3M#HRs>SM{ciL+A*B+25D@shT-)W||^9>f2~c{Sda-9fWdaM`ey=PC|mdXDg$j z{j2O42^WXxASWaN<<+l_tsT1#whjWLTEAA=SJdr0hQ=2XTn`!v=jX}2^@#XxuCOE% zG#XZ`>I@e-xK0tdrHXGj)8!+akFzN#@^W1b`Uc^iN{fDdlM#zt+{b7@-B(>xJ;gSB zgBxjl@UXN4KJz<78}4WfEYO$WQbP1q8}A*H1`CBGG}|1mmGPzD?`WOmY>tM6neYsK*&|VFj72jfEZC5+2wQva z4;+7~XSg9Grey134Zn{qU+>AF`^H`vVL!o10Gv0MWe>&LeGE*Yhtl2dn{B)`_%bhO zF9kGS#LB5(7sX5AwItvzH$Dym(kpsL_p-f6P69dE$LX zUrMmwrgzZ8^H&7>9A&PdJletY0KuLk*bwD$bv2>S!JAi}cquWokMde~h+vNsY?NSH zcQe7(5R(%GgF(f!gYPFzimFHv6U z-b1k42nM?Nfk@!pOR%RMj6Rs3`v`Uc4a5Y!D=+t>F2U9jOzBq7zWSU82v#GQ(ufGQ zo)*z(2v&E`G{FuK%=Y(%cmMAC)wFy8%^C~ z3Dzc<#XF8*4-jmE@U$OqC)gTVQ)Plx+;cp^t|6H1+X-loV3wB+Pkr@+PZI1Fs;B+E zkYLx)y1R^E_|adC=|u$l9Kj|iuXHyO>}7(L38r)}CfKF43N77B2sS}5OLykV3y}A2)25)Uw6ZeH_uEEtVVRTzZVkhNrKtB7ZGd~x%iguGhaVz_8Nli zGj;!iV9ye)M6fH}^PdD;b+W*2AQ+ziBG`HdyO!SZJWH@`1ZzVU2q0$s5Wi?flN*7b~}(cl$RtJo7dx41)9Tt$gc} z@#eODyJk+jbl)Fbc@#tSk19~SlY_y(h21=Vp+SD=?nyG#ty*I@{V)f8(K<~uO=+sv zCh14Cm!v|eNrb$|N&KfbGf;43fPx%WGNc=g{2PdER2-y=Wz^M?lS zd~Dynj}CnH!vcN(Uw{4H)B67P!|fk@=D=<1w?c1G`k#wSPu+C-(_0_<#(U4bY31`( zfj)fvr~moJk5tQd{BYGfKd|nT9}?&#KfP)9Gn>Cs{_=&VT>ZkMcl@nD_kHSvFMj{= zXNUgyk=k|NUAT5cp#Qe@hsUpc^!o#UwEynwHop8XmkIQyv$mfw^E;m$dGO?sr7!)% z-<&4Uw7-64e>n)+bj|Pa0RxBWaZh^_svrB^GcS|!KNu3-xDAS4= zARK$e5yjeu_;NGyyBe*KE}m9VW|QA{ zTM`7Y%|0aC7wunrlePoh?$^n`p9`WVLsz8*naoOh*Z#xiuXW|H z;boVHjfc)ef)Ai$1e*>RsjXlr;{Tu`+0m#U)>xrE_#-c@xcDLDk)B_1G0pWn$@j9o7yaw=bvlp^eh22~(0&R*qm(eFKRAc8 zUH_ooa`9ZV?EBey?$$Wk)p>>gq;m%UO6L+j)LPd7d?#edb)dPVU$}+9Q~pq89&N$D zQ@*hPEZ+);j|E)#5BP*_#Ai`LdpqzkqCKt@#5tNHOzsgnT6YEsx2|g(N zQ6%`N_$0F)4DtC7ZKA?@sm?!YaCq|qpBUpWb704e$CK6?*41%{;kGm%R*P% z%Gb9LJFf8ARsP|t1CQKI`PmJ3NO3rFt}@)A-`@0|xzR^YIqpk?N5Ai@gRg~ew1M_y zZi0Ze72dk((C~9skHdDXb;Z~>&_r^=zCzbN_8mGV*p~nSayYm!86E0aV9%p`gCD!z z(SEnY^^V{=nG}CZ2swI=yQ(_x0Y?cTqba(muxADm^b_0R*FitQ zw(9&rCbIJfdPPZXa;L1lY4o{ol<{6U>5|u^*KB{WkJtWUpO5xn*!4d`(sScO)kBCU zXn!f3vF!e$9(d^_okx7$`tWPf<97Wbez4Xxiugjs~)hsz^Ap<{yh1;CI29h1Y^ ze;`JpC{p$B2s|MuvpA8RBP1h^yTo*#L1j#Ndz+m%}Gy zVI-_IO752ep_B0LUV-8z?Xw3oFNgsi4CnPK2aRt%Hq?K|?YH+o|C68e-@Si7+a_T} z*5~b?|2*POWDBrAN7`SewfhkE0Z0tOpMx+Aep5Woplu|4zBauJGSCG`y7x=>w0yRB r=rV~I=sjE4^{;;6z=J2Px%Hc$_|fb`-RvRk9TN85_(W_4pGf}?``J6S literal 0 HcmV?d00001 diff --git a/CylVision/Assets/ThridParty/KinectView/MainScene.unity.meta b/CylVision/Assets/ThridParty/KinectView/MainScene.unity.meta new file mode 100644 index 0000000..83811ec --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/MainScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: be6b0f8f61cfb0546b28fc9e1e07aea7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectView/Materials.meta b/CylVision/Assets/ThridParty/KinectView/Materials.meta new file mode 100644 index 0000000..5194633 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc347fec4001191469ed16345b5e71dc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat b/CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat new file mode 100644 index 0000000000000000000000000000000000000000..979ab189d027876fd222f084e4e258de2761058e GIT binary patch literal 4272 zcmeHK+j1N=5S0T2NFb1K2@nVixp8$a4iF$Dwu2X3sU({?@J4OPyIOmwU5!hlHC~?f zlkypS6{b(OG}ewq@|uV3su{J^N9xv5OPW#Y*dI#0`9vx8DwR|yb$xMZacOW>{ky-v zzd-eO=((r8afKeLRb3fHhJ7F*FW@y*>J=)+wko!)>9-2&)u{Vm^H01vO6&E&7r^(#)iHxfJ&4+A&p zKqA*OB}|O2rsE_5ATcWFfq5nboSs4>31g;tM{fl?J6p~;dYb@{IvUbvdB^sGqzK8B zJLAfiqesRP{SU`xEGzl0z-L1L%@%&rapjJ2ezLJ`47T5f-ZlNuSQsJibm$C1KpwWq zNbeB(vDsU*yMlTTR+6X9{QY2$m_rnQz(a&Vg1)1RkZ~aROp2Had2LSO9M^)?-wqMHF6GsmQgNhOo$Jl2LBqo=7`n+LBHTCpG#xCjGM!b@}U#6g` ztaUR7z9I~WWAX?SS*{O=ugM6B>_VT--bFN#q(eLwG4d?cHiC%J-qVGpPuF0gVoJ9Z9+4WiZg<=C3ke%8fBYJE`4R*!_K_05solr) MDO=kW#;c$I0L6y$nE(I) literal 0 HcmV?d00001 diff --git a/CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat.meta b/CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat.meta new file mode 100644 index 0000000..d6c130b --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Materials/BoneMaterial.mat.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: f2ea145c63353784985576f08398a815 +NativeFormatImporter: + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts.meta b/CylVision/Assets/ThridParty/KinectView/Scripts.meta new file mode 100644 index 0000000..2f38768 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fe8ee5ed16142f4db68624c68e84b89 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs new file mode 100644 index 0000000..288cf9e --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class BodySourceManager : MonoBehaviour +{ + private KinectSensor _Sensor; + private BodyFrameReader _Reader; + private Body[] _Data = null; + + public Body[] GetData() + { + return _Data; + } + + + void Start () + { + _Sensor = KinectSensor.GetDefault(); + + if (_Sensor != null) + { + _Reader = _Sensor.BodyFrameSource.OpenReader(); + + if (!_Sensor.IsOpen) + { + _Sensor.Open(); + } + } + } + + void Update () + { + if (_Reader != null) + { + var frame = _Reader.AcquireLatestFrame(); + if (frame != null) + { + if (_Data == null) + { + _Data = new Body[_Sensor.BodyFrameSource.BodyCount]; + } + + frame.GetAndRefreshBodyData(_Data); + + frame.Dispose(); + frame = null; + } + } + } + + void OnApplicationQuit() + { + if (_Reader != null) + { + _Reader.Dispose(); + _Reader = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs.meta new file mode 100644 index 0000000..39841de --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e74aed0503c9d24290a1ae5438fddc3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs new file mode 100644 index 0000000..71eac3d --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs @@ -0,0 +1,179 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using Kinect = Windows.Kinect; + +public class BodySourceView : MonoBehaviour +{ + public Material BoneMaterial; + public GameObject BodySourceManager; + + private Dictionary _Bodies = new Dictionary(); + private BodySourceManager _BodyManager; + + private Dictionary _BoneMap = new Dictionary() + { + { Kinect.JointType.FootLeft, Kinect.JointType.AnkleLeft }, + { Kinect.JointType.AnkleLeft, Kinect.JointType.KneeLeft }, + { Kinect.JointType.KneeLeft, Kinect.JointType.HipLeft }, + { Kinect.JointType.HipLeft, Kinect.JointType.SpineBase }, + + { Kinect.JointType.FootRight, Kinect.JointType.AnkleRight }, + { Kinect.JointType.AnkleRight, Kinect.JointType.KneeRight }, + { Kinect.JointType.KneeRight, Kinect.JointType.HipRight }, + { Kinect.JointType.HipRight, Kinect.JointType.SpineBase }, + + { Kinect.JointType.HandTipLeft, Kinect.JointType.HandLeft }, + { Kinect.JointType.ThumbLeft, Kinect.JointType.HandLeft }, + { Kinect.JointType.HandLeft, Kinect.JointType.WristLeft }, + { Kinect.JointType.WristLeft, Kinect.JointType.ElbowLeft }, + { Kinect.JointType.ElbowLeft, Kinect.JointType.ShoulderLeft }, + { Kinect.JointType.ShoulderLeft, Kinect.JointType.SpineShoulder }, + + { Kinect.JointType.HandTipRight, Kinect.JointType.HandRight }, + { Kinect.JointType.ThumbRight, Kinect.JointType.HandRight }, + { Kinect.JointType.HandRight, Kinect.JointType.WristRight }, + { Kinect.JointType.WristRight, Kinect.JointType.ElbowRight }, + { Kinect.JointType.ElbowRight, Kinect.JointType.ShoulderRight }, + { Kinect.JointType.ShoulderRight, Kinect.JointType.SpineShoulder }, + + { Kinect.JointType.SpineBase, Kinect.JointType.SpineMid }, + { Kinect.JointType.SpineMid, Kinect.JointType.SpineShoulder }, + { Kinect.JointType.SpineShoulder, Kinect.JointType.Neck }, + { Kinect.JointType.Neck, Kinect.JointType.Head }, + }; + + void Update () + { + if (BodySourceManager == null) + { + return; + } + + _BodyManager = BodySourceManager.GetComponent(); + if (_BodyManager == null) + { + return; + } + + Kinect.Body[] data = _BodyManager.GetData(); + if (data == null) + { + return; + } + + List trackedIds = new List(); + foreach(var body in data) + { + if (body == null) + { + continue; + } + + if(body.IsTracked) + { + trackedIds.Add (body.TrackingId); + } + } + + List knownIds = new List(_Bodies.Keys); + + // First delete untracked bodies + foreach(ulong trackingId in knownIds) + { + if(!trackedIds.Contains(trackingId)) + { + Destroy(_Bodies[trackingId]); + _Bodies.Remove(trackingId); + } + } + + foreach(var body in data) + { + if (body == null) + { + continue; + } + + if(body.IsTracked) + { + if(!_Bodies.ContainsKey(body.TrackingId)) + { + _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId); + } + + RefreshBodyObject(body, _Bodies[body.TrackingId]); + } + } + } + + private GameObject CreateBodyObject(ulong id) + { + GameObject body = new GameObject("Body:" + id); + + for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) + { + GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube); + + LineRenderer lr = jointObj.AddComponent(); + lr.SetVertexCount(2); + lr.material = BoneMaterial; + lr.SetWidth(0.05f, 0.05f); + + jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); + jointObj.name = jt.ToString(); + jointObj.transform.parent = body.transform; + } + + return body; + } + + private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject) + { + for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) + { + Kinect.Joint sourceJoint = body.Joints[jt]; + Kinect.Joint? targetJoint = null; + + if(_BoneMap.ContainsKey(jt)) + { + targetJoint = body.Joints[_BoneMap[jt]]; + } + + Transform jointObj = bodyObject.transform.Find(jt.ToString()); + jointObj.localPosition = GetVector3FromJoint(sourceJoint); + + LineRenderer lr = jointObj.GetComponent(); + if(targetJoint.HasValue) + { + lr.SetPosition(0, jointObj.localPosition); + lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value)); + lr.SetColors(GetColorForState (sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState)); + } + else + { + lr.enabled = false; + } + } + } + + private static Color GetColorForState(Kinect.TrackingState state) + { + switch (state) + { + case Kinect.TrackingState.Tracked: + return Color.green; + + case Kinect.TrackingState.Inferred: + return Color.red; + + default: + return Color.black; + } + } + + private static Vector3 GetVector3FromJoint(Kinect.Joint joint) + { + return new Vector3(joint.Position.X * 10, joint.Position.Y * 10, joint.Position.Z * 10); + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs.meta new file mode 100644 index 0000000..2855453 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/BodySourceView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8821130411451d343a1488e2a9db134e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs new file mode 100644 index 0000000..30d0b75 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs @@ -0,0 +1,78 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class ColorSourceManager : MonoBehaviour +{ + public int ColorWidth { get; private set; } + public int ColorHeight { get; private set; } + + private KinectSensor _Sensor; + private ColorFrameReader _Reader; + private Texture2D _Texture; + private byte[] _Data; + + public Texture2D GetColorTexture() + { + return _Texture; + } + + void Start() + { + _Sensor = KinectSensor.GetDefault(); + + if (_Sensor != null) + { + _Reader = _Sensor.ColorFrameSource.OpenReader(); + + var frameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba); + ColorWidth = frameDesc.Width; + ColorHeight = frameDesc.Height; + + _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.RGBA32, false); + _Data = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels]; + + if (!_Sensor.IsOpen) + { + _Sensor.Open(); + } + } + } + + void Update () + { + if (_Reader != null) + { + var frame = _Reader.AcquireLatestFrame(); + + if (frame != null) + { + frame.CopyConvertedFrameDataToArray(_Data, ColorImageFormat.Rgba); + _Texture.LoadRawTextureData(_Data); + _Texture.Apply(); + + frame.Dispose(); + frame = null; + } + } + } + + void OnApplicationQuit() + { + if (_Reader != null) + { + _Reader.Dispose(); + _Reader = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs.meta new file mode 100644 index 0000000..f16f40f --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92ab5bea6110edb4081e490c0982748d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs new file mode 100644 index 0000000..0b1fd17 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class ColorSourceView : MonoBehaviour +{ + public GameObject ColorSourceManager; + private ColorSourceManager _ColorManager; + + void Start () + { + gameObject.GetComponent().material.SetTextureScale("_MainTex", new Vector2(-1, 1)); + } + + void Update() + { + if (ColorSourceManager == null) + { + return; + } + + _ColorManager = ColorSourceManager.GetComponent(); + if (_ColorManager == null) + { + return; + } + + gameObject.GetComponent().material.mainTexture = _ColorManager.GetColorTexture(); + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs.meta new file mode 100644 index 0000000..ce51abc --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/ColorSourceView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee5302fdf7d10e74fbbbe1a2f7503f46 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs new file mode 100644 index 0000000..5b8500d --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class DepthSourceManager : MonoBehaviour +{ + private KinectSensor _Sensor; + private DepthFrameReader _Reader; + private ushort[] _Data; + + public ushort[] GetData() + { + return _Data; + } + + void Start () + { + _Sensor = KinectSensor.GetDefault(); + + if (_Sensor != null) + { + _Reader = _Sensor.DepthFrameSource.OpenReader(); + _Data = new ushort[_Sensor.DepthFrameSource.FrameDescription.LengthInPixels]; + } + } + + void Update () + { + if (_Reader != null) + { + var frame = _Reader.AcquireLatestFrame(); + if (frame != null) + { + frame.CopyFrameDataToArray(_Data); + frame.Dispose(); + frame = null; + } + } + } + + void OnApplicationQuit() + { + if (_Reader != null) + { + _Reader.Dispose(); + _Reader = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs.meta new file mode 100644 index 0000000..06de839 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1cd019cdd7a54604b9ae8091d242d8a4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs new file mode 100644 index 0000000..64e3a50 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs @@ -0,0 +1,252 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public enum DepthViewMode +{ + SeparateSourceReaders, + MultiSourceReader, +} + +public class DepthSourceView : MonoBehaviour +{ + public DepthViewMode ViewMode = DepthViewMode.SeparateSourceReaders; + + public GameObject ColorSourceManager; + public GameObject DepthSourceManager; + public GameObject MultiSourceManager; + + private KinectSensor _Sensor; + private CoordinateMapper _Mapper; + private Mesh _Mesh; + private Vector3[] _Vertices; + private Vector2[] _UV; + private int[] _Triangles; + + // Only works at 4 right now + private const int _DownsampleSize = 4; + private const double _DepthScale = 0.1f; + private const int _Speed = 50; + + private MultiSourceManager _MultiManager; + private ColorSourceManager _ColorManager; + private DepthSourceManager _DepthManager; + + void Start() + { + _Sensor = KinectSensor.GetDefault(); + if (_Sensor != null) + { + _Mapper = _Sensor.CoordinateMapper; + var frameDesc = _Sensor.DepthFrameSource.FrameDescription; + + // Downsample to lower resolution + CreateMesh(frameDesc.Width / _DownsampleSize, frameDesc.Height / _DownsampleSize); + + if (!_Sensor.IsOpen) + { + _Sensor.Open(); + } + } + } + + void CreateMesh(int width, int height) + { + _Mesh = new Mesh(); + GetComponent().mesh = _Mesh; + + _Vertices = new Vector3[width * height]; + _UV = new Vector2[width * height]; + _Triangles = new int[6 * ((width - 1) * (height - 1))]; + + int triangleIndex = 0; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + int index = (y * width) + x; + + _Vertices[index] = new Vector3(x, -y, 0); + _UV[index] = new Vector2(((float)x / (float)width), ((float)y / (float)height)); + + // Skip the last row/col + if (x != (width - 1) && y != (height - 1)) + { + int topLeft = index; + int topRight = topLeft + 1; + int bottomLeft = topLeft + width; + int bottomRight = bottomLeft + 1; + + _Triangles[triangleIndex++] = topLeft; + _Triangles[triangleIndex++] = topRight; + _Triangles[triangleIndex++] = bottomLeft; + _Triangles[triangleIndex++] = bottomLeft; + _Triangles[triangleIndex++] = topRight; + _Triangles[triangleIndex++] = bottomRight; + } + } + } + + _Mesh.vertices = _Vertices; + _Mesh.uv = _UV; + _Mesh.triangles = _Triangles; + _Mesh.RecalculateNormals(); + } + + void OnGUI() + { + GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height)); + GUI.TextField(new Rect(Screen.width - 250 , 10, 250, 20), "DepthMode: " + ViewMode.ToString()); + GUI.EndGroup(); + } + + void Update() + { + if (_Sensor == null) + { + return; + } + + if (Input.GetButtonDown("Fire1")) + { + if(ViewMode == DepthViewMode.MultiSourceReader) + { + ViewMode = DepthViewMode.SeparateSourceReaders; + } + else + { + ViewMode = DepthViewMode.MultiSourceReader; + } + } + + float yVal = Input.GetAxis("Horizontal"); + float xVal = -Input.GetAxis("Vertical"); + + transform.Rotate( + (xVal * Time.deltaTime * _Speed), + (yVal * Time.deltaTime * _Speed), + 0, + Space.Self); + + if (ViewMode == DepthViewMode.SeparateSourceReaders) + { + if (ColorSourceManager == null) + { + return; + } + + _ColorManager = ColorSourceManager.GetComponent(); + if (_ColorManager == null) + { + return; + } + + if (DepthSourceManager == null) + { + return; + } + + _DepthManager = DepthSourceManager.GetComponent(); + if (_DepthManager == null) + { + return; + } + + gameObject.GetComponent().material.mainTexture = _ColorManager.GetColorTexture(); + RefreshData(_DepthManager.GetData(), + _ColorManager.ColorWidth, + _ColorManager.ColorHeight); + } + else + { + if (MultiSourceManager == null) + { + return; + } + + _MultiManager = MultiSourceManager.GetComponent(); + if (_MultiManager == null) + { + return; + } + + gameObject.GetComponent().material.mainTexture = _MultiManager.GetColorTexture(); + + RefreshData(_MultiManager.GetDepthData(), + _MultiManager.ColorWidth, + _MultiManager.ColorHeight); + } + } + + private void RefreshData(ushort[] depthData, int colorWidth, int colorHeight) + { + var frameDesc = _Sensor.DepthFrameSource.FrameDescription; + + ColorSpacePoint[] colorSpace = new ColorSpacePoint[depthData.Length]; + _Mapper.MapDepthFrameToColorSpace(depthData, colorSpace); + + for (int y = 0; y < frameDesc.Height; y += _DownsampleSize) + { + for (int x = 0; x < frameDesc.Width; x += _DownsampleSize) + { + int indexX = x / _DownsampleSize; + int indexY = y / _DownsampleSize; + int smallIndex = (indexY * (frameDesc.Width / _DownsampleSize)) + indexX; + + double avg = GetAvg(depthData, x, y, frameDesc.Width, frameDesc.Height); + + avg = avg * _DepthScale; + + _Vertices[smallIndex].z = (float)avg; + + // Update UV mapping with CDRP + var colorSpacePoint = colorSpace[(y * frameDesc.Width) + x]; + _UV[smallIndex] = new Vector2(colorSpacePoint.X / colorWidth, colorSpacePoint.Y / colorHeight); + } + } + + _Mesh.vertices = _Vertices; + _Mesh.uv = _UV; + _Mesh.triangles = _Triangles; + _Mesh.RecalculateNormals(); + } + + private double GetAvg(ushort[] depthData, int x, int y, int width, int height) + { + double sum = 0.0; + + for (int y1 = y; y1 < y + 4; y1++) + { + for (int x1 = x; x1 < x + 4; x1++) + { + int fullIndex = (y1 * width) + x1; + + if (depthData[fullIndex] == 0) + sum += 4500; + else + sum += depthData[fullIndex]; + + } + } + + return sum / 16; + } + + void OnApplicationQuit() + { + if (_Mapper != null) + { + _Mapper = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs.meta new file mode 100644 index 0000000..09bec26 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DepthSourceView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 383e102cbe3bfb34d94c98ea3c2479b4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs new file mode 100644 index 0000000..b6b2ab9 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs @@ -0,0 +1,11 @@ +using UnityEngine; +using System.Collections; + +public class DisableOnStart : MonoBehaviour { + + // Use this for initialization + void Start () + { + gameObject.SetActive (false); + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs.meta new file mode 100644 index 0000000..4dddfaa --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/DisableOnStart.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 61e5c93f5da1e324aa7fd9671db875bc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs new file mode 100644 index 0000000..bdb6b15 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs @@ -0,0 +1,85 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class InfraredSourceManager : MonoBehaviour +{ + private KinectSensor _Sensor; + private InfraredFrameReader _Reader; + private ushort[] _Data; + private byte[] _RawData; + + // I'm not sure this makes sense for the Kinect APIs + // Instead, this logic should be in the VIEW + private Texture2D _Texture; + + public Texture2D GetInfraredTexture() + { + return _Texture; + } + + void Start() + { + _Sensor = KinectSensor.GetDefault(); + if (_Sensor != null) + { + _Reader = _Sensor.InfraredFrameSource.OpenReader(); + var frameDesc = _Sensor.InfraredFrameSource.FrameDescription; + _Data = new ushort[frameDesc.LengthInPixels]; + _RawData = new byte[frameDesc.LengthInPixels * 4]; + _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.BGRA32, false); + + if (!_Sensor.IsOpen) + { + _Sensor.Open(); + } + } + } + + void Update () + { + if (_Reader != null) + { + var frame = _Reader.AcquireLatestFrame(); + if (frame != null) + { + frame.CopyFrameDataToArray(_Data); + + int index = 0; + foreach(var ir in _Data) + { + byte intensity = (byte)(ir >> 8); + _RawData[index++] = intensity; + _RawData[index++] = intensity; + _RawData[index++] = intensity; + _RawData[index++] = 255; // Alpha + } + + _Texture.LoadRawTextureData(_RawData); + _Texture.Apply(); + + frame.Dispose(); + frame = null; + } + } + } + + void OnApplicationQuit() + { + if (_Reader != null) + { + _Reader.Dispose(); + _Reader = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs.meta new file mode 100644 index 0000000..be6708d --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 63eff7f54e54aa049a2331755f3cb99c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs new file mode 100644 index 0000000..9523d9d --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs @@ -0,0 +1,29 @@ +using UnityEngine; +using System.Collections; + +public class InfraredSourceView : MonoBehaviour +{ + public GameObject InfraredSourceManager; + private InfraredSourceManager _InfraredManager; + + void Start () + { + gameObject.GetComponent().material.SetTextureScale("_MainTex", new Vector2(-1, 1)); + } + + void Update() + { + if (InfraredSourceManager == null) + { + return; + } + + _InfraredManager = InfraredSourceManager.GetComponent(); + if (_InfraredManager == null) + { + return; + } + + gameObject.GetComponent().material.mainTexture = _InfraredManager.GetInfraredTexture(); + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs.meta new file mode 100644 index 0000000..5cca658 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/InfraredSourceView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 98f8736f9d8c8e44592c96e57d57c5d4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs b/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs new file mode 100644 index 0000000..1186278 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs @@ -0,0 +1,100 @@ +using UnityEngine; +using System.Collections; +using Windows.Kinect; + +public class MultiSourceManager : MonoBehaviour { + public int ColorWidth { get; private set; } + public int ColorHeight { get; private set; } + + private KinectSensor _Sensor; + private MultiSourceFrameReader _Reader; + private Texture2D _ColorTexture; + private ushort[] _DepthData; + private byte[] _ColorData; + + public Texture2D GetColorTexture() + { + return _ColorTexture; + } + + public ushort[] GetDepthData() + { + return _DepthData; + } + + void Start () + { + _Sensor = KinectSensor.GetDefault(); + + if (_Sensor != null) + { + _Reader = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth); + + var colorFrameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba); + ColorWidth = colorFrameDesc.Width; + ColorHeight = colorFrameDesc.Height; + + _ColorTexture = new Texture2D(colorFrameDesc.Width, colorFrameDesc.Height, TextureFormat.RGBA32, false); + _ColorData = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels]; + + var depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription; + _DepthData = new ushort[depthFrameDesc.LengthInPixels]; + + if (!_Sensor.IsOpen) + { + _Sensor.Open(); + } + } + } + + void Update () + { + if (_Reader != null) + { + var frame = _Reader.AcquireLatestFrame(); + if (frame != null) + { + var colorFrame = frame.ColorFrameReference.AcquireFrame(); + if (colorFrame != null) + { + var depthFrame = frame.DepthFrameReference.AcquireFrame(); + if (depthFrame != null) + { + colorFrame.CopyConvertedFrameDataToArray(_ColorData, ColorImageFormat.Rgba); + _ColorTexture.LoadRawTextureData(_ColorData); + _ColorTexture.Apply(); + + depthFrame.CopyFrameDataToArray(_DepthData); + + depthFrame.Dispose(); + depthFrame = null; + } + + colorFrame.Dispose(); + colorFrame = null; + } + + frame = null; + } + } + } + + void OnApplicationQuit() + { + if (_Reader != null) + { + _Reader.Dispose(); + _Reader = null; + } + + if (_Sensor != null) + { + if (_Sensor.IsOpen) + { + _Sensor.Close(); + } + + _Sensor = null; + } + } +} diff --git a/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs.meta b/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs.meta new file mode 100644 index 0000000..b9b6707 --- /dev/null +++ b/CylVision/Assets/ThridParty/KinectView/Scripts/MultiSourceManager.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f752c4e07617d8d4eb21d4975a2d7c61 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/CylVision/Assets/ThridParty/Windows.meta b/CylVision/Assets/ThridParty/Windows.meta new file mode 100644 index 0000000..72b2a5b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54de333b03246424ba3091b44f9e0114 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Data.meta b/CylVision/Assets/ThridParty/Windows/Data.meta new file mode 100644 index 0000000..b34245f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Data.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5a7a988c4678d55498baf13c6fc26ef0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs new file mode 100644 index 0000000..ee259ee --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs @@ -0,0 +1,73 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Data +{ + // + // Windows.Data.PropertyChangedEventArgs + // + public sealed partial class PropertyChangedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal PropertyChangedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Data_PropertyChangedEventArgs_AddRefObject(ref _pNative); + } + + ~PropertyChangedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Data_PropertyChangedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Data_PropertyChangedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Data_PropertyChangedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Data_PropertyChangedEventArgs_get_PropertyName(RootSystem.IntPtr pNative); + public string PropertyName + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("PropertyChangedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Data_PropertyChangedEventArgs_get_PropertyName(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + var managedString = RootSystem.Runtime.InteropServices.Marshal.PtrToStringUni(objectPointer); + RootSystem.Runtime.InteropServices.Marshal.FreeCoTaskMem(objectPointer); + return managedString; + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs.meta new file mode 100644 index 0000000..9ece7cb --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Data/PropertyChangedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f717bd2a5c39cc43a49fc8904889932 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect.meta b/CylVision/Assets/ThridParty/Windows/Kinect.meta new file mode 100644 index 0000000..3b278f4 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b566cd4d01a560341b7da441f29bffe5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs new file mode 100644 index 0000000..f786d80 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs @@ -0,0 +1,18 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Activity + // + public enum Activity : int + { + EyeLeftClosed =0, + EyeRightClosed =1, + MouthOpen =2, + MouthMoved =3, + LookingAway =4, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs.meta new file mode 100644 index 0000000..b5a2271 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Activity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec6785f19ac6c494a9957fa63f49fcf5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs new file mode 100644 index 0000000..0cae6f3 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs @@ -0,0 +1,14 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Appearance + // + public enum Appearance : int + { + WearingGlasses =0, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs.meta new file mode 100644 index 0000000..6edf117 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Appearance.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00eb0d9c4964c0b4f9e3090704ff7201 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs new file mode 100644 index 0000000..dcbb064 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs @@ -0,0 +1,240 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeam + // + public sealed partial class AudioBeam : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeam(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeam_AddRefObject(ref _pNative); + } + + ~AudioBeam() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeam_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeam_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioBeam_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.AudioBeamMode Windows_Kinect_AudioBeam_get_AudioBeamMode(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeam_put_AudioBeamMode(RootSystem.IntPtr pNative, Windows.Kinect.AudioBeamMode audioBeamMode); + public Windows.Kinect.AudioBeamMode AudioBeamMode + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + return Windows_Kinect_AudioBeam_get_AudioBeamMode(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + Windows_Kinect_AudioBeam_put_AudioBeamMode(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeam_get_AudioSource(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioSource AudioSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeam_get_AudioSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_AudioBeam_get_BeamAngle(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeam_put_BeamAngle(RootSystem.IntPtr pNative, float beamAngle); + public float BeamAngle + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + return Windows_Kinect_AudioBeam_get_BeamAngle(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + Windows_Kinect_AudioBeam_put_BeamAngle(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_AudioBeam_get_BeamAngleConfidence(RootSystem.IntPtr pNative); + public float BeamAngleConfidence + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + return Windows_Kinect_AudioBeam_get_BeamAngleConfidence(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeam_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeam"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeam_get_RelativeTime(_pNative)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeam_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_AudioBeam_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_AudioBeam_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + private void __EventCleanup() + { + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_AudioBeam_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs.meta new file mode 100644 index 0000000..db619b3 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeam.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e64f7eb8de6f72e42874eb2ea7c01be5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs new file mode 100644 index 0000000..07e386b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs @@ -0,0 +1,114 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamFrame + // + public sealed partial class AudioBeamFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamFrame_AddRefObject(ref _pNative); + } + + ~AudioBeamFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrame_AddRefObject(ref RootSystem.IntPtr pNative); + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeamFrame_get_AudioBeam(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioBeam AudioBeam + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeamFrame_get_AudioBeam(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioBeam(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeamFrame_get_AudioSource(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioSource AudioSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeamFrame_get_AudioSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeamFrame_get_Duration(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan Duration + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamFrame_get_Duration(_pNative)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeamFrame_get_RelativeTimeStart(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTimeStart + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamFrame_get_RelativeTimeStart(_pNative)); + } + } + + + // Public Methods + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs.meta new file mode 100644 index 0000000..3f62a2e --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ff93fd69396b944ea1e0d067cf5b091 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs new file mode 100644 index 0000000..73c443b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamFrameArrivedEventArgs + // + public sealed partial class AudioBeamFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~AudioBeamFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioBeamFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeamFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioBeamFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeamFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioBeamFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..32d8bd0 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bb78a9668fb2c694881a216e349cb1e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs new file mode 100644 index 0000000..757ea2e --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs @@ -0,0 +1,71 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamFrameList + // + public sealed partial class AudioBeamFrameList : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamFrameList(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamFrameList_AddRefObject(ref _pNative); + } + + ~AudioBeamFrameList() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameList_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameList_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_AudioBeamFrameList_Dispose(_pNative); + } + Windows_Kinect_AudioBeamFrameList_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameList_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs.meta new file mode 100644 index 0000000..c73cad1 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe7ef6722da9a6d42b589d3f8b35b6f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs new file mode 100644 index 0000000..e7212b3 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs @@ -0,0 +1,309 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamFrameReader + // + public sealed partial class AudioBeamFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamFrameReader_AddRefObject(ref _pNative); + } + + ~AudioBeamFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_AudioBeamFrameReader_Dispose(_pNative); + } + Windows_Kinect_AudioBeamFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioBeamFrameReader_get_AudioSource(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioSource AudioSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioBeamFrameReader_get_AudioSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_AudioBeamFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader"); + } + + return Windows_Kinect_AudioBeamFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader"); + } + + Windows_Kinect_AudioBeamFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.AudioBeamFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate(Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_AudioBeamFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_AudioBeamFrameReader_add_FrameArrived(_pNative, Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_AudioBeamFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_AudioBeamFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames_Length(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize); + public RootSystem.Collections.Generic.IList AcquireLatestBeamFrames() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReader"); + } + + int outCollectionSize = Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames_Length(_pNative); + var outCollection = new RootSystem.IntPtr[outCollectionSize]; + var managedCollection = new Windows.Kinect.AudioBeamFrame[outCollectionSize]; + + outCollectionSize = Windows_Kinect_AudioBeamFrameReader_AcquireLatestBeamFrames(_pNative, outCollection, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i(outCollection[i], n => new Windows.Kinect.AudioBeamFrame(n)); + + managedCollection[i] = obj; + } + return managedCollection; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_AudioBeamFrameReader_add_FrameArrived(_pNative, Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_AudioBeamFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_AudioBeamFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs.meta new file mode 100644 index 0000000..06ee234 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df51c172437a76942a0ec4a4f1438a8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs new file mode 100644 index 0000000..76b8091 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs @@ -0,0 +1,101 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamFrameReference + // + public sealed partial class AudioBeamFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamFrameReference_AddRefObject(ref _pNative); + } + + ~AudioBeamFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioBeamFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeamFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamFrameReference_AcquireBeamFrames_Length(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamFrameReference_AcquireBeamFrames(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize); + public RootSystem.Collections.Generic.IList AcquireBeamFrames() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamFrameReference"); + } + + int outCollectionSize = Windows_Kinect_AudioBeamFrameReference_AcquireBeamFrames_Length(_pNative); + var outCollection = new RootSystem.IntPtr[outCollectionSize]; + var managedCollection = new Windows.Kinect.AudioBeamFrame[outCollectionSize]; + + outCollectionSize = Windows_Kinect_AudioBeamFrameReference_AcquireBeamFrames(_pNative, outCollection, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i(outCollection[i], n => new Windows.Kinect.AudioBeamFrame(n)); + + managedCollection[i] = obj; + } + return managedCollection; + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs.meta new file mode 100644 index 0000000..b7791af --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fe91384e0a914a4985b0cc2f1026a72 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs new file mode 100644 index 0000000..8df2d36 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs @@ -0,0 +1,15 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamMode + // + public enum AudioBeamMode : int + { + Automatic =0, + Manual =1, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs.meta new file mode 100644 index 0000000..2a859a0 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f287bc065b7e7a4faa7cf96c175eabb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs new file mode 100644 index 0000000..7d79042 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs @@ -0,0 +1,212 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBeamSubFrame + // + public sealed partial class AudioBeamSubFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBeamSubFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBeamSubFrame_AddRefObject(ref _pNative); + } + + ~AudioBeamSubFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamSubFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamSubFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_AudioBeamSubFrame_Dispose(_pNative); + } + Windows_Kinect_AudioBeamSubFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.AudioBeamMode Windows_Kinect_AudioBeamSubFrame_get_AudioBeamMode(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioBeamMode AudioBeamMode + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return Windows_Kinect_AudioBeamSubFrame_get_AudioBeamMode(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations_Length(RootSystem.IntPtr pNative); + public RootSystem.Collections.Generic.IList AudioBodyCorrelations + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + int outCollectionSize = Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations_Length(_pNative); + var outCollection = new RootSystem.IntPtr[outCollectionSize]; + var managedCollection = new Windows.Kinect.AudioBodyCorrelation[outCollectionSize]; + + outCollectionSize = Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations(_pNative, outCollection, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i(outCollection[i], n => new Windows.Kinect.AudioBodyCorrelation(n)); + + managedCollection[i] = obj; + } + return managedCollection; + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_AudioBeamSubFrame_get_BeamAngle(RootSystem.IntPtr pNative); + public float BeamAngle + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return Windows_Kinect_AudioBeamSubFrame_get_BeamAngle(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_AudioBeamSubFrame_get_BeamAngleConfidence(RootSystem.IntPtr pNative); + public float BeamAngleConfidence + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return Windows_Kinect_AudioBeamSubFrame_get_BeamAngleConfidence(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeamSubFrame_get_Duration(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan Duration + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamSubFrame_get_Duration(_pNative)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern uint Windows_Kinect_AudioBeamSubFrame_get_FrameLengthInBytes(RootSystem.IntPtr pNative); + public uint FrameLengthInBytes + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return Windows_Kinect_AudioBeamSubFrame_get_FrameLengthInBytes(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioBeamSubFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamSubFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyFrameDataToArray(byte[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBeamSubFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs.meta new file mode 100644 index 0000000..e8e7054 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBeamSubFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e3bf3859145801247a7f6d4dcd90b2be +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs new file mode 100644 index 0000000..a469055 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs @@ -0,0 +1,68 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioBodyCorrelation + // + public sealed partial class AudioBodyCorrelation : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioBodyCorrelation(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioBodyCorrelation_AddRefObject(ref _pNative); + } + + ~AudioBodyCorrelation() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBodyCorrelation_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioBodyCorrelation_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioBodyCorrelation_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern ulong Windows_Kinect_AudioBodyCorrelation_get_BodyTrackingId(RootSystem.IntPtr pNative); + public ulong BodyTrackingId + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioBodyCorrelation"); + } + + return Windows_Kinect_AudioBodyCorrelation_get_BodyTrackingId(_pNative); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs.meta new file mode 100644 index 0000000..4460d2f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioBodyCorrelation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f12e3715b57390a47aeecc0046c6d6ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs new file mode 100644 index 0000000..1191d0d --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs @@ -0,0 +1,361 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.AudioSource + // + public sealed partial class AudioSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal AudioSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_AudioSource_AddRefObject(ref _pNative); + } + + ~AudioSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_AudioSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioSource_get_AudioBeams(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_AudioSource_get_AudioBeams_Length(RootSystem.IntPtr pNative); + public RootSystem.Collections.Generic.IList AudioBeams + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + int outCollectionSize = Windows_Kinect_AudioSource_get_AudioBeams_Length(_pNative); + var outCollection = new RootSystem.IntPtr[outCollectionSize]; + var managedCollection = new Windows.Kinect.AudioBeam[outCollectionSize]; + + outCollectionSize = Windows_Kinect_AudioSource_get_AudioBeams(_pNative, outCollection, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i(outCollection[i], n => new Windows.Kinect.AudioBeam(n)); + + managedCollection[i] = obj; + } + return managedCollection; + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_AudioSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + return Windows_Kinect_AudioSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern uint Windows_Kinect_AudioSource_get_MaxSubFrameCount(RootSystem.IntPtr pNative); + public uint MaxSubFrameCount + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + return Windows_Kinect_AudioSource_get_MaxSubFrameCount(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_AudioSource_get_SubFrameDuration(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan SubFrameDuration + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioSource_get_SubFrameDuration(_pNative)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern uint Windows_Kinect_AudioSource_get_SubFrameLengthInBytes(RootSystem.IntPtr pNative); + public uint SubFrameLengthInBytes + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + return Windows_Kinect_AudioSource_get_SubFrameLengthInBytes(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.KinectAudioCalibrationState Windows_Kinect_AudioSource_get_AudioCalibrationState(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectAudioCalibrationState AudioCalibrationState + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + return Windows_Kinect_AudioSource_get_AudioCalibrationState(_pNative); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_AudioSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_AudioSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_AudioSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_AudioSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_AudioSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_AudioSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioBeamFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("AudioSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_AudioSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioBeamFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_AudioSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_AudioSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs.meta new file mode 100644 index 0000000..cbe02dc --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/AudioSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cb60632e999b8d44cb5cfd848e264abf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Body.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Body.cs new file mode 100644 index 0000000..744d071 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Body.cs @@ -0,0 +1,355 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Body + // + public sealed partial class Body : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal Body(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_Body_AddRefObject(ref _pNative); + } + + ~Body() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_Body_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_Body_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_Body_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + 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); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_Body_get_Activities_Length(RootSystem.IntPtr pNative); + public RootSystem.Collections.Generic.Dictionary Activities + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + int outCollectionSize = Windows_Kinect_Body_get_Activities_Length(_pNative); + var outKeys = new Windows.Kinect.Activity[outCollectionSize]; + var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; + var managedDictionary = new RootSystem.Collections.Generic.Dictionary(); + + outCollectionSize = Windows_Kinect_Body_get_Activities(_pNative, outKeys, outValues, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i Appearance + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + int outCollectionSize = Windows_Kinect_Body_get_Appearance_Length(_pNative); + var outKeys = new Windows.Kinect.Appearance[outCollectionSize]; + var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; + var managedDictionary = new RootSystem.Collections.Generic.Dictionary(); + + outCollectionSize = Windows_Kinect_Body_get_Appearance(_pNative, outKeys, outValues, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i Expressions + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + int outCollectionSize = Windows_Kinect_Body_get_Expressions_Length(_pNative); + var outKeys = new Windows.Kinect.Expression[outCollectionSize]; + var outValues = new Windows.Kinect.DetectionResult[outCollectionSize]; + var managedDictionary = new RootSystem.Collections.Generic.Dictionary(); + + outCollectionSize = Windows_Kinect_Body_get_Expressions(_pNative, outKeys, outValues, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i JointOrientations + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + int outCollectionSize = Windows_Kinect_Body_get_JointOrientations_Length(_pNative); + var outKeys = new Windows.Kinect.JointType[outCollectionSize]; + var outValues = new Windows.Kinect.JointOrientation[outCollectionSize]; + var managedDictionary = new RootSystem.Collections.Generic.Dictionary(); + + outCollectionSize = Windows_Kinect_Body_get_JointOrientations(_pNative, outKeys, outValues, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i Joints + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("Body"); + } + + int outCollectionSize = Windows_Kinect_Body_get_Joints_Length(_pNative); + var outKeys = new Windows.Kinect.JointType[outCollectionSize]; + var outValues = new Windows.Kinect.Joint[outCollectionSize]; + var managedDictionary = new RootSystem.Collections.Generic.Dictionary(); + + outCollectionSize = Windows_Kinect_Body_get_Joints(_pNative, outKeys, outValues, outCollectionSize); + Helper.ExceptionHelper.CheckLastError(); + for(int i=0;i(_pNative); + + if (disposing) + { + Windows_Kinect_BodyFrame_Dispose(_pNative); + } + Windows_Kinect_BodyFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_BodyFrame_get_BodyCount(RootSystem.IntPtr pNative); + public int BodyCount + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrame"); + } + + return Windows_Kinect_BodyFrame_get_BodyCount(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrame_get_BodyFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameSource BodyFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrame_get_BodyFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrame_get_FloorClipPlane(RootSystem.IntPtr pNative); + public Windows.Kinect.Vector4 FloorClipPlane + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrame"); + } + + var objectPointer = Windows_Kinect_BodyFrame_get_FloorClipPlane(_pNative); + Helper.ExceptionHelper.CheckLastError(); + var obj = (Windows.Kinect.Vector4)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.Vector4)); + Windows.Kinect.KinectUnityAddinUtils.FreeMemory(objectPointer); + return obj; + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_BodyFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_BodyFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrame.cs.meta new file mode 100644 index 0000000..4ed6762 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19d23b65a55461b4c8fcfc815e9a8be5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs new file mode 100644 index 0000000..78c1e2e --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyFrameArrivedEventArgs + // + public sealed partial class BodyFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~BodyFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..f3c9f28 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 676ce9850965f6d4fad5e20fa2a8da30 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs new file mode 100644 index 0000000..981d83f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyFrameReader + // + public sealed partial class BodyFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyFrameReader_AddRefObject(ref _pNative); + } + + ~BodyFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_BodyFrameReader_Dispose(_pNative); + } + Windows_Kinect_BodyFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameReader_get_BodyFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameSource BodyFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameReader_get_BodyFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_BodyFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReader"); + } + + return Windows_Kinect_BodyFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReader"); + } + + Windows_Kinect_BodyFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_BodyFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.BodyFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate(Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyFrameReader_add_FrameArrived(_pNative, Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyFrameReader_add_FrameArrived(_pNative, Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_BodyFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs.meta new file mode 100644 index 0000000..822b391 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3af2f300d248d614eb0f026c16be6e51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs new file mode 100644 index 0000000..e6cd68a --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyFrameReference + // + public sealed partial class BodyFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyFrameReference_AddRefObject(ref _pNative); + } + + ~BodyFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_BodyFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_BodyFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs.meta new file mode 100644 index 0000000..1bfd3be --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 083a7736def5ad3429a51cc96a6c4564 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs new file mode 100644 index 0000000..20bc0be --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs @@ -0,0 +1,308 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyFrameSource + // + public sealed partial class BodyFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyFrameSource_AddRefObject(ref _pNative); + } + + ~BodyFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_BodyFrameSource_get_BodyCount(RootSystem.IntPtr pNative); + public int BodyCount + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + return Windows_Kinect_BodyFrameSource_get_BodyCount(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_BodyFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + return Windows_Kinect_BodyFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameReader(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_OverrideHandTracking(RootSystem.IntPtr pNative, ulong trackingId); + public void OverrideHandTracking(ulong trackingId) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + Windows_Kinect_BodyFrameSource_OverrideHandTracking(_pNative, trackingId); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyFrameSource_OverrideHandTracking_1(RootSystem.IntPtr pNative, ulong oldTrackingId, ulong newTrackingId); + public void OverrideHandTracking(ulong oldTrackingId, ulong newTrackingId) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyFrameSource"); + } + + Windows_Kinect_BodyFrameSource_OverrideHandTracking_1(_pNative, oldTrackingId, newTrackingId); + Helper.ExceptionHelper.CheckLastError(); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs.meta new file mode 100644 index 0000000..9c99420 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3679e372811a218438e365b6da52873c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs new file mode 100644 index 0000000..46f8311 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs @@ -0,0 +1,147 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyIndexFrame + // + public sealed partial class BodyIndexFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyIndexFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyIndexFrame_AddRefObject(ref _pNative); + } + + ~BodyIndexFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_BodyIndexFrame_Dispose(_pNative); + } + Windows_Kinect_BodyIndexFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrame_get_BodyIndexFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameSource BodyIndexFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrame_get_BodyIndexFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrame_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrame_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_BodyIndexFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_BodyIndexFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyFrameDataToArray(byte[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_BodyIndexFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs.meta new file mode 100644 index 0000000..9b5deed --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 31029a9c200fe984790d50a6d2875e32 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs new file mode 100644 index 0000000..5f61069 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyIndexFrameArrivedEventArgs + // + public sealed partial class BodyIndexFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyIndexFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyIndexFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~BodyIndexFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyIndexFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..c16b674 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 673826e3a38138946b030da95a1d0f95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs new file mode 100644 index 0000000..d12ae3f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyIndexFrameReader + // + public sealed partial class BodyIndexFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyIndexFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyIndexFrameReader_AddRefObject(ref _pNative); + } + + ~BodyIndexFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_BodyIndexFrameReader_Dispose(_pNative); + } + Windows_Kinect_BodyIndexFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameReader_get_BodyIndexFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameSource BodyIndexFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameReader_get_BodyIndexFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_BodyIndexFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReader"); + } + + return Windows_Kinect_BodyIndexFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReader"); + } + + Windows_Kinect_BodyIndexFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.BodyIndexFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate(Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyIndexFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyIndexFrameReader_add_FrameArrived(_pNative, Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyIndexFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyIndexFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyIndexFrameReader_add_FrameArrived(_pNative, Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_BodyIndexFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyIndexFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs.meta new file mode 100644 index 0000000..14f6daa --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a9ba9eb393e51241bb15db5d3bf3390 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs new file mode 100644 index 0000000..822a944 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyIndexFrameReference + // + public sealed partial class BodyIndexFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyIndexFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyIndexFrameReference_AddRefObject(ref _pNative); + } + + ~BodyIndexFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyIndexFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_BodyIndexFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_BodyIndexFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs.meta new file mode 100644 index 0000000..7630484 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ee08767e1297454a93a5759b975860d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs new file mode 100644 index 0000000..e6747ad --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs @@ -0,0 +1,289 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.BodyIndexFrameSource + // + public sealed partial class BodyIndexFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal BodyIndexFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_BodyIndexFrameSource_AddRefObject(ref _pNative); + } + + ~BodyIndexFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_BodyIndexFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameSource_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameSource_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_BodyIndexFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameSource"); + } + + return Windows_Kinect_BodyIndexFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyIndexFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyIndexFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_BodyIndexFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_BodyIndexFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_BodyIndexFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_BodyIndexFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("BodyIndexFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_BodyIndexFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyIndexFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_BodyIndexFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs.meta new file mode 100644 index 0000000..72bbb8f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/BodyIndexFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7568d115ed2fcca4ba26af8d7e3252c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs b/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs new file mode 100644 index 0000000..16818a0 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs @@ -0,0 +1,47 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.CameraSpacePoint + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct CameraSpacePoint + { + public float X { get; set; } + public float Y { get; set; } + public float Z { get; set; } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is CameraSpacePoint)) + { + return false; + } + + return this.Equals((CameraSpacePoint)obj); + } + + public bool Equals(CameraSpacePoint obj) + { + return X.Equals(obj.X) && Y.Equals(obj.Y) && Z.Equals(obj.Z); + } + + public static bool operator ==(CameraSpacePoint a, CameraSpacePoint b) + { + return a.Equals(b); + } + + public static bool operator !=(CameraSpacePoint a, CameraSpacePoint b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs.meta new file mode 100644 index 0000000..aa5e11c --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CameraSpacePoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ef37675a811881f44be680e69695e9e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs new file mode 100644 index 0000000..4d248a9 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs @@ -0,0 +1,113 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorCameraSettings + // + public sealed partial class ColorCameraSettings : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorCameraSettings(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorCameraSettings_AddRefObject(ref _pNative); + } + + ~ColorCameraSettings() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorCameraSettings_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorCameraSettings_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_ColorCameraSettings_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_ColorCameraSettings_get_ExposureTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan ExposureTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorCameraSettings"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_ColorCameraSettings_get_ExposureTime(_pNative)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_ColorCameraSettings_get_FrameInterval(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan FrameInterval + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorCameraSettings"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_ColorCameraSettings_get_FrameInterval(_pNative)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_ColorCameraSettings_get_Gain(RootSystem.IntPtr pNative); + public float Gain + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorCameraSettings"); + } + + return Windows_Kinect_ColorCameraSettings_get_Gain(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_ColorCameraSettings_get_Gamma(RootSystem.IntPtr pNative); + public float Gamma + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorCameraSettings"); + } + + return Windows_Kinect_ColorCameraSettings_get_Gamma(_pNative); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs.meta new file mode 100644 index 0000000..ae7fe42 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorCameraSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f199f6bb5e11b941b4c707a6783daaa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs new file mode 100644 index 0000000..9f3a6dd --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs @@ -0,0 +1,218 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorFrame + // + public sealed partial class ColorFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorFrame_AddRefObject(ref _pNative); + } + + ~ColorFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_ColorFrame_Dispose(_pNative); + } + Windows_Kinect_ColorFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrame_get_ColorCameraSettings(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorCameraSettings ColorCameraSettings + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrame_get_ColorCameraSettings(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorCameraSettings(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrame_get_ColorFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameSource ColorFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrame_get_ColorFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrame_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrame_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.ColorImageFormat Windows_Kinect_ColorFrame_get_RawColorImageFormat(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorImageFormat RawColorImageFormat + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + return Windows_Kinect_ColorFrame_get_RawColorImageFormat(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_ColorFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_ColorFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrame_CopyRawFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyRawFrameDataToArray(byte[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_ColorFrame_CopyRawFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrame_CopyConvertedFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize, Windows.Kinect.ColorImageFormat colorFormat); + public void CopyConvertedFrameDataToArray(byte[] frameData, Windows.Kinect.ColorImageFormat colorFormat) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_ColorFrame_CopyConvertedFrameDataToArray(_pNative, _frameData, frameData.Length, colorFormat); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrame_CreateFrameDescription(RootSystem.IntPtr pNative, Windows.Kinect.ColorImageFormat format); + public Windows.Kinect.FrameDescription CreateFrameDescription(Windows.Kinect.ColorImageFormat format) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrame_CreateFrameDescription(_pNative, format); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs.meta new file mode 100644 index 0000000..c00d14b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4e3ef938a829c1d4385d938971be0b73 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs new file mode 100644 index 0000000..c0481d9 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorFrameArrivedEventArgs + // + public sealed partial class ColorFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~ColorFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_ColorFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..f953e66 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 383ab6b5e32edbc4ca3eca80db481330 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs new file mode 100644 index 0000000..5e6ab54 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorFrameReader + // + public sealed partial class ColorFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorFrameReader_AddRefObject(ref _pNative); + } + + ~ColorFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_ColorFrameReader_Dispose(_pNative); + } + Windows_Kinect_ColorFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameReader_get_ColorFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameSource ColorFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameReader_get_ColorFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_ColorFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReader"); + } + + return Windows_Kinect_ColorFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReader"); + } + + Windows_Kinect_ColorFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_ColorFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.ColorFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate(Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_ColorFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_ColorFrameReader_add_FrameArrived(_pNative, Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_ColorFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_ColorFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_ColorFrameReader_add_FrameArrived(_pNative, Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_ColorFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs.meta new file mode 100644 index 0000000..ee35cd7 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c8a043d45b0ce641bfe872c2654ec00 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs new file mode 100644 index 0000000..ccd0b14 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorFrameReference + // + public sealed partial class ColorFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorFrameReference_AddRefObject(ref _pNative); + } + + ~ColorFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_ColorFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_ColorFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_ColorFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs.meta new file mode 100644 index 0000000..83f638c --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 05fb49d39d96f5a4ea512141fab5cff6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs new file mode 100644 index 0000000..4f4e4ba --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs @@ -0,0 +1,308 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorFrameSource + // + public sealed partial class ColorFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal ColorFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_ColorFrameSource_AddRefObject(ref _pNative); + } + + ~ColorFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_ColorFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameSource_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameSource_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_ColorFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameSource"); + } + + return Windows_Kinect_ColorFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_ColorFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_ColorFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_ColorFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_ColorFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_ColorFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameReader(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_ColorFrameSource_CreateFrameDescription(RootSystem.IntPtr pNative, Windows.Kinect.ColorImageFormat format); + public Windows.Kinect.FrameDescription CreateFrameDescription(Windows.Kinect.ColorImageFormat format) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("ColorFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_ColorFrameSource_CreateFrameDescription(_pNative, format); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_ColorFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_ColorFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs.meta new file mode 100644 index 0000000..4c7ede5 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 31be1a3a8cdc0d1408a7eada947fe966 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs new file mode 100644 index 0000000..7c2f7c9 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs @@ -0,0 +1,19 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorImageFormat + // + public enum ColorImageFormat : int + { + None =0, + Rgba =1, + Yuv =2, + Bgra =3, + Bayer =4, + Yuy2 =5, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs.meta new file mode 100644 index 0000000..0b1b277 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorImageFormat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a203492c798220244927d338800eec2f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs b/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs new file mode 100644 index 0000000..d72c563 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs @@ -0,0 +1,46 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.ColorSpacePoint + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct ColorSpacePoint + { + public float X { get; set; } + public float Y { get; set; } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is ColorSpacePoint)) + { + return false; + } + + return this.Equals((ColorSpacePoint)obj); + } + + public bool Equals(ColorSpacePoint obj) + { + return X.Equals(obj.X) && Y.Equals(obj.Y); + } + + public static bool operator ==(ColorSpacePoint a, ColorSpacePoint b) + { + return a.Equals(b); + } + + public static bool operator !=(ColorSpacePoint a, ColorSpacePoint b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs.meta new file mode 100644 index 0000000..1d92d89 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/ColorSpacePoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9eb5711cb5d886b45883ead06f286283 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs new file mode 100644 index 0000000..811213b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs @@ -0,0 +1,336 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.CoordinateMapper + // + public sealed partial class CoordinateMapper : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal CoordinateMapper(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_CoordinateMapper_AddRefObject(ref _pNative); + } + + ~CoordinateMapper() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_CoordinateMapper_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate))] + private static void Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.CoordinateMappingChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_add_CoordinateMappingChanged(RootSystem.IntPtr pNative, _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler CoordinateMappingChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate(Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handler); + _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_CoordinateMapper_add_CoordinateMappingChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_CoordinateMapper_add_CoordinateMappingChanged(_pNative, Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handler, true); + _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_CoordinateMapper_MapCameraPointToDepthSpace(RootSystem.IntPtr pNative, Windows.Kinect.CameraSpacePoint cameraPoint); + public Windows.Kinect.DepthSpacePoint MapCameraPointToDepthSpace(Windows.Kinect.CameraSpacePoint cameraPoint) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var objectPointer = Windows_Kinect_CoordinateMapper_MapCameraPointToDepthSpace(_pNative, cameraPoint); + Helper.ExceptionHelper.CheckLastError(); + var obj = (Windows.Kinect.DepthSpacePoint)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.DepthSpacePoint)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_CoordinateMapper_MapCameraPointToColorSpace(RootSystem.IntPtr pNative, Windows.Kinect.CameraSpacePoint cameraPoint); + public Windows.Kinect.ColorSpacePoint MapCameraPointToColorSpace(Windows.Kinect.CameraSpacePoint cameraPoint) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var objectPointer = Windows_Kinect_CoordinateMapper_MapCameraPointToColorSpace(_pNative, cameraPoint); + Helper.ExceptionHelper.CheckLastError(); + var obj = (Windows.Kinect.ColorSpacePoint)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.ColorSpacePoint)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_CoordinateMapper_MapDepthPointToCameraSpace(RootSystem.IntPtr pNative, Windows.Kinect.DepthSpacePoint depthPoint, ushort depth); + public Windows.Kinect.CameraSpacePoint MapDepthPointToCameraSpace(Windows.Kinect.DepthSpacePoint depthPoint, ushort depth) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var objectPointer = Windows_Kinect_CoordinateMapper_MapDepthPointToCameraSpace(_pNative, depthPoint, depth); + Helper.ExceptionHelper.CheckLastError(); + var obj = (Windows.Kinect.CameraSpacePoint)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.CameraSpacePoint)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_CoordinateMapper_MapDepthPointToColorSpace(RootSystem.IntPtr pNative, Windows.Kinect.DepthSpacePoint depthPoint, ushort depth); + public Windows.Kinect.ColorSpacePoint MapDepthPointToColorSpace(Windows.Kinect.DepthSpacePoint depthPoint, ushort depth) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var objectPointer = Windows_Kinect_CoordinateMapper_MapDepthPointToColorSpace(_pNative, depthPoint, depth); + Helper.ExceptionHelper.CheckLastError(); + var obj = (Windows.Kinect.ColorSpacePoint)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.ColorSpacePoint)); + RootSystem.Runtime.InteropServices.Marshal.FreeHGlobal(objectPointer); + return obj; + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapCameraPointsToDepthSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr cameraPoints, int cameraPointsSize, RootSystem.IntPtr depthPoints, int depthPointsSize); + public void MapCameraPointsToDepthSpace(Windows.Kinect.CameraSpacePoint[] cameraPoints, Windows.Kinect.DepthSpacePoint[] depthPoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var cameraPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(cameraPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _cameraPoints = cameraPointsSmartGCHandle.AddrOfPinnedObject(); + var depthPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthPoints = depthPointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapCameraPointsToDepthSpace(_pNative, _cameraPoints, cameraPoints.Length, _depthPoints, depthPoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapCameraPointsToColorSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr cameraPoints, int cameraPointsSize, RootSystem.IntPtr colorPoints, int colorPointsSize); + public void MapCameraPointsToColorSpace(Windows.Kinect.CameraSpacePoint[] cameraPoints, Windows.Kinect.ColorSpacePoint[] colorPoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var cameraPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(cameraPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _cameraPoints = cameraPointsSmartGCHandle.AddrOfPinnedObject(); + var colorPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(colorPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _colorPoints = colorPointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapCameraPointsToColorSpace(_pNative, _cameraPoints, cameraPoints.Length, _colorPoints, colorPoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthPointsToCameraSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthPoints, int depthPointsSize, RootSystem.IntPtr depths, int depthsSize, RootSystem.IntPtr cameraPoints, int cameraPointsSize); + public void MapDepthPointsToCameraSpace(Windows.Kinect.DepthSpacePoint[] depthPoints, ushort[] depths, Windows.Kinect.CameraSpacePoint[] cameraPoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthPoints = depthPointsSmartGCHandle.AddrOfPinnedObject(); + var depthsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depths, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depths = depthsSmartGCHandle.AddrOfPinnedObject(); + var cameraPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(cameraPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _cameraPoints = cameraPointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapDepthPointsToCameraSpace(_pNative, _depthPoints, depthPoints.Length, _depths, depths.Length, _cameraPoints, cameraPoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthPointsToColorSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthPoints, int depthPointsSize, RootSystem.IntPtr depths, int depthsSize, RootSystem.IntPtr colorPoints, int colorPointsSize); + public void MapDepthPointsToColorSpace(Windows.Kinect.DepthSpacePoint[] depthPoints, ushort[] depths, Windows.Kinect.ColorSpacePoint[] colorPoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthPoints = depthPointsSmartGCHandle.AddrOfPinnedObject(); + var depthsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depths, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depths = depthsSmartGCHandle.AddrOfPinnedObject(); + var colorPointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(colorPoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _colorPoints = colorPointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapDepthPointsToColorSpace(_pNative, _depthPoints, depthPoints.Length, _depths, depths.Length, _colorPoints, colorPoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthFrameToCameraSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthFrameData, int depthFrameDataSize, RootSystem.IntPtr cameraSpacePoints, int cameraSpacePointsSize); + public void MapDepthFrameToCameraSpace(ushort[] depthFrameData, Windows.Kinect.CameraSpacePoint[] cameraSpacePoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthFrameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthFrameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthFrameData = depthFrameDataSmartGCHandle.AddrOfPinnedObject(); + var cameraSpacePointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(cameraSpacePoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _cameraSpacePoints = cameraSpacePointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapDepthFrameToCameraSpace(_pNative, _depthFrameData, depthFrameData.Length, _cameraSpacePoints, cameraSpacePoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapDepthFrameToColorSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthFrameData, int depthFrameDataSize, RootSystem.IntPtr colorSpacePoints, int colorSpacePointsSize); + public void MapDepthFrameToColorSpace(ushort[] depthFrameData, Windows.Kinect.ColorSpacePoint[] colorSpacePoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthFrameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthFrameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthFrameData = depthFrameDataSmartGCHandle.AddrOfPinnedObject(); + var colorSpacePointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(colorSpacePoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _colorSpacePoints = colorSpacePointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapDepthFrameToColorSpace(_pNative, _depthFrameData, depthFrameData.Length, _colorSpacePoints, colorSpacePoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapColorFrameToDepthSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthFrameData, int depthFrameDataSize, RootSystem.IntPtr depthSpacePoints, int depthSpacePointsSize); + public void MapColorFrameToDepthSpace(ushort[] depthFrameData, Windows.Kinect.DepthSpacePoint[] depthSpacePoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthFrameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthFrameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthFrameData = depthFrameDataSmartGCHandle.AddrOfPinnedObject(); + var depthSpacePointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthSpacePoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthSpacePoints = depthSpacePointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapColorFrameToDepthSpace(_pNative, _depthFrameData, depthFrameData.Length, _depthSpacePoints, depthSpacePoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMapper_MapColorFrameToCameraSpace(RootSystem.IntPtr pNative, RootSystem.IntPtr depthFrameData, int depthFrameDataSize, RootSystem.IntPtr cameraSpacePoints, int cameraSpacePointsSize); + public void MapColorFrameToCameraSpace(ushort[] depthFrameData, Windows.Kinect.CameraSpacePoint[] cameraSpacePoints) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("CoordinateMapper"); + } + + var depthFrameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(depthFrameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _depthFrameData = depthFrameDataSmartGCHandle.AddrOfPinnedObject(); + var cameraSpacePointsSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(cameraSpacePoints, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _cameraSpacePoints = cameraSpacePointsSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_CoordinateMapper_MapColorFrameToCameraSpace(_pNative, _depthFrameData, depthFrameData.Length, _cameraSpacePoints, cameraSpacePoints.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + private void __EventCleanup() + { + { + Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_CoordinateMapper_add_CoordinateMappingChanged(_pNative, Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_CoordinateMappingChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs.meta new file mode 100644 index 0000000..72e53be --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 452370c006443bb40bc44aa5d4bd8def +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs new file mode 100644 index 0000000..e1b02ac --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs @@ -0,0 +1,51 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.CoordinateMappingChangedEventArgs + // + public sealed partial class CoordinateMappingChangedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal CoordinateMappingChangedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_CoordinateMappingChangedEventArgs_AddRefObject(ref _pNative); + } + + ~CoordinateMappingChangedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMappingChangedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_CoordinateMappingChangedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_CoordinateMappingChangedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs.meta new file mode 100644 index 0000000..3d15bb5 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/CoordinateMappingChangedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 82cb5d8afd91cba43a5380999e22e2cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs new file mode 100644 index 0000000..03535d7 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs @@ -0,0 +1,177 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthFrame + // + public sealed partial class DepthFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal DepthFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_DepthFrame_AddRefObject(ref _pNative); + } + + ~DepthFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_DepthFrame_Dispose(_pNative); + } + Windows_Kinect_DepthFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrame_get_DepthFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameSource DepthFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrame_get_DepthFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern ushort Windows_Kinect_DepthFrame_get_DepthMaxReliableDistance(RootSystem.IntPtr pNative); + public ushort DepthMaxReliableDistance + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + return Windows_Kinect_DepthFrame_get_DepthMaxReliableDistance(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern ushort Windows_Kinect_DepthFrame_get_DepthMinReliableDistance(RootSystem.IntPtr pNative); + public ushort DepthMinReliableDistance + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + return Windows_Kinect_DepthFrame_get_DepthMinReliableDistance(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrame_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrame_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_DepthFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_DepthFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyFrameDataToArray(ushort[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_DepthFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs.meta new file mode 100644 index 0000000..92b90da --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1cc3d786ee7037e40b806839fdca184a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs new file mode 100644 index 0000000..17c4046 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthFrameArrivedEventArgs + // + public sealed partial class DepthFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal DepthFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_DepthFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~DepthFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_DepthFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..0e558a8 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c09496fb04e3d9c43b5fbf4ac998ff6e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs new file mode 100644 index 0000000..3e589a8 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthFrameReader + // + public sealed partial class DepthFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal DepthFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_DepthFrameReader_AddRefObject(ref _pNative); + } + + ~DepthFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_DepthFrameReader_Dispose(_pNative); + } + Windows_Kinect_DepthFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameReader_get_DepthFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameSource DepthFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameReader_get_DepthFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_DepthFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReader"); + } + + return Windows_Kinect_DepthFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReader"); + } + + Windows_Kinect_DepthFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_DepthFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.DepthFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate(Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_DepthFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_DepthFrameReader_add_FrameArrived(_pNative, Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_DepthFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_DepthFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_DepthFrameReader_add_FrameArrived(_pNative, Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_DepthFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_DepthFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs.meta new file mode 100644 index 0000000..fb7170f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19e437f0dfc211640b0b56e1e0221a8f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs new file mode 100644 index 0000000..e9ebd58 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthFrameReference + // + public sealed partial class DepthFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal DepthFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_DepthFrameReference_AddRefObject(ref _pNative); + } + + ~DepthFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_DepthFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_DepthFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_DepthFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs.meta new file mode 100644 index 0000000..98ac07c --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f53daf0889b08bf4494ecbd1914a99d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs new file mode 100644 index 0000000..829f946 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs @@ -0,0 +1,319 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthFrameSource + // + public sealed partial class DepthFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal DepthFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_DepthFrameSource_AddRefObject(ref _pNative); + } + + ~DepthFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_DepthFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern ushort Windows_Kinect_DepthFrameSource_get_DepthMaxReliableDistance(RootSystem.IntPtr pNative); + public ushort DepthMaxReliableDistance + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + return Windows_Kinect_DepthFrameSource_get_DepthMaxReliableDistance(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern ushort Windows_Kinect_DepthFrameSource_get_DepthMinReliableDistance(RootSystem.IntPtr pNative); + public ushort DepthMinReliableDistance + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + return Windows_Kinect_DepthFrameSource_get_DepthMinReliableDistance(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameSource_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameSource_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_DepthFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + return Windows_Kinect_DepthFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_DepthFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_DepthFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_DepthFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_DepthFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_DepthFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_DepthFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("DepthFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_DepthFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_DepthFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_DepthFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs.meta new file mode 100644 index 0000000..7dcd943 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec16a6a3c150d4c479a008f45c1851ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs new file mode 100644 index 0000000..fc94cfe --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs @@ -0,0 +1,46 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DepthSpacePoint + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct DepthSpacePoint + { + public float X { get; set; } + public float Y { get; set; } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is DepthSpacePoint)) + { + return false; + } + + return this.Equals((DepthSpacePoint)obj); + } + + public bool Equals(DepthSpacePoint obj) + { + return X.Equals(obj.X) && Y.Equals(obj.Y); + } + + public static bool operator ==(DepthSpacePoint a, DepthSpacePoint b) + { + return a.Equals(b); + } + + public static bool operator !=(DepthSpacePoint a, DepthSpacePoint b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs.meta new file mode 100644 index 0000000..732fe63 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DepthSpacePoint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87a047e9c131269479b899f8dd9cac89 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs b/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs new file mode 100644 index 0000000..6558bf7 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs @@ -0,0 +1,17 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.DetectionResult + // + public enum DetectionResult : int + { + Unknown =0, + No =1, + Maybe =2, + Yes =3, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs.meta new file mode 100644 index 0000000..77f89a5 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/DetectionResult.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f242e10b172a6340a49529ef0ad2d90 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs new file mode 100644 index 0000000..5d4bb22 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs @@ -0,0 +1,15 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Expression + // + public enum Expression : int + { + Neutral =0, + Happy =1, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs.meta new file mode 100644 index 0000000..7b786a6 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Expression.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 13c84518ab4fa60499742f896207e91e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs new file mode 100644 index 0000000..307b970 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs @@ -0,0 +1,98 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.FrameCapturedEventArgs + // + public sealed partial class FrameCapturedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal FrameCapturedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_FrameCapturedEventArgs_AddRefObject(ref _pNative); + } + + ~FrameCapturedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_FrameCapturedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_FrameCapturedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_FrameCapturedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.FrameCapturedStatus Windows_Kinect_FrameCapturedEventArgs_get_FrameStatus(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameCapturedStatus FrameStatus + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameCapturedEventArgs"); + } + + return Windows_Kinect_FrameCapturedEventArgs_get_FrameStatus(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.FrameSourceTypes Windows_Kinect_FrameCapturedEventArgs_get_FrameType(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameSourceTypes FrameType + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameCapturedEventArgs"); + } + + return Windows_Kinect_FrameCapturedEventArgs_get_FrameType(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_FrameCapturedEventArgs_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameCapturedEventArgs"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_FrameCapturedEventArgs_get_RelativeTime(_pNative)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs.meta new file mode 100644 index 0000000..842a523 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 085ec75a343f958408701e00ba2168ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs new file mode 100644 index 0000000..a42cf71 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs @@ -0,0 +1,16 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.FrameCapturedStatus + // + public enum FrameCapturedStatus : int + { + Unknown =0, + Queued =1, + Dropped =2, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs.meta new file mode 100644 index 0000000..da09174 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameCapturedStatus.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ccf1cabe437c4764d9818a2fd30827f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs b/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs new file mode 100644 index 0000000..25d46ab --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs @@ -0,0 +1,158 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.FrameDescription + // + public sealed partial class FrameDescription : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal FrameDescription(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_FrameDescription_AddRefObject(ref _pNative); + } + + ~FrameDescription() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_FrameDescription_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_FrameDescription_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_FrameDescription_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern uint Windows_Kinect_FrameDescription_get_BytesPerPixel(RootSystem.IntPtr pNative); + public uint BytesPerPixel + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_BytesPerPixel(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_FrameDescription_get_DiagonalFieldOfView(RootSystem.IntPtr pNative); + public float DiagonalFieldOfView + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_DiagonalFieldOfView(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_FrameDescription_get_Height(RootSystem.IntPtr pNative); + public int Height + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_Height(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_FrameDescription_get_HorizontalFieldOfView(RootSystem.IntPtr pNative); + public float HorizontalFieldOfView + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_HorizontalFieldOfView(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern uint Windows_Kinect_FrameDescription_get_LengthInPixels(RootSystem.IntPtr pNative); + public uint LengthInPixels + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_LengthInPixels(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern float Windows_Kinect_FrameDescription_get_VerticalFieldOfView(RootSystem.IntPtr pNative); + public float VerticalFieldOfView + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_VerticalFieldOfView(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern int Windows_Kinect_FrameDescription_get_Width(RootSystem.IntPtr pNative); + public int Width + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("FrameDescription"); + } + + return Windows_Kinect_FrameDescription_get_Width(_pNative); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs.meta new file mode 100644 index 0000000..0e422bf --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameDescription.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 855fcb405500ab14b8902d15d27ed0ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs b/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs new file mode 100644 index 0000000..4751626 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs @@ -0,0 +1,19 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.FrameEdges + // + [RootSystem.Flags] + public enum FrameEdges : uint + { + None =0, + Right =1, + Left =2, + Top =4, + Bottom =8, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs.meta new file mode 100644 index 0000000..1fbd05f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameEdges.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34cd6f0c5382cd9458b3b1ef06e001ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs b/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs new file mode 100644 index 0000000..cb639bb --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs @@ -0,0 +1,22 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.FrameSourceTypes + // + [RootSystem.Flags] + public enum FrameSourceTypes : uint + { + None =0, + Color =1, + Infrared =2, + LongExposureInfrared =4, + Depth =8, + BodyIndex =16, + Body =32, + Audio =64, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs.meta new file mode 100644 index 0000000..da8733b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/FrameSourceTypes.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bbb237f869b7c684aa4bff904d74ceed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs b/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs new file mode 100644 index 0000000..6ae6efc --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs @@ -0,0 +1,18 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.HandState + // + public enum HandState : int + { + Unknown =0, + NotTracked =1, + Open =2, + Closed =3, + Lasso =4, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs.meta new file mode 100644 index 0000000..77b88d3 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/HandState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 61c6c0071af9a08459843e571124cbef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs new file mode 100644 index 0000000..e097592 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs @@ -0,0 +1,147 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.InfraredFrame + // + public sealed partial class InfraredFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal InfraredFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_InfraredFrame_AddRefObject(ref _pNative); + } + + ~InfraredFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_InfraredFrame_Dispose(_pNative); + } + Windows_Kinect_InfraredFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrame_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrame_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrame_get_InfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameSource InfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrame_get_InfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_InfraredFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_InfraredFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyFrameDataToArray(ushort[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_InfraredFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs.meta new file mode 100644 index 0000000..b620137 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 716d52dd0cd344f439914ed99e62b0e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs new file mode 100644 index 0000000..443b235 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.InfraredFrameArrivedEventArgs + // + public sealed partial class InfraredFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal InfraredFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_InfraredFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~InfraredFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_InfraredFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..c6c84b7 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 47e956b7b74fcd447a28c068f2fcaf56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs new file mode 100644 index 0000000..5bda30b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.InfraredFrameReader + // + public sealed partial class InfraredFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal InfraredFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_InfraredFrameReader_AddRefObject(ref _pNative); + } + + ~InfraredFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_InfraredFrameReader_Dispose(_pNative); + } + Windows_Kinect_InfraredFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameReader_get_InfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameSource InfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameReader_get_InfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_InfraredFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReader"); + } + + return Windows_Kinect_InfraredFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReader"); + } + + Windows_Kinect_InfraredFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.InfraredFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate(Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_InfraredFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_InfraredFrameReader_add_FrameArrived(_pNative, Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_InfraredFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_InfraredFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_InfraredFrameReader_add_FrameArrived(_pNative, Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_InfraredFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_InfraredFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs.meta new file mode 100644 index 0000000..67607d4 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0937005bb1a679a40a0bffab4f8fa84b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs new file mode 100644 index 0000000..38d5466 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.InfraredFrameReference + // + public sealed partial class InfraredFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal InfraredFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_InfraredFrameReference_AddRefObject(ref _pNative); + } + + ~InfraredFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_InfraredFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_InfraredFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_InfraredFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs.meta new file mode 100644 index 0000000..f23f2c6 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89acda427f65cc64dbe156710db8760f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs new file mode 100644 index 0000000..45e150b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs @@ -0,0 +1,289 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.InfraredFrameSource + // + public sealed partial class InfraredFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal InfraredFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_InfraredFrameSource_AddRefObject(ref _pNative); + } + + ~InfraredFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_InfraredFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameSource_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameSource_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_InfraredFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameSource"); + } + + return Windows_Kinect_InfraredFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_InfraredFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_InfraredFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_InfraredFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_InfraredFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_InfraredFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_InfraredFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("InfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_InfraredFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_InfraredFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_InfraredFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs.meta new file mode 100644 index 0000000..e63e0ad --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/InfraredFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b41da8047304434eb12d404c2f99979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs new file mode 100644 index 0000000..981c366 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs @@ -0,0 +1,68 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.IsAvailableChangedEventArgs + // + public sealed partial class IsAvailableChangedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal IsAvailableChangedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_IsAvailableChangedEventArgs_AddRefObject(ref _pNative); + } + + ~IsAvailableChangedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_IsAvailableChangedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_IsAvailableChangedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_IsAvailableChangedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_IsAvailableChangedEventArgs_get_IsAvailable(RootSystem.IntPtr pNative); + public bool IsAvailable + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("IsAvailableChangedEventArgs"); + } + + return Windows_Kinect_IsAvailableChangedEventArgs_get_IsAvailable(_pNative); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs.meta new file mode 100644 index 0000000..e5ca969 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/IsAvailableChangedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65a7600b04976b84db9c9ec171a5d71f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs new file mode 100644 index 0000000..419ea98 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs @@ -0,0 +1,47 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Joint + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct Joint + { + public Windows.Kinect.JointType JointType { get; set; } + public Windows.Kinect.CameraSpacePoint Position { get; set; } + public Windows.Kinect.TrackingState TrackingState { get; set; } + + public override int GetHashCode() + { + return JointType.GetHashCode() ^ Position.GetHashCode() ^ TrackingState.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is Joint)) + { + return false; + } + + return this.Equals((Joint)obj); + } + + public bool Equals(Joint obj) + { + return JointType.Equals(obj.JointType) && Position.Equals(obj.Position) && TrackingState.Equals(obj.TrackingState); + } + + public static bool operator ==(Joint a, Joint b) + { + return a.Equals(b); + } + + public static bool operator !=(Joint a, Joint b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs.meta new file mode 100644 index 0000000..855527f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Joint.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c6ab2966f653a9b439da02f3ae85c867 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs b/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs new file mode 100644 index 0000000..03e2fd8 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs @@ -0,0 +1,46 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.JointOrientation + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct JointOrientation + { + public Windows.Kinect.JointType JointType { get; set; } + public Windows.Kinect.Vector4 Orientation { get; set; } + + public override int GetHashCode() + { + return JointType.GetHashCode() ^ Orientation.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is JointOrientation)) + { + return false; + } + + return this.Equals((JointOrientation)obj); + } + + public bool Equals(JointOrientation obj) + { + return JointType.Equals(obj.JointType) && Orientation.Equals(obj.Orientation); + } + + public static bool operator ==(JointOrientation a, JointOrientation b) + { + return a.Equals(b); + } + + public static bool operator !=(JointOrientation a, JointOrientation b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs.meta new file mode 100644 index 0000000..019eb6d --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/JointOrientation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d616618770c2c84469f5aaa5f72ca2ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs b/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs new file mode 100644 index 0000000..4f3f3bf --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs @@ -0,0 +1,38 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.JointType + // + public enum JointType : int + { + SpineBase =0, + SpineMid =1, + Neck =2, + Head =3, + ShoulderLeft =4, + ElbowLeft =5, + WristLeft =6, + HandLeft =7, + ShoulderRight =8, + ElbowRight =9, + WristRight =10, + HandRight =11, + HipLeft =12, + KneeLeft =13, + AnkleLeft =14, + FootLeft =15, + HipRight =16, + KneeRight =17, + AnkleRight =18, + FootRight =19, + SpineShoulder =20, + HandTipLeft =21, + ThumbLeft =22, + HandTipRight =23, + ThumbRight =24, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs.meta new file mode 100644 index 0000000..1441299 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/JointType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1791e2ee3f5ea1343a2694b4e1b3f00f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs b/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs new file mode 100644 index 0000000..d259d22 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs @@ -0,0 +1,16 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.KinectAudioCalibrationState + // + public enum KinectAudioCalibrationState : int + { + Unknown =0, + CalibrationRequired =1, + Calibrated =2, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs.meta new file mode 100644 index 0000000..7007e0a --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectAudioCalibrationState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87d856dfd833c524381664b12e58813a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs b/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs new file mode 100644 index 0000000..ab516af --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs @@ -0,0 +1,20 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.KinectCapabilities + // + [RootSystem.Flags] + public enum KinectCapabilities : uint + { + None =0, + Vision =1, + Audio =2, + Face =4, + Expressions =8, + Gamechat =16, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs.meta new file mode 100644 index 0000000..54817c6 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectCapabilities.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6dcba0f7ec870d94c849f4d8ed860377 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs b/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs new file mode 100644 index 0000000..9b41cf3 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs @@ -0,0 +1,498 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.KinectSensor + // + public sealed partial class KinectSensor : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal KinectSensor(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_KinectSensor_AddRefObject(ref _pNative); + } + + ~KinectSensor() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_AddRefObject(ref RootSystem.IntPtr pNative); + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_AudioSource(RootSystem.IntPtr pNative); + public Windows.Kinect.AudioSource AudioSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_AudioSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.AudioSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_BodyFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameSource BodyFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_BodyFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_BodyIndexFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameSource BodyIndexFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_BodyIndexFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_ColorFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameSource ColorFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_ColorFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_CoordinateMapper(RootSystem.IntPtr pNative); + public Windows.Kinect.CoordinateMapper CoordinateMapper + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_CoordinateMapper(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.CoordinateMapper(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_DepthFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameSource DepthFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_DepthFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_InfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameSource InfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_InfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_KinectSensor_get_IsAvailable(RootSystem.IntPtr pNative); + public bool IsAvailable + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + return Windows_Kinect_KinectSensor_get_IsAvailable(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_KinectSensor_get_IsOpen(RootSystem.IntPtr pNative); + public bool IsOpen + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + return Windows_Kinect_KinectSensor_get_IsOpen(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.KinectCapabilities Windows_Kinect_KinectSensor_get_KinectCapabilities(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectCapabilities KinectCapabilities + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + return Windows_Kinect_KinectSensor_get_KinectCapabilities(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_LongExposureInfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameSource LongExposureInfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_LongExposureInfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_get_UniqueKinectId(RootSystem.IntPtr pNative); + public string UniqueKinectId + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_get_UniqueKinectId(_pNative); + Helper.ExceptionHelper.CheckLastError(); + + var managedString = RootSystem.Runtime.InteropServices.Marshal.PtrToStringUni(objectPointer); + RootSystem.Runtime.InteropServices.Marshal.FreeCoTaskMem(objectPointer); + return managedString; + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_IsAvailableChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_IsAvailableChangedEventArgs_Delegate))] + private static void Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.IsAvailableChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_add_IsAvailableChanged(RootSystem.IntPtr pNative, _Windows_Kinect_IsAvailableChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler IsAvailableChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_IsAvailableChangedEventArgs_Delegate(Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handler); + _Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_KinectSensor_add_IsAvailableChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_KinectSensor_add_IsAvailableChanged(_pNative, Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handler, true); + _Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_KinectSensor_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_KinectSensor_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Static Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_GetDefault(); + public static Windows.Kinect.KinectSensor GetDefault() + { + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_GetDefault(); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_Open(RootSystem.IntPtr pNative); + public void Open() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + Windows_Kinect_KinectSensor_Open(_pNative); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_KinectSensor_Close(RootSystem.IntPtr pNative); + public void Close() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + Windows_Kinect_KinectSensor_Close(_pNative); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_KinectSensor_OpenMultiSourceFrameReader(RootSystem.IntPtr pNative, Windows.Kinect.FrameSourceTypes enabledFrameSourceTypes); + public Windows.Kinect.MultiSourceFrameReader OpenMultiSourceFrameReader(Windows.Kinect.FrameSourceTypes enabledFrameSourceTypes) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("KinectSensor"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_KinectSensor_OpenMultiSourceFrameReader(_pNative, enabledFrameSourceTypes); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.MultiSourceFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_IsAvailableChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_KinectSensor_add_IsAvailableChanged(_pNative, Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_IsAvailableChangedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_KinectSensor_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs.meta new file mode 100644 index 0000000..35379e6 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectSensor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5a5ec3f3f1b0064fae54e1512e12887 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs b/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs new file mode 100644 index 0000000..7423048 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs @@ -0,0 +1,19 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.KinectUnityAddinUtils + // + public sealed partial class KinectUnityAddinUtils + { + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void KinectUnityAddin_FreeMemory(RootSystem.IntPtr pToDealloc); + public static void FreeMemory(RootSystem.IntPtr pToDealloc) + { + KinectUnityAddin_FreeMemory(pToDealloc); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs.meta new file mode 100644 index 0000000..20e619a --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/KinectUnityAddinUtils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 985cae59f29daa947acc082d310c3492 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs new file mode 100644 index 0000000..b5bf431 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs @@ -0,0 +1,147 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.LongExposureInfraredFrame + // + public sealed partial class LongExposureInfraredFrame : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal LongExposureInfraredFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_LongExposureInfraredFrame_AddRefObject(ref _pNative); + } + + ~LongExposureInfraredFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_LongExposureInfraredFrame_Dispose(_pNative); + } + Windows_Kinect_LongExposureInfraredFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrame_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrame_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrame_get_LongExposureInfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameSource LongExposureInfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrame_get_LongExposureInfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameSource(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_LongExposureInfraredFrame_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_LongExposureInfraredFrame_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize); + public void CopyFrameDataToArray(ushort[] frameData) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrame"); + } + + var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned)); + var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject(); + Windows_Kinect_LongExposureInfraredFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length); + Helper.ExceptionHelper.CheckLastError(); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrame_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs.meta new file mode 100644 index 0000000..0418c00 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 62e292d05e1f99d4695e2306db22e75f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs new file mode 100644 index 0000000..b22dd21 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.LongExposureInfraredFrameArrivedEventArgs + // + public sealed partial class LongExposureInfraredFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal LongExposureInfraredFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~LongExposureInfraredFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..bae812b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dbaaf8e0d23f24848ab81331f4379722 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs new file mode 100644 index 0000000..9ebfb47 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs @@ -0,0 +1,297 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.LongExposureInfraredFrameReader + // + public sealed partial class LongExposureInfraredFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal LongExposureInfraredFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_LongExposureInfraredFrameReader_AddRefObject(ref _pNative); + } + + ~LongExposureInfraredFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_LongExposureInfraredFrameReader_Dispose(_pNative); + } + Windows_Kinect_LongExposureInfraredFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_LongExposureInfraredFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReader"); + } + + return Windows_Kinect_LongExposureInfraredFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReader"); + } + + Windows_Kinect_LongExposureInfraredFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameReader_get_LongExposureInfraredFrameSource(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameSource LongExposureInfraredFrameSource + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameReader_get_LongExposureInfraredFrameSource(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameSource(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.LongExposureInfraredFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_add_FrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate(Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_LongExposureInfraredFrameReader_add_FrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_LongExposureInfraredFrameReader_add_FrameArrived(_pNative, Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_LongExposureInfraredFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_LongExposureInfraredFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_LongExposureInfraredFrameReader_add_FrameArrived(_pNative, Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_LongExposureInfraredFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_LongExposureInfraredFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs.meta new file mode 100644 index 0000000..62c72c5 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 78a6e9053bd545d4f948fa1d8ced5879 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs new file mode 100644 index 0000000..84ce8e8 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs @@ -0,0 +1,89 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.LongExposureInfraredFrameReference + // + public sealed partial class LongExposureInfraredFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal LongExposureInfraredFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_LongExposureInfraredFrameReference_AddRefObject(ref _pNative); + } + + ~LongExposureInfraredFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_LongExposureInfraredFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern long Windows_Kinect_LongExposureInfraredFrameReference_get_RelativeTime(RootSystem.IntPtr pNative); + public RootSystem.TimeSpan RelativeTime + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReference"); + } + + return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_LongExposureInfraredFrameReference_get_RelativeTime(_pNative)); + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs.meta new file mode 100644 index 0000000..ea4be61 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91cd9161c056061438655504e2f2f7f4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs new file mode 100644 index 0000000..c0c2f44 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs @@ -0,0 +1,289 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.LongExposureInfraredFrameSource + // + public sealed partial class LongExposureInfraredFrameSource : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal LongExposureInfraredFrameSource(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_LongExposureInfraredFrameSource_AddRefObject(ref _pNative); + } + + ~LongExposureInfraredFrameSource() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameSource_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameSource_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_LongExposureInfraredFrameSource_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameSource_get_FrameDescription(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameDescription FrameDescription + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameSource_get_FrameDescription(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.FrameDescription(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_LongExposureInfraredFrameSource_get_IsActive(RootSystem.IntPtr pNative); + public bool IsActive + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameSource"); + } + + return Windows_Kinect_LongExposureInfraredFrameSource_get_IsActive(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameSource_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameSource_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_FrameCapturedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_FrameCapturedEventArgs_Delegate))] + private static void Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.FrameCapturedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameSource_add_FrameCaptured(RootSystem.IntPtr pNative, _Windows_Kinect_FrameCapturedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler FrameCaptured + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_FrameCapturedEventArgs_Delegate(Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_LongExposureInfraredFrameSource_add_FrameCaptured(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_LongExposureInfraredFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_LongExposureInfraredFrameSource_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_LongExposureInfraredFrameSource_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_LongExposureInfraredFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_LongExposureInfraredFrameSource_OpenReader(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameReader OpenReader() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("LongExposureInfraredFrameSource"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_LongExposureInfraredFrameSource_OpenReader(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameReader(n)); + } + + private void __EventCleanup() + { + { + Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_FrameCapturedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_LongExposureInfraredFrameSource_add_FrameCaptured(_pNative, Windows_Kinect_FrameCapturedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_FrameCapturedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_LongExposureInfraredFrameSource_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs.meta new file mode 100644 index 0000000..a590158 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/LongExposureInfraredFrameSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cdcf249c89943864ca06ab517b1d74f5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs new file mode 100644 index 0000000..c5e3b4d --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs @@ -0,0 +1,187 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.MultiSourceFrame + // + public sealed partial class MultiSourceFrame : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal MultiSourceFrame(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_MultiSourceFrame_AddRefObject(ref _pNative); + } + + ~MultiSourceFrame() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrame_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrame_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_MultiSourceFrame_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_BodyFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyFrameReference BodyFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_BodyFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyFrameReference(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_BodyIndexFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.BodyIndexFrameReference BodyIndexFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_BodyIndexFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.BodyIndexFrameReference(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_ColorFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.ColorFrameReference ColorFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_ColorFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.ColorFrameReference(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_DepthFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.DepthFrameReference DepthFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_DepthFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.DepthFrameReference(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_InfraredFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.InfraredFrameReference InfraredFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_InfraredFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.InfraredFrameReference(n)); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrame_get_LongExposureInfraredFrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.LongExposureInfraredFrameReference LongExposureInfraredFrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrame"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrame_get_LongExposureInfraredFrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.LongExposureInfraredFrameReference(n)); + } + } + + + // Public Methods + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs.meta new file mode 100644 index 0000000..a69f04f --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrame.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb5e1a9a4aa7a3f4b8190ab4fab84118 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs new file mode 100644 index 0000000..b4f8e94 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs @@ -0,0 +1,75 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.MultiSourceFrameArrivedEventArgs + // + public sealed partial class MultiSourceFrameArrivedEventArgs : RootSystem.EventArgs, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal MultiSourceFrameArrivedEventArgs(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_MultiSourceFrameArrivedEventArgs_AddRefObject(ref _pNative); + } + + ~MultiSourceFrameArrivedEventArgs() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameArrivedEventArgs_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameArrivedEventArgs_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_MultiSourceFrameArrivedEventArgs_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrameArrivedEventArgs_get_FrameReference(RootSystem.IntPtr pNative); + public Windows.Kinect.MultiSourceFrameReference FrameReference + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameArrivedEventArgs"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrameArrivedEventArgs_get_FrameReference(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.MultiSourceFrameReference(n)); + } + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs.meta new file mode 100644 index 0000000..3921c69 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1188dd030cd382340966a429c46ed4fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs new file mode 100644 index 0000000..6e946f4 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs @@ -0,0 +1,312 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.MultiSourceFrameReader + // + public sealed partial class MultiSourceFrameReader : RootSystem.IDisposable, Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal MultiSourceFrameReader(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_MultiSourceFrameReader_AddRefObject(ref _pNative); + } + + ~MultiSourceFrameReader() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + + if (disposing) + { + Windows_Kinect_MultiSourceFrameReader_Dispose(_pNative); + } + Windows_Kinect_MultiSourceFrameReader_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Properties + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern Windows.Kinect.FrameSourceTypes Windows_Kinect_MultiSourceFrameReader_get_FrameSourceTypes(RootSystem.IntPtr pNative); + public Windows.Kinect.FrameSourceTypes FrameSourceTypes + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReader"); + } + + return Windows_Kinect_MultiSourceFrameReader_get_FrameSourceTypes(_pNative); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern bool Windows_Kinect_MultiSourceFrameReader_get_IsPaused(RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_put_IsPaused(RootSystem.IntPtr pNative, bool isPaused); + public bool IsPaused + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReader"); + } + + return Windows_Kinect_MultiSourceFrameReader_get_IsPaused(_pNative); + } + set + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReader"); + } + + Windows_Kinect_MultiSourceFrameReader_put_IsPaused(_pNative, value); + Helper.ExceptionHelper.CheckLastError(); + } + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrameReader_get_KinectSensor(RootSystem.IntPtr pNative); + public Windows.Kinect.KinectSensor KinectSensor + { + get + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrameReader_get_KinectSensor(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.KinectSensor(n)); + } + } + + + // Events + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate))] + private static void Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Kinect.MultiSourceFrameArrivedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_add_MultiSourceFrameArrived(RootSystem.IntPtr pNative, _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler MultiSourceFrameArrived + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate(Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handler); + _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_MultiSourceFrameReader_add_MultiSourceFrameArrived(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_MultiSourceFrameReader_add_MultiSourceFrameArrived(_pNative, Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handler, true); + _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + private static RootSystem.Runtime.InteropServices.GCHandle _Windows_Data_PropertyChangedEventArgs_Delegate_Handle; + [RootSystem.Runtime.InteropServices.UnmanagedFunctionPointer(RootSystem.Runtime.InteropServices.CallingConvention.Cdecl)] + private delegate void _Windows_Data_PropertyChangedEventArgs_Delegate(RootSystem.IntPtr args, RootSystem.IntPtr pNative); + private static Helper.CollectionMap>> Windows_Data_PropertyChangedEventArgs_Delegate_callbacks = new Helper.CollectionMap>>(); + [AOT.MonoPInvokeCallbackAttribute(typeof(_Windows_Data_PropertyChangedEventArgs_Delegate))] + private static void Windows_Data_PropertyChangedEventArgs_Delegate_Handler(RootSystem.IntPtr result, RootSystem.IntPtr pNative) + { + List> callbackList = null; + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryGetValue(pNative, out callbackList); + lock(callbackList) + { + var objThis = Helper.NativeObjectCache.GetObject(pNative); + var args = new Windows.Data.PropertyChangedEventArgs(result); + foreach(var func in callbackList) + { + Helper.EventPump.Instance.Enqueue(() => { try { func(objThis, args); } catch { } }); + } + } + } + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_add_PropertyChanged(RootSystem.IntPtr pNative, _Windows_Data_PropertyChangedEventArgs_Delegate eventCallback, bool unsubscribe); + public event RootSystem.EventHandler PropertyChanged + { + add + { + Helper.EventPump.EnsureInitialized(); + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Add(value); + if(callbackList.Count == 1) + { + var del = new _Windows_Data_PropertyChangedEventArgs_Delegate(Windows_Data_PropertyChangedEventArgs_Delegate_Handler); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle = RootSystem.Runtime.InteropServices.GCHandle.Alloc(del); + Windows_Kinect_MultiSourceFrameReader_add_PropertyChanged(_pNative, del, false); + } + } + } + remove + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + callbackList.Remove(value); + if(callbackList.Count == 0) + { + Windows_Kinect_MultiSourceFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrameReader_AcquireLatestFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.MultiSourceFrame AcquireLatestFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReader"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrameReader_AcquireLatestFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.MultiSourceFrame(n)); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReader_Dispose(RootSystem.IntPtr pNative); + public void Dispose() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + Dispose(true); + RootSystem.GC.SuppressFinalize(this); + } + + private void __EventCleanup() + { + { + Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_MultiSourceFrameReader_add_MultiSourceFrameArrived(_pNative, Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handler, true); + } + _Windows_Kinect_MultiSourceFrameArrivedEventArgs_Delegate_Handle.Free(); + } + } + } + { + Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(_pNative); + var callbackList = Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[_pNative]; + lock (callbackList) + { + if (callbackList.Count > 0) + { + callbackList.Clear(); + if (_pNative != RootSystem.IntPtr.Zero) + { + Windows_Kinect_MultiSourceFrameReader_add_PropertyChanged(_pNative, Windows_Data_PropertyChangedEventArgs_Delegate_Handler, true); + } + _Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free(); + } + } + } + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs.meta new file mode 100644 index 0000000..b9a2d76 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a52acb4cdb90b3a4fa3937ab27ced4ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs new file mode 100644 index 0000000..01ffec4 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs @@ -0,0 +1,72 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.MultiSourceFrameReference + // + public sealed partial class MultiSourceFrameReference : Helper.INativeWrapper + + { + internal RootSystem.IntPtr _pNative; + RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } + + // Constructors and Finalizers + internal MultiSourceFrameReference(RootSystem.IntPtr pNative) + { + _pNative = pNative; + Windows_Kinect_MultiSourceFrameReference_AddRefObject(ref _pNative); + } + + ~MultiSourceFrameReference() + { + Dispose(false); + } + + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReference_ReleaseObject(ref RootSystem.IntPtr pNative); + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern void Windows_Kinect_MultiSourceFrameReference_AddRefObject(ref RootSystem.IntPtr pNative); + private void Dispose(bool disposing) + { + if (_pNative == RootSystem.IntPtr.Zero) + { + return; + } + + __EventCleanup(); + + Helper.NativeObjectCache.RemoveObject(_pNative); + Windows_Kinect_MultiSourceFrameReference_ReleaseObject(ref _pNative); + + _pNative = RootSystem.IntPtr.Zero; + } + + + // Public Methods + [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] + private static extern RootSystem.IntPtr Windows_Kinect_MultiSourceFrameReference_AcquireFrame(RootSystem.IntPtr pNative); + public Windows.Kinect.MultiSourceFrame AcquireFrame() + { + if (_pNative == RootSystem.IntPtr.Zero) + { + throw new RootSystem.ObjectDisposedException("MultiSourceFrameReference"); + } + + RootSystem.IntPtr objectPointer = Windows_Kinect_MultiSourceFrameReference_AcquireFrame(_pNative); + Helper.ExceptionHelper.CheckLastError(); + if (objectPointer == RootSystem.IntPtr.Zero) + { + return null; + } + + return Helper.NativeObjectCache.CreateOrGetObject(objectPointer, n => new Windows.Kinect.MultiSourceFrame(n)); + } + + private void __EventCleanup() + { + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs.meta new file mode 100644 index 0000000..51df3c1 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/MultiSourceFrameReference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e2ed2961bcca974085bf9ddcaaac6a9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs new file mode 100644 index 0000000..cdedb9e --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs @@ -0,0 +1,15 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.TrackingConfidence + // + public enum TrackingConfidence : int + { + Low =0, + High =1, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs.meta new file mode 100644 index 0000000..7579b29 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingConfidence.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7fc638ac4166d2945b7efa3e6699e510 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs new file mode 100644 index 0000000..f18ef9b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs @@ -0,0 +1,16 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.TrackingState + // + public enum TrackingState : int + { + NotTracked =0, + Inferred =1, + Tracked =2, + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs.meta new file mode 100644 index 0000000..0f46e66 --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/TrackingState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7448c7529f8b6564bb3357abc07b1ccf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs b/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs new file mode 100644 index 0000000..ea9679a --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs @@ -0,0 +1,48 @@ +using RootSystem = System; +using System.Linq; +using System.Collections.Generic; +namespace Windows.Kinect +{ + // + // Windows.Kinect.Vector4 + // + [RootSystem.Runtime.InteropServices.StructLayout(RootSystem.Runtime.InteropServices.LayoutKind.Sequential)] + public struct Vector4 + { + public float X { get; set; } + public float Y { get; set; } + public float Z { get; set; } + public float W { get; set; } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (!(obj is Vector4)) + { + return false; + } + + return this.Equals((Vector4)obj); + } + + public bool Equals(Vector4 obj) + { + return X.Equals(obj.X) && Y.Equals(obj.Y) && Z.Equals(obj.Z) && W.Equals(obj.W); + } + + public static bool operator ==(Vector4 a, Vector4 b) + { + return a.Equals(b); + } + + public static bool operator !=(Vector4 a, Vector4 b) + { + return !(a.Equals(b)); + } + } + +} diff --git a/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs.meta b/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs.meta new file mode 100644 index 0000000..a71047b --- /dev/null +++ b/CylVision/Assets/ThridParty/Windows/Kinect/Vector4.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6722a9a2a7c5eaa4f98f57c7aca7cfab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: