private void InitVariables()
 {
     this.boundingBoxes         = new List <RectI32>();
     this.landmarks             = new List <LandmarkPoint[]>();
     this.allLandmarks          = new List <LandmarkPoint[]>();
     this.landmarkBoundingBoxes = new List <RectI32>();
     this.colors       = new List <System.Windows.Media.Color>();
     this.depthFormats = new List <String>();
     this.depthFormats.Add("Depth");
     this.depthFormats.Add("Depth Raw");
     this.depthFormats.Add("RGB32");
     this.colorFormats = new List <String>();
     this.colorFormats.Add("RGB32");
     this.colorFormats.Add("RGB24");
     this.landmarkGroup           = LandmarksGroupType.LANDMARK_GROUP_MOUTH;
     this.extractLandmarkGroup    = true;
     this.drawFaceBoundingBox     = false;
     this.drawLandmarkPoints      = false;
     this.drawLandmarkBoundingBox = true;
     this.captureImage            = false;
     this.captureSeries           = false;
     this.pauseSave               = false;
     this.seriesCaptured          = 0;
     this.seriesToCapture         = 0;
     this.streamBox.SelectedIndex = 0;
     this.dirName          = "";
     this.colorPixelFormat = Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB32;
     this.depthPixelFormat = Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_RAW;
     this.boxWidth         = 140;
     this.boxHeight        = 80;
 }
        private System.Windows.Media.PixelFormat ConvertPixelFormat(Intel.RealSense.PixelFormat pixelFormat)
        {
            System.Windows.Media.PixelFormat convertedPixelFormat;
            switch (pixelFormat)
            {
            case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB32:
                convertedPixelFormat = System.Windows.Media.PixelFormats.Bgr32;
                break;

            case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB24:
                convertedPixelFormat = System.Windows.Media.PixelFormats.Bgr24;
                break;

            case Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH:
            case Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_RAW:
                convertedPixelFormat = System.Windows.Media.PixelFormats.Gray16;
                break;

            default:
                convertedPixelFormat = System.Windows.Media.PixelFormats.Bgr32;
                break;
            }

            return(convertedPixelFormat);
        }
        private int GetDepthIndexFromPixelFormat(Intel.RealSense.PixelFormat pixelFormat)
        {
            int index = 0;

            if (streamBox.SelectedIndex != -1)
            {
                String streamType = (streamBox.SelectedItem as ComboBoxItem).Content.ToString();

                switch (pixelFormat)
                {
                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_RAW:
                    index = 1;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_CONFIDENCE:
                    index = 2;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_DEPTH_F32:
                    index = 3;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB32:
                    index = 4;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB24:
                    index = 5;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGB:
                    index = 6;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_RGBA:
                    index = 7;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_Y16:
                    index = 8;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_Y8:
                    index = 9;
                    break;

                case Intel.RealSense.PixelFormat.PIXEL_FORMAT_YUY2:
                    index = 10;
                    break;
                }
            }
            return(index);
        }
        private void PixelFormatBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (streamBox.SelectedIndex != -1 && pixelFormatBox.SelectedIndex != -1)
            {
                String streamType = (streamBox.SelectedItem as ComboBoxItem).Content.ToString();
                String pixelType  = (pixelFormatBox.SelectedItem as ComboBoxItem).Content.ToString();

                if (streamType.ToLower().Equals("depth"))
                {
                    depthPixelFormat = GetPixelFormatFromString(pixelType);
                }
                else
                {
                    colorPixelFormat = GetPixelFormatFromString(pixelType);
                }
            }
        }
        private int GetIndexFromPixelFormat(Intel.RealSense.PixelFormat pixelFormat)
        {
            int index = 0;

            if (streamBox.SelectedIndex != -1)
            {
                String streamType = (streamBox.SelectedItem as ComboBoxItem).Content.ToString();
                if (streamType.ToLower().Equals("depth"))
                {
                    index = GetDepthIndexFromPixelFormat(pixelFormat);
                }
                else
                {
                    index = GetColorIndexFromPixelFormat(pixelFormat);
                }
            }
            return(index);
        }