コード例 #1
0
        private IEnumerator Process(DepthMode depthMode, bool cpuOnly)
        {
            var debugDelegate = new AzureKinectBodyTracker.DebugLogDelegate(PluginDebugLogCallBack);
            var debagCallback = Marshal.GetFunctionPointerForDelegate(debugDelegate);

            AzureKinectBodyTracker.SetDebugLogCallback(debagCallback);

            var bodyRecognizedDelegate = new AzureKinectBodyTracker.BodyRecognizedDelegate(this.BodyRecognizedCallback);
            var bodyRecognizedCallback = Marshal.GetFunctionPointerForDelegate(bodyRecognizedDelegate);

            AzureKinectBodyTracker.SetBodyRecognizedCallback(bodyRecognizedCallback);

            var depthTextureId = 1u;
            var depthWidth     = (int)AzureKinectBodyTracker.DepthResolutions[depthMode].x;
            var depthHeight    = (int)AzureKinectBodyTracker.DepthResolutions[depthMode].y;

            this.depthTexture = new Texture2D((depthWidth > 0) ? depthWidth : 1, (depthHeight > 0) ? depthHeight : 1, TextureFormat.R16, false);
            this.depthMaterial.mainTexture = this.depthTexture;
            var colorTextureId = 2u;

            this.colorTexture = new Texture2D(1920, 1080, TextureFormat.BGRA32, false);
            this.colorMaterial.mainTexture = this.colorTexture;
            var transformedDepthTextureId = 3u;

            this.transformedDepthTexture = new Texture2D(1920, 1080, TextureFormat.R16, false);
            this.transformedDepthMaterial.mainTexture = this.transformedDepthTexture;

            var callback      = AzureKinectBodyTracker.GetTextureUpdateCallback();
            var commandBuffer = new CommandBuffer();

            commandBuffer.name = "AzureKinectImagesUpdeate";
            commandBuffer.IssuePluginCustomTextureUpdateV2(callback, this.depthTexture, depthTextureId);
            commandBuffer.IssuePluginCustomTextureUpdateV2(callback, this.colorTexture, colorTextureId);
            commandBuffer.IssuePluginCustomTextureUpdateV2(callback, this.transformedDepthTexture, transformedDepthTextureId);

            try
            {
                AzureKinectBodyTracker.Start(depthTextureId, colorTextureId, transformedDepthTextureId, depthMode, cpuOnly);
                this.currentDepthMode = depthMode;
            }
            catch (K4ABTException)
            {
                this.ProcessFinallize(false);
                yield break;
            }
            this.isRunning = true;
            while (this.isRunning)
            {
                Graphics.ExecuteCommandBuffer(commandBuffer);
                yield return(null);
            }
            AzureKinectBodyTracker.End();
            this.ProcessFinallize();
        }
コード例 #2
0
        void Start()
        {
            self             = this;
            this.syncContext = SynchronizationContext.Current;

            this.commandBuffer      = new CommandBuffer();
            this.commandBuffer.name = "AzureKinectImagesUpdeate";

            var debugDelegate = new AzureKinectBodyTracker.DebugLogDelegate(PluginDebugLogCallBack);
            var debagCallback = Marshal.GetFunctionPointerForDelegate(debugDelegate);

            AzureKinectBodyTracker.SetDebugLogCallback(debagCallback);

            var bodyRecognizedDelegate = new AzureKinectBodyTracker.BodyRecognizedDelegate(this.BodyRecognizedCallback);
            var bodyRecognizedCallback = Marshal.GetFunctionPointerForDelegate(bodyRecognizedDelegate);

            AzureKinectBodyTracker.SetBodyRecognizedCallback(bodyRecognizedCallback);

            this.StartCoroutine(this.Process());
        }
コード例 #3
0
        private IEnumerator Process(DepthMode depthMode, bool cpuOnly)
        {
            var debugDelegate = new AzureKinectBodyTracker.DebugLogDelegate(PluginDebugLogCallBack);
            var debagCallback = Marshal.GetFunctionPointerForDelegate(debugDelegate);

            AzureKinectBodyTracker.SetDebugLogCallback(debagCallback);

            try
            {
                AzureKinectBodyTracker.Start(0, 0, 0, depthMode, cpuOnly);
                this.currentDepthMode = depthMode;
            }
            catch (K4ABTException)
            {
                this.ProcessFinallize(false);
                yield break;
            }

            var depthImageToPointCloudDelegate = new AzureKinectBodyTracker.DepthImageToPointCloudDelegate(this.DepthImageToPointCloudCallback);
            var depthImageToPointCloudCallback = Marshal.GetFunctionPointerForDelegate(depthImageToPointCloudDelegate);

            AzureKinectBodyTracker.SetDepthImageToPointCloudCallback(depthImageToPointCloudCallback);

            var colorImageToDepthSpaceDelegate = new AzureKinectBodyTracker.ColorImageToDepthSpaceDelegate(this.ColorImageToDepthSpaceCallback);
            var colorImageToDepthSpaceCallback = Marshal.GetFunctionPointerForDelegate(colorImageToDepthSpaceDelegate);

            AzureKinectBodyTracker.SetColorImageToDepthSpaceCallback(colorImageToDepthSpaceCallback);

            this.isRunning = true;
            while (this.isRunning)
            {
                yield return(null);
            }
            AzureKinectBodyTracker.End();
            this.ProcessFinallize();
        }