示例#1
0
        private void BodyReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            SkeletonOutput.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                               () =>
            {
                var coordinateMapper = _kinectSensor.GetCoordinateMapper();
                SkeletonOutput.FillBodies(
                    e.BodyFrame.Bodies,
                    _colorCameraIntrinsics,
                    p => coordinateMapper.MapDepthSpacePointToColor(p));

                DepthSkeletonOutput.FillBodies(
                    e.BodyFrame.Bodies,
                    _depthCameraIntrinsics,
                    p => p);
            });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
示例#2
0
        private async void CompositionTarget_Rendering(object sender, object e)
        {
            if (Interlocked.CompareExchange(ref _isRenderingDepth, 1, 0) == 0)
            {
                try
                {
                    SoftwareBitmap availableFrame = null;
                    while ((availableFrame = Interlocked.Exchange(ref _depthBackBuffer, null)) != null)
                    {
                        await((SoftwareBitmapSource)DepthOutput.Source).SetBitmapAsync(availableFrame);
                        availableFrame.Dispose();
                    }
                }
                finally
                {
                    Interlocked.Exchange(ref _isRenderingDepth, 0);
                }
            }

            if (Interlocked.CompareExchange(ref _isRenderingColor, 1, 0) == 0)
            {
                try
                {
                    SoftwareBitmap availableFrame = null;
                    while ((availableFrame = Interlocked.Exchange(ref _colorBackBuffer, null)) != null)
                    {
                        await((SoftwareBitmapSource)ColorOutput.Source).SetBitmapAsync(availableFrame);
                        availableFrame.Dispose();
                    }
                }
                finally
                {
                    Interlocked.Exchange(ref _isRenderingColor, 0);
                }
            }

            if (Interlocked.CompareExchange(ref _isRederingBodyIndex, 1, 0) == 0)
            {
                try
                {
                    SoftwareBitmap availableFrame = null;
                    while ((availableFrame = Interlocked.Exchange(ref _bodyIndexBackBuffer, null)) != null)
                    {
                        await((SoftwareBitmapSource)BodyIndexOutput.Source).SetBitmapAsync(availableFrame);
                        availableFrame.Dispose();
                    }
                }
                finally
                {
                    Interlocked.Exchange(ref _isRederingBodyIndex, 0);
                }
            }

            if (_bodies != null)
            {
                var coordinateMapper = _kinectSensor.GetCoordinateMapper();
                SkeletonOutput.FillBodies(
                    _bodies,
                    _colorCameraIntrinsics,
                    p => coordinateMapper.MapDepthSpacePointToColor(p));

                DepthSkeletonOutput.FillBodies(
                    _bodies,
                    _depthCameraIntrinsics,
                    p => p);
            }
        }