Beispiel #1
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            switch (currentDisplayFrameType)
            {
                case DisplayFrameType.bodyTracking:
                     this.currentFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    this.displayWidth = this.currentFrameDescription.Width;
                    this.displayHeight = this.currentFrameDescription.Height;
                    this.setupBodyJoints();
                    break;
                case DisplayFrameType.Color:
                    if (this.kinectSensor.ColorFrameSource.FrameDescription != null)
                    {
                        this.currentFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    }
                   // this.currentFrameDescription = colorFrameDescription;
                    this.colorBitmap = new WriteableBitmap(this.currentFrameDescription.Width, this.currentFrameDescription.Height, 96, 96, PixelFormats.Bgr32, null);
                    colorPixels = new byte[this.currentFrameDescription.Width * this.currentFrameDescription.Height * bytePerPixel];
                    break;

                default:
                    break;
            }

        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            switch (currentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;

                // Allocate space for pixels being recieved and converted
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];

                // Create the Bitmap to display
                this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            case DisplayFrameType.Color:
                FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;

                // Create the Bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            default:
                break;
            }
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;

            switch (currentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap            = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            case DisplayFrameType.Color:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.Depth:
                FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                this.CurrentFrameDescription = depthFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                this.bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;

            case DisplayFrameType.BodyMask:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // allocate space to put the pixels being received and converted
                this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            switch (currentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                // this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray32Float, null);
                break;

            case DisplayFrameType.Depth:
                FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                this.bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray32Float, null);
                break;

            default:
                break;
            }
        }
Beispiel #5
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType, bool isFullScreen = true)
        {
            if (isFullScreen)
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(0) });
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(0) });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(70) });
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
                RootGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(100) });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }

            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            FrameDescription depthFrameDescription = null;
            FrameDescription infraredFrameDescription = null;
            // reset the display methods
            FacePointsCanvas.Children.Clear();
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
                case DisplayFrameType.Infrared:
                    infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                    this.CurrentFrameDescription = infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    break;

                case DisplayFrameType.Color:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.Depth:
                    depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    this.CurrentFrameDescription = depthFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    this.depthPixels = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyMask:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyJoints:
                    depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    // instantiate a new Canvas
                    this.drawingCanvas = new Canvas();
                    // set the clip rectangle to prevent rendering outside the canvas
                    this.drawingCanvas.Clip = new RectangleGeometry();
                    this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                    this.drawingCanvas.Width = this.BodyJointsGrid.Width;
                    this.drawingCanvas.Height = this.BodyJointsGrid.Height;
                    // reset the body joints grid
                    this.BodyJointsGrid.Visibility = Visibility.Visible;
                    this.BodyJointsGrid.Children.Clear();
                    // add canvas to DisplayGrid
                    this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                    bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                    break;

                case DisplayFrameType.BackgroundRemoved:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    // Actual current frame is going to be a map of depth and color, choosing the larger to display(color)
                    this.CurrentFrameDescription = colorFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;
                case DisplayFrameType.FaceOnColor:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    this.FacePointsCanvas.Width = colorFrameDescription.Width;
                    this.FacePointsCanvas.Height = colorFrameDescription.Height;
                    this.faceFrameFeatures =
                            FaceFrameFeatures.BoundingBoxInColorSpace
                            | FaceFrameFeatures.PointsInColorSpace
                            | FaceFrameFeatures.RotationOrientation
                            | FaceFrameFeatures.FaceEngagement
                            | FaceFrameFeatures.Glasses
                            | FaceFrameFeatures.Happy
                            | FaceFrameFeatures.LeftEyeClosed
                            | FaceFrameFeatures.RightEyeClosed
                            | FaceFrameFeatures.LookingAway
                            | FaceFrameFeatures.MouthMoved
                            | FaceFrameFeatures.MouthOpen;
                    break;

                case DisplayFrameType.FaceOnInfrared:
                    infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                    this.CurrentFrameDescription = infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    this.FacePointsCanvas.Width = infraredFrameDescription.Width;
                    this.FacePointsCanvas.Height = infraredFrameDescription.Height;
                    break;

                case DisplayFrameType.FaceGame:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    this.FacePointsCanvas.Width = colorFrameDescription.Width;
                    this.FacePointsCanvas.Height = colorFrameDescription.Height;
                    break;

                default:
                    break;
            }
        }
Beispiel #6
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            FrameDescription depthFrameDescription = null;

            // reset the display methods
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap            = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            case DisplayFrameType.Color:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.Depth:
                depthFrameDescription        = this.kinectSensor.DepthFrameSource.FrameDescription;
                this.CurrentFrameDescription = depthFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                this.bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;

            case DisplayFrameType.BodyMask:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // allocate space to put the pixels being received and converted
                this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.BodyJoints:
                // instantiate a new Canvas
                this.drawingCanvas = new Canvas();
                // set the clip rectangle to prevent rendering outside the canvas
                this.drawingCanvas.Clip      = new RectangleGeometry();
                this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                this.drawingCanvas.Width     = this.BodyJointsGrid.Width;
                this.drawingCanvas.Height    = this.BodyJointsGrid.Height;
                // reset the body joints grid
                this.BodyJointsGrid.Visibility = Visibility.Visible;
                this.BodyJointsGrid.Children.Clear();
                // add canvas to DisplayGrid
                this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                break;

            case DisplayFrameType.BackgroundRemoved:
                colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                // Actual current frame is going to be a map of depth and color, choosing the larger to display(color)
                this.CurrentFrameDescription = colorFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData           = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            default:
                break;
            }
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            // reset the display methods
            if (BodyJointsGrid!= null)
            {
                BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (FrameDisplayImage!= null)
            {
                FrameDisplayImage.Source = null;
            }
            switch (currentDisplayFrameType)
            {
                case DisplayFrameType.Infrared:
                    FrameDescription infraredFrameDescription = kinectSensor.InfraredFrameSource.FrameDescription;
                    CurrentFrameDescription= infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    infraredFrameData= new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    infraredPixels= new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    bitmap= new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    break;

                case DisplayFrameType.Color:
                    colorFrameDescription =kinectSensor.ColorFrameSource.FrameDescription;
                    CurrentFrameDescription= colorFrameDescription;
                    // create the bitmap to display
                    bitmap= new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.Depth:
                    FrameDescription depthFrameDescription = kinectSensor.DepthFrameSource.FrameDescription;
                    CurrentFrameDescription= depthFrameDescription;
                    // allocate space to put the pixels being received and converted
                    depthFrameData= new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    depthPixels= new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                    bitmap= new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyJoints:
                    // instantiate a new Canvas
                    drawingCanvas= new Canvas();
                    // set the clip rectangle to prevent rendering outside the canvas
                    drawingCanvas.Clip = new RectangleGeometry();
                    drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, BodyJointsGrid.Width, BodyJointsGrid.Height);
                    drawingCanvas.Width =BodyJointsGrid.Width;
                    drawingCanvas.Height =BodyJointsGrid.Height;
                    // reset the body joints grid
                    BodyJointsGrid.Visibility = Visibility.Visible;
                    BodyJointsGrid.Children.Clear();
                    // add canvas to DisplayGrid
                    BodyJointsGrid.Children.Add(drawingCanvas);
                    bodiesManager = new BodiesManager(coordinateMapper, drawingCanvas, kinectSensor.BodyFrameSource.BodyCount);
                    break;
                default:
                    break;
            }
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;

            switch (currentDisplayFrameType)
            {
                case DisplayFrameType.Infrared:

                    FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;

                    this.CurrentFrameDescription = infraredFrameDescription;

                    // allocate space to put the pixel being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width*infraredFrameDescription.Height];

                    this.infraredPixels = new byte[infraredFrameDescription.Width*infraredFrameDescription.Height*BytesPerPixel];

                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);

                    break;

                case DisplayFrameType.Color:

                    FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;

                    this.CurrentFrameDescription = colorFrameDescription;

                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);

                    break;

                case DisplayFrameType.Depth:

                    FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;

                    this.CurrentFrameDescription = depthFrameDescription;

                    // allocate space to put the pixels being, received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];

                    this.depthPixels = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];

                    this.bitmap = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);

                    break;

                default:
                    break;

            }
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType, bool isFullScreen = true)
        {
            if (isFullScreen)
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(0)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(0)
                });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(70)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(100)
                });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }

            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            FrameDescription depthFrameDescription = null;

            // reset the display methods
            FacePointsCanvas.Children.Clear();
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription =
                    this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being
                // received and converted
                this.infraredFrameData =
                    new ushort[infraredFrameDescription.Width *
                               infraredFrameDescription.Height];
                this.infraredPixels =
                    new byte[infraredFrameDescription.Width *
                             infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap =
                    new WriteableBitmap(infraredFrameDescription.Width,
                                        infraredFrameDescription.Height);
                break;

            case DisplayFrameType.BodyJoints:

                depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                // instantiate a new Canvas
                this.drawingCanvas = new Canvas();
                // set the clip rectangle to prevent rendering outside the canvas
                this.drawingCanvas.Clip      = new RectangleGeometry();
                this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                this.drawingCanvas.Width     = this.BodyJointsGrid.Width;
                this.drawingCanvas.Height    = this.BodyJointsGrid.Height;
                // reset the body joints grid
                this.BodyJointsGrid.Visibility = Visibility.Visible;
                this.BodyJointsGrid.Children.Clear();
                // add canvas to DisplayGrid
                this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                break;


            default:
                break;
            }
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch statement
            FrameDescription colorFrameDescription = null;

            //reset the display methods
            if (BodyJointsGrid != null)
            {
                BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (FrameDisplayImage != null)
            {
                FrameDisplayImage.Source = null;
            }
            switch (currentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = kinectSensor.InfraredFrameSource.FrameDescription;
                CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BYTES_PER_PIXEL];
                bitmap            = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            case DisplayFrameType.Color:
                colorFrameDescription   = kinectSensor.ColorFrameSource.FrameDescription;
                CurrentFrameDescription = colorFrameDescription;
                // create the bitmap
                bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.Depth:
                FrameDescription depthFrameDescription = kinectSensor.DepthFrameSource.FrameDescription;
                CurrentFrameDescription = depthFrameDescription;
                depthFrameData          = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                depthPixels             = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BYTES_PER_PIXEL];
                bitmap = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;

            case DisplayFrameType.BodyMask:
                colorFrameDescription    = kinectSensor.ColorFrameSource.FrameDescription;
                CurrentFrameDescription  = colorFrameDescription;
                colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.BodyJoints:
                // instantiate a new Canvas
                drawingCanvas           = new Canvas();
                drawingCanvas.Clip      = new RectangleGeometry();
                drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, BodyJointsGrid.Width, BodyJointsGrid.Height);
                // reset the body joints grid
                BodyJointsGrid.Visibility = Visibility.Visible;
                BodyJointsGrid.Children.Clear();
                // add canvas to DisplayGrid
                BodyJointsGrid.Children.Add(drawingCanvas);
                bodiesManager = new BodiesManager(coordinateMapper, drawingCanvas, kinectSensor.BodyFrameSource.BodyCount);
                break;

            default:
                break;
            }
        }
Beispiel #11
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            switch (currentDisplayFrameType)
            {
                case DisplayFrameType.Infrared:
                    FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                    this.CurrentFrameDescription = infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    break;

                case DisplayFrameType.Color:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.Depth:
                    FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    this.CurrentFrameDescription = depthFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    this.depthPixels = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyMask:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;
                default:
                    break;
            }
        }
Beispiel #12
0
        //This function takes the frame type, and creates the view for the
        // new window to be rendered in the view selected
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            currentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;

            // reset the display methods
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (currentDisplayFrameType) // setting data between different views
            {
            //The case for infrared, not used in experiment
            case DisplayFrameType.Infrared:
                FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap            = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            // case for Color playback, control for experiment
            case DisplayFrameType.Color:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            //case for Depth playback, not used for experiment
            case DisplayFrameType.Depth:
                FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                this.CurrentFrameDescription = depthFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                this.bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;


            // case for Body Indexing, used to test in experiment
            case DisplayFrameType.BodyJoints:
                // instantiate a new Canvas
                this.drawingCanvas = new Canvas();
                // set the clip rectangle to prevent rendering outside the canvas
                this.drawingCanvas.Clip      = new RectangleGeometry();
                this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                this.drawingCanvas.Width     = this.BodyJointsGrid.Width;
                this.drawingCanvas.Height    = this.BodyJointsGrid.Height;
                // reset the body joints grid
                this.BodyJointsGrid.Visibility = Visibility.Visible;
                this.BodyJointsGrid.Children.Clear();
                // add canvas to DisplayGrid
                this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                break;

            default:
                break;
            }
        }
Beispiel #13
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            FrameDescription depthFrameDescription = null;
            // reset the display methods
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
                case DisplayFrameType.Infrared:
                    FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                    this.CurrentFrameDescription = infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    break;

                case DisplayFrameType.Color:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.Depth:
                    depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    this.CurrentFrameDescription = depthFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    this.depthPixels = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyMask:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;

                case DisplayFrameType.BodyJoints:
                    // instantiate a new Canvas
                    this.drawingCanvas = new Canvas();
                    // set the clip rectangle to prevent rendering outside the canvas
                    this.drawingCanvas.Clip = new RectangleGeometry();
                    this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                    this.drawingCanvas.Width = this.BodyJointsGrid.Width;
                    this.drawingCanvas.Height = this.BodyJointsGrid.Height;
                    // reset the body joints grid
                    this.BodyJointsGrid.Visibility = Visibility.Visible;
                    this.BodyJointsGrid.Children.Clear();
                    // add canvas to DisplayGrid
                    this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                    bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                    break;

                case DisplayFrameType.BackgroundRemoved:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                    // Actual current frame is going to be a map of depth and color, choosing the larger to display(color)
                    this.CurrentFrameDescription = colorFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                    this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    break;
                default:
                    break;
            }
        }
Beispiel #14
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType, bool isFullScreen = true)
        {
            if (isFullScreen)
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(0)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(0)
                });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
            else
            {
                RootGrid.RowDefinitions.Clear();
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(70)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                RootGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(100)
                });
                FullScreenBackButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }

            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription    = null;
            FrameDescription depthFrameDescription    = null;
            FrameDescription infraredFrameDescription = null;

            // reset the display methods
            FacePointsCanvas.Children.Clear();
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
            case DisplayFrameType.Infrared:
                infraredFrameDescription     = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels    = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap            = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                break;

            case DisplayFrameType.Color:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.Depth:
                depthFrameDescription        = this.kinectSensor.DepthFrameSource.FrameDescription;
                this.CurrentFrameDescription = depthFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                this.bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;

            case DisplayFrameType.BodyMask:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // allocate space to put the pixels being received and converted
                this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.BodyJoints:
                depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                // instantiate a new Canvas
                this.drawingCanvas = new Canvas();
                // set the clip rectangle to prevent rendering outside the canvas
                this.drawingCanvas.Clip      = new RectangleGeometry();
                this.drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, this.BodyJointsGrid.Width, this.BodyJointsGrid.Height);
                this.drawingCanvas.Width     = this.BodyJointsGrid.Width;
                this.drawingCanvas.Height    = this.BodyJointsGrid.Height;
                // reset the body joints grid
                this.BodyJointsGrid.Visibility = Visibility.Visible;
                this.BodyJointsGrid.Children.Clear();
                // add canvas to DisplayGrid
                this.BodyJointsGrid.Children.Add(this.drawingCanvas);
                bodiesManager = new BodiesManager(this.coordinateMapper, this.drawingCanvas, this.kinectSensor.BodyFrameSource.BodyCount);
                break;

            case DisplayFrameType.BackgroundRemoved:
                colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
                // Actual current frame is going to be a map of depth and color, choosing the larger to display(color)
                this.CurrentFrameDescription = colorFrameDescription;
                // allocate space to put the pixels being received and converted
                this.depthFrameData           = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                this.colorMappedToDepthPoints = new DepthSpacePoint[colorFrameDescription.Width * colorFrameDescription.Height];
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.FaceOnColor:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                this.FacePointsCanvas.Width  = colorFrameDescription.Width;
                this.FacePointsCanvas.Height = colorFrameDescription.Height;
                this.faceFrameFeatures       =
                    FaceFrameFeatures.BoundingBoxInColorSpace
                    | FaceFrameFeatures.PointsInColorSpace
                    | FaceFrameFeatures.RotationOrientation
                    | FaceFrameFeatures.FaceEngagement
                    | FaceFrameFeatures.Glasses
                    | FaceFrameFeatures.Happy
                    | FaceFrameFeatures.LeftEyeClosed
                    | FaceFrameFeatures.RightEyeClosed
                    | FaceFrameFeatures.LookingAway
                    | FaceFrameFeatures.MouthMoved
                    | FaceFrameFeatures.MouthOpen;
                break;

            case DisplayFrameType.FaceOnInfrared:
                infraredFrameDescription     = this.kinectSensor.InfraredFrameSource.FrameDescription;
                this.CurrentFrameDescription = infraredFrameDescription;
                // allocate space to put the pixels being received and converted
                this.infraredFrameData       = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                this.infraredPixels          = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                this.bitmap                  = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                this.FacePointsCanvas.Width  = infraredFrameDescription.Width;
                this.FacePointsCanvas.Height = infraredFrameDescription.Height;
                break;

            case DisplayFrameType.FaceGame:
                colorFrameDescription        = this.kinectSensor.ColorFrameSource.FrameDescription;
                this.CurrentFrameDescription = colorFrameDescription;
                this.FacePointsCanvas.Width  = colorFrameDescription.Width;
                this.FacePointsCanvas.Height = colorFrameDescription.Height;
                break;

            default:
                break;
            }
        }
Beispiel #15
0
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            CurrentDisplayFrameType = newDisplayFrameType;

            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription;
            FrameDescription depthFrameDescription;

            // Instantiate a new canvas
            _drawingCanvas = new Canvas();

            if (BodyJointsGrid != null)
            {
                BodyJointsGrid.Visibility = Visibility.Collapsed;
            }

            if (FrameDisplayImage != null)
            {
                FrameDisplayImage.Source = null;
            }

            switch (CurrentDisplayFrameType)
            {
            case DisplayFrameType.Colour:
                colorFrameDescription   = _kinectSensor.ColorFrameSource.FrameDescription;
                CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                _bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                break;

            case DisplayFrameType.Depth:
                depthFrameDescription   = _kinectSensor.DepthFrameSource.FrameDescription;
                CurrentFrameDescription = depthFrameDescription;
                // allocate space to put the pixels being received and converted
                _depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                _depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                _bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);
                break;

            case DisplayFrameType.JointsOnColour:
                // Colour data
                colorFrameDescription   = _kinectSensor.ColorFrameSource.FrameDescription;
                CurrentFrameDescription = colorFrameDescription;
                // create the bitmap to display
                _bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);

                // Joints data
                // set the clip rectangle to prevent rendering outside the canvas
                _drawingCanvas.Clip = new RectangleGeometry();
                if (BodyJointsGrid != null)
                {
                    _drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, BodyJointsGrid.Width, BodyJointsGrid.Height);
                    _drawingCanvas.Width     = BodyJointsGrid.Width;
                    _drawingCanvas.Height    = BodyJointsGrid.Height;
                    // reset the body joints grid
                    BodyJointsGrid.Visibility = Visibility.Visible;
                    BodyJointsGrid.Children.Clear();
                    // add canvas to DisplayGrid
                    BodyJointsGrid.Children.Add(_drawingCanvas);
                }

                _bodiesManager = new BodiesManager(_coordinateMapper, _drawingCanvas, _kinectSensor.BodyFrameSource.BodyCount);
                break;

            case DisplayFrameType.JointsOnDepth:

                //Depth data
                depthFrameDescription   = _kinectSensor.DepthFrameSource.FrameDescription;
                CurrentFrameDescription = depthFrameDescription;

                // allocate space to put the pixels being received and converted
                _depthFrameData = new ushort[depthFrameDescription.Width * depthFrameDescription.Height];
                _depthPixels    = new byte[depthFrameDescription.Width * depthFrameDescription.Height * BytesPerPixel];
                _bitmap         = new WriteableBitmap(depthFrameDescription.Width, depthFrameDescription.Height);

                // set the clip rectangle to prevent rendering outside the canvas
                _drawingCanvas.Clip = new RectangleGeometry();
                if (BodyJointsGrid != null)
                {
                    _drawingCanvas.Clip.Rect = new Rect(0.0, 0.0, BodyJointsGrid.Width, BodyJointsGrid.Height);
                    _drawingCanvas.Width     = BodyJointsGrid.Width;
                    _drawingCanvas.Height    = BodyJointsGrid.Height;

                    // reset the body joints grid
                    BodyJointsGrid.Visibility = Visibility.Visible;
                    BodyJointsGrid.Children.Clear();

                    // add canvas to DisplayGrid
                    BodyJointsGrid.Children.Add(_drawingCanvas);
                }

                _bodiesManager = new BodiesManager(_coordinateMapper, _drawingCanvas, _kinectSensor.BodyFrameSource.BodyCount);
                break;

            default:
                break;
            }

            SetupLocationFlags();
        }
        private void SetupCurrentDisplay(DisplayFrameType newDisplayFrameType)
        {
            CurrentDisplayFrameType = newDisplayFrameType;
            // Frames used by more than one type are declared outside the switch
            FrameDescription colorFrameDescription = null;
            FrameDescription infraredFrameDescription = null;
            // reset the display methods
            FacePointsCanvas.Children.Clear();
            if (this.BodyJointsGrid != null)
            {
                this.BodyJointsGrid.Visibility = Visibility.Collapsed;
            }
            if (this.FrameDisplayImage != null)
            {
                this.FrameDisplayImage.Source = null;
            }
            switch (CurrentDisplayFrameType)
            {
                case DisplayFrameType.FaceOnColor:
                    colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
                    this.CurrentFrameDescription = colorFrameDescription;
                    // create the bitmap to display
                    this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height);
                    this.FacePointsCanvas.Width = colorFrameDescription.Width;
                    this.FacePointsCanvas.Height = colorFrameDescription.Height;
                    this.faceFrameFeatures =
                            FaceFrameFeatures.BoundingBoxInColorSpace
                            | FaceFrameFeatures.PointsInColorSpace
                            | FaceFrameFeatures.RotationOrientation
                            | FaceFrameFeatures.FaceEngagement
                            | FaceFrameFeatures.Glasses
                            | FaceFrameFeatures.Happy
                            | FaceFrameFeatures.LeftEyeClosed
                            | FaceFrameFeatures.RightEyeClosed
                            | FaceFrameFeatures.LookingAway
                            | FaceFrameFeatures.MouthMoved
                            | FaceFrameFeatures.MouthOpen;
                    break;

                case DisplayFrameType.FaceOnInfrared:
                    infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription;
                    this.CurrentFrameDescription = infraredFrameDescription;
                    // allocate space to put the pixels being received and converted
                    this.infraredFrameData = new ushort[infraredFrameDescription.Width * infraredFrameDescription.Height];
                    this.infraredPixels = new byte[infraredFrameDescription.Width * infraredFrameDescription.Height * BytesPerPixel];
                    this.bitmap = new WriteableBitmap(infraredFrameDescription.Width, infraredFrameDescription.Height);
                    this.FacePointsCanvas.Width = infraredFrameDescription.Width;
                    this.FacePointsCanvas.Height = infraredFrameDescription.Height;
                    break;

                default:
                    break;
            }
        }