Example #1
0
 public void swapBackground(chromaKeyImageData _newData)
 {
     if (gsView != null)
     {
         gsView.changeBackground(_newData);
     }
 }
Example #2
0
        /// <summary>
        /// In this version the chromaKeyImageData contains already loaded BitmapImages
        /// </summary>
        /// <param name="sensor"></param>
        /// <param name="_width"></param>
        /// <param name="_height"></param>
        /// <param name="_initialBG"></param>
        /// <param name="_initialFG"></param>
        public void init(ref KinectSensor sensor, double _width, double _height, chromaKeyImageData _initialChromaKData)
        {
            _sensor     = sensor;
            _thisWidth  = _width;
            _thisHeight = _height;

            setupKinectOrNoK(_initialChromaKData);
            // Ensure we only have ONE photo submitter
            _photoSubmitter = new ThreadedPhotoSubmission();
            _photoSubmitter.ImageSubmissionComplete += handlePhotoSubmittedToCMS;
        }
Example #3
0
 public void changeBackground(chromaKeyImageData _newKeyPhotoData)
 {
     if (_bgImage != null)
     {
         if (_newKeyPhotoData.BackgroundImageBM != null)
         {
             _bgImage.Source = _newKeyPhotoData.BackgroundImageBM;
         }
     }
     if (_fgImage != null)
     {
         if (_newKeyPhotoData.ForegroundImageBM != null)
         {
             _fgImage.Source = _newKeyPhotoData.ForegroundImageBM;
         }
         else
         {
             _fgImage.Source = null;
         }
     }
 }
Example #4
0
        private void setupKinectOrNoK(chromaKeyImageData _initalData)
        {
            // Create the background image reguardless
            _bgImage         = new Image();
            _bgImage.Name    = "backgroundImage";
            _bgImage.Width   = _thisWidth;
            _bgImage.Height  = _thisHeight;
            _bgImage.Stretch = Stretch.Fill;
            kiddieHolder.Children.Add(_bgImage);

            _bgImage.Source = _initalData.BackgroundImageBM;

            if (_sensor != null)
            {
                // Create the image
                _kColorImage        = new Image();
                _kColorImage.Name   = "UserPhoto";
                _kColorImage.Width  = 640 * Properties.Settings.Default.kinectDepthImageScale;
                _kColorImage.Height = 480 * Properties.Settings.Default.kinectDepthImageScale;
                kiddieHolder.Children.Add(_kColorImage);
                // This does fill or exceede the visual area but the kinects depth stream is not as large as the color stream..so we need to offset the left and
                // top by a uniform ammount as we scale too.
                Canvas.SetTop(_kColorImage, _depthTopOffset);
                Canvas.SetLeft(_kColorImage, _depthLeftOffset);

                this.colorBitmap         = new WriteableBitmap(this._sensor.ColorStream.FrameWidth, this._sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
                this.maskBitmap          = new WriteableBitmap(_sensor.DepthStream.FrameWidth, _sensor.DepthStream.FrameHeight, 96, 96, PixelFormats.Bgra32, null);
                this._kColorImage.Source = this.colorBitmap;

                // colorBitmap serves as our main source for the player image - BUT we have an opacity mask on that guy too which is generated
                // from an image brush made by our "green screen" data. By having that secondary image we can use fast WPF blurs on it and do other
                // manipulations
                _blurMaskSource       = new Image();
                blurMaskEffect        = new BlurEffect();
                blurMaskEffect.Radius = _postblurAmmount;

                blurMaskVisualBrush        = new VisualBrush();
                blurMaskVisualBrush.Visual = _blurMaskSource;
                //_blurMaskSource.Source = maskBitmap;
                _blurMaskSource.Effect = blurMaskEffect;

                this._kColorImage.OpacityMask = this.blurMaskVisualBrush;

                // Init the green screen work horse
                _greenScreenProcessor  = new GreenScreenImplementation(this._sensor);
                _blurMaskSource.Source = _greenScreenProcessor.greenScreenMask;
                _greenScreenProcessor.frameReadyForDisplay += greenScreenFrameReady;

                _sensor.AllFramesReady += kinectAllFramesReady;
            }
            else
            {
                // Create the kinect needed
                _noKinect        = new KFWIcon();
                _noKinect.Name   = "kwfLogo";
                _noKinect.Width  = 328;
                _noKinect.Height = 180;
                _noKinect.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                _noKinect.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                kiddieHolder.Children.Add(_noKinect);
            }

            // Foreground too, but it may not have anything
            _fgImage         = new Image();
            _fgImage.Name    = "foregroundImage";
            _fgImage.Width   = _thisWidth;
            _fgImage.Height  = _thisHeight;
            _fgImage.Stretch = Stretch.Fill;
            kiddieHolder.Children.Add(_fgImage);

            if (_initalData.ForegroundImageBM != null)
            {
                _fgImage.Source = _initalData.ForegroundImageBM;
            }
        }