Esempio n. 1
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;
            }
        }
Esempio n. 2
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;
            }
        }
        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, 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;
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 7
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;
            }
        }