Example #1
0
 public void AddScreen(MotionTrackingScreen screen)
 {
     WPFPresenter presenter = new WPFPresenter(Factory, DepthPresenter.Width, DepthPresenter.Height);
     ScreenVisualizations.Add(screen, presenter);
 }
Example #2
0
        private void UpdateScreenVisualization(Dictionary<int, MotionTrackingDevice> devices, MotionTrackingScreen screen, WPFPresenter handPresenter)
        {
            handPresenter.Clear();

            edgeEffect.Tint = new Color4(1, 1, 0, 0);
            edgeEffect.MinThreshold = 300f;
            edgeEffect.MaxThreshold = 10000f;
            edgeEffect.EdgeThreshold = 100f;
            edgeEffect.TexSize = new Size(intermediateLayer.Width, intermediateLayer.Height);

            foreach (var innerkvp in devices)
            {
                var session = innerkvp.Value.Session;
                var rectf = new RectangleF((float)(session.PositionProjective.X - 100), (float)(session.PositionProjective.Y - 100), 200, 200);
                if (!screen.IsSessionInBounds(session))
                {
                    continue;
                }

                var p = screen.MapPositionToScreen(session, handPresenter.Width, handPresenter.Height);

                var targetRectf = new RectangleF((float)(p.X - 100), (float)(p.Y - 100), 200, 200);

                if (innerkvp.Value.ShouldPromoteToTouch)
                    thresholdEffect.Tint = new Color4(.8f, 0, 0, 0);
                else
                    thresholdEffect.Tint = new Color4(.4f, 0, 0, 0);
                thresholdEffect.MinThreshold = (float)(session.PositionProjective.Z - 100);
                thresholdEffect.MaxThreshold = (float)(session.PositionProjective.Z + 100);
                rawDepthLayer.ApplyEffect(thresholdEffect, intermediateLayer, true);

                //intermediateLayer.ApplyEffect(unpackEffect, effectLayer, true);

                //handPresenter.BeginDraw();
                //if (session.IsPromotedToTouch)
                //handPresenter.FillEllipse(contactBrush, new DirectCanvas.Shapes.Ellipse(new PointF((float)p.X, (float)p.Y), 20, 20));
                //else
                //  handPresenter.FillEllipse(hoverBrush, new DirectCanvas.Shapes.Ellipse(new PointF((float)p.X, (float)p.Y), 20, 20));
                //handPresenter.EndDraw();
                var tint = new Color4(1, 1, 1, 1);
                //if (innerkvp.Value.ShouldPromoteToTouch)
                //{
                //    tint.Alpha = 0.8f;
                //}
                handPresenter.BeginCompose();
                handPresenter.ComposeLayer(intermediateLayer, rectf, targetRectf, new RotationParameters(), tint);
                handPresenter.EndCompose();
            }

            handPresenter.Present();
        }
Example #3
0
        public void InitLayers(Size ImageSize)
        {
            hoverBrush = Factory.CreateSolidColorBrush(new Color4(.4f, 0, 0, 0));
            contactBrush = Factory.CreateSolidColorBrush(new Color4(.8f, 0, 0, 0));

            DepthPresenter = new WPFPresenter(Factory, ImageSize.Width, ImageSize.Height);
            intermediateLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height);
            rawDepthLayer = Factory.CreateDrawingLayer(ImageSize.Width, ImageSize.Height);

            DepthBrush = Factory.CreateDrawingLayerBrush(DepthPresenter);
            DepthBrush.Alignment = DirectCanvas.Brushes.BrushAlignment.DrawingLayerAbsolute;
        }
Example #4
0
        public System.Windows.Media.ImageSource ImageToImageSource(DepthFrame frame)
        {
            WPFPresenter presenter = new WPFPresenter(Factory, frame.Width, frame.Height);
            ushort minValue;
            ushort maxValue;
            var image = frame.ToDirectCanvasImage(Factory, out minValue, out maxValue);

            rawDepthLayer.CopyFromImage(image);

            unpackEffect.MinThreshold = 100f;
            unpackEffect.MaxThreshold = 1000f;
            unpackEffect.MinValue = minValue;
            unpackEffect.MaxValue = maxValue;
            unpackEffect.TexSize = new DirectCanvas.Misc.Size(rawDepthLayer.Width, rawDepthLayer.Height);
            rawDepthLayer.ApplyEffect(unpackEffect, presenter, true);
            presenter.Present();
            return presenter.ImageSource;
        }
        private void InitDirectCanvas()
        {
            m_directCanvasFactory = new DirectCanvasFactory();

            /* Create a new WindowsFromsPresenter, passing it our factory 
             * and our Winforms control that we want to render to */
            m_presenter = new WPFPresenter(m_directCanvasFactory,
                                           (int)Width /* Pixel width of our presenter */,
                                           (int)Height /* Pixel height of our presenter */,
                                           wpfImage /* The WPF Image to render to */);
            m_presenter.CurrentScene = m_scene;
            m_presenter.StartRendering();

            m_shaderScene = new PixelShaderScene(m_presenter);
            m_geometryScene = new GeometryScene(m_presenter);
            m_compositorScene = new CompositorScene(m_presenter);
            m_superBlurScene = new SuperBlur(m_presenter);
            m_transitionScene = new TransitionEffectScene(m_presenter);

            m_scene = m_geometryScene;
        }
Example #6
0
        private bool VerifyInit()
        {
            if (Factory == null || this.Image == null)
            {
                return false;
            }
            if (_drawingLayerSize.Width == 0 || _drawingLayerSize.Height == 0)
                return false;

            if (presenter == null)
            {
                presenter = new WPFPresenter(Factory, (int)DrawingLayerSize.Width, (int)DrawingLayerSize.Height);
            }

            return VerifyInitOverride();
        }