/// <summary> /// Draws the average energy used in session. /// </summary> private static void DrawAverageEnergyUse() { var canvas = _dataCanvas; var averageEnergyUse = EnergyHistory.GetAverageEnergyUsed(); var headlineBlock = new TextBlock { Text = "Average energy used (Joule/s):", Margin = new Thickness(30, 20, 0, 0), TextAlignment = TextAlignment.Center, TextWrapping = TextWrapping.Wrap, FontSize = 20 }; var averageEnergyBlock = new TextBlock { Text = string.Format("{0:N2}", averageEnergyUse), Foreground = Brushes.Red, Margin = new Thickness(30, 45, 0, 0), TextAlignment = TextAlignment.Center, FontSize = 20 }; canvas.Children.Add(headlineBlock); canvas.Children.Add(averageEnergyBlock); }
/// <summary> /// Performs body tracking on frame /// </summary> private void TrackBodies(TimeSpan frameRelativeTime, CameraSpacePoint[] noiseFilteredFrame) { var validatedHeads = DetectHeads(noiseFilteredFrame); _stopwatch.Restart(); GeodesicUtils.CreateGeodesicGraph(noiseFilteredFrame); if (Logger.LogTimeGeodesic) { _stopwatch.Stop(); Console.WriteLine("CreateGeodesicGraph: {0}", _stopwatch.ElapsedMilliseconds); } _stopwatch.Restart(); var bodies = CreateBodies(frameRelativeTime, validatedHeads); BodiesHistory.Update(bodies); GlobVar.TimeStamps.Add(frameRelativeTime); TrackingDiagnostics.AddNewBodyFrame(bodies); _heatMap.AddFrame(GlobVar.HeatCanvas); EnergyHistory.Update(bodies); if (Logger.PrintFps) { var currentTime = frameRelativeTime; Console.WriteLine("FPS: {0}", Logger.CalculateFps(currentTime, _timestampPreviousFrame)); _timestampPreviousFrame = currentTime; } }
public MainWindow() { _kinectSensor = KinectSensor.GetDefault(); _depthFrameDescription = _kinectSensor.DepthFrameSource.FrameDescription; _depthFrameReader = _kinectSensor.DepthFrameSource.OpenReader(); _depthFrameReader.FrameArrived += Reader_FrameArrived; _cameraSpacePoints = new CameraSpacePoint[_depthFrameDescription.Width * _depthFrameDescription.Height]; _trackingDiagnostics = new TrackingDiagnostics(); _heatMap = new HeatMap(); _energyHistory = new EnergyHistory(); _temporalMedianImage = new TemporalMedianImage(GlobVar.TemporalFrameCounter); _stopwatch = new Stopwatch(); BodiesHistory.Initialize(); GlobVar.CoordinateMapper = _kinectSensor.CoordinateMapper; GlobVar.TimeStamps = new List <TimeSpan>(); // initialize the components (controls) of the GUI window InitializeComponent(); _kinectSensor.Open(); }
public MainWindow() { _kinectSensor = KinectSensor.GetDefault(); _depthFrameDescription = _kinectSensor.DepthFrameSource.FrameDescription; _depthFrameReader = _kinectSensor.DepthFrameSource.OpenReader(); _depthFrameReader.FrameArrived += Reader_FrameArrived; _cameraSpacePoints = new CameraSpacePoint[_depthFrameDescription.Width * _depthFrameDescription.Height]; _trackingDiagnostics = new TrackingDiagnostics(); _heatMap = new HeatMap(); _energyHistory = new EnergyHistory(); _temporalMedianImage = new TemporalMedianImage(GlobVar.TemporalFrameCounter); _stopwatch = new Stopwatch(); BodiesHistory.Initialize(); GlobVar.CoordinateMapper = _kinectSensor.CoordinateMapper; GlobVar.TimeStamps = new List<TimeSpan>(); // initialize the components (controls) of the GUI window InitializeComponent(); _kinectSensor.Open(); }