public System.Windows.Media.ImageSource GetImageSourceForScreen(MotionTrackingScreen screen) { if (ScreenVisualizations.ContainsKey(screen)) { return ScreenVisualizations[screen].ImageSource; } return null; }
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(); }
public void AddScreen(MotionTrackingScreen screen) { WPFPresenter presenter = new WPFPresenter(Factory, DepthPresenter.Width, DepthPresenter.Height); ScreenVisualizations.Add(screen, presenter); }
public void RemoveScreen(MotionTrackingScreen screen) { if (ScreenVisualizations.ContainsKey(screen)) { ScreenVisualizations.Remove(screen); } }