/// <summary> /// Helper function to draw constructed background frame. /// </summary> public void Draw(MainWindow mainWindow) { if (_frameCounter != _maxTemporalFrames) { return; } GraphicsUtils.RenderDepthPixels(mainWindow, TemporalImage); }
/// <summary> /// Handles the depth frame data arriving from the sensor /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void Reader_FrameArrived(object sender, DepthFrameArrivedEventArgs e) { var stopwatchTotalTime = new Stopwatch(); stopwatchTotalTime.Restart(); ushort[] frameData = new ushort[_depthFrameDescription.Width * _depthFrameDescription.Height]; using (DepthFrame depthFrame = e.FrameReference.AcquireFrame()) { if (depthFrame != null) { _depthFrameReader.IsPaused = true; depthFrame.CopyFrameDataToArray(frameData); GlobVar.CoordinateMapper.MapDepthFrameToCameraSpace(frameData, _cameraSpacePoints); var preProcessedFrame = PreProcessFrame(_cameraSpacePoints); //preProcessedFrame = ImageUtils.DepthFilter(preProcessedFrame); if (_temporalMedianImage.ImageSet) { var subtractedFrame = _temporalMedianImage.Subtract(preProcessedFrame); _stopwatch.Restart(); var noiseFilteredFrame = ImageUtils.MedianFilter3X3(subtractedFrame, 2); if (Logger.LogTimeMedian) { _stopwatch.Stop(); Console.WriteLine("Median: {0}", _stopwatch.ElapsedMilliseconds); } _stopwatch.Restart(); GlobVar.SubtractedFilteredPointCloud = noiseFilteredFrame; TrackBodies(depthFrame.RelativeTime, noiseFilteredFrame); GraphicsUtils.RenderDepthPixels(this, noiseFilteredFrame); //_temporalMedianImage.Draw(this); } _depthFrameReader.IsPaused = false; } } if (Logger.LogTimeTotal) { stopwatchTotalTime.Stop(); Console.WriteLine("TotalTime: {0}", stopwatchTotalTime.ElapsedMilliseconds); } }