public void update(KinectData data) { /* DateTime ExecutionStartTime; DateTime ExecutionStopTime; TimeSpan ExecutionTime; ExecutionStartTime = DateTime.Now; */ // Is data_ going to be nullifies? (Michael) if (data_ == null) { this.data_ = data; this.depth_ = data.depth(); this.rgb_ = data.color(); PackageState(); } DateTime ExecutionStartTime_new; DateTime ExecutionStopTime_new; TimeSpan ExecutionTime_new; ExecutionStartTime_new = DateTime.Now; #region Color Image DateTime ExecutionStartTime; DateTime ExecutionStopTime; TimeSpan ExecutionTime; ExecutionStartTime = DateTime.Now; process(Filter.Step.CopyColor); // pontentially dangerous due to creating a new thread here. This is because bitmap_bits will be used later color_bitmap_.Dispatcher.Invoke(new Action(() => // color_bitmap_.Dispatcher.BeginInvoke(new Action(() => { color_bitmap_.WritePixels(new Int32Rect(0, 0, color_bitmap_.PixelWidth, color_bitmap_.PixelHeight), bitmap_bits_, color_bitmap_.PixelWidth * sizeof(int), 0); })); ExecutionStopTime = DateTime.Now; ExecutionTime = ExecutionStopTime - ExecutionStartTime; SetContent.SetColorImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds))); #endregion #region Depth Image ExecutionStartTime = DateTime.Now; process(Filter.Step.CopyDepth); process(Filter.Step.CheckpointCurrentBitmap); process(Filter.Step.EnablePredict); process(Filter.Step.PerPixelClassificationOnEnable); process(Filter.Step.ShowOverlay); depth_bitmap_.Dispatcher.Invoke(new Action(() => // depth_bitmap_.Dispatcher.BeginInvoke(new Action(() => { depth_bitmap_.WritePixels(new Int32Rect(0, 0, depth_bitmap_.PixelWidth, depth_bitmap_.PixelHeight), bitmap_bits_, depth_bitmap_.PixelWidth * sizeof(int), 0); })); ExecutionStopTime = DateTime.Now; ExecutionTime = ExecutionStopTime - ExecutionStartTime; SetContent.SetDepthImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds) )); #endregion #region Pool Image ExecutionStartTime = DateTime.Now; process(Filter.Step.RestoreBitmap); process(Filter.Step.PoolingOnPerPixelClassification); process(Filter.Step.ShowOverlay); pool_bitmap_.Dispatcher.Invoke(new Action(() => //pool_bitmap_.Dispatcher.BeginInvoke(new Action(() => { pool_bitmap_.WritePixels(new Int32Rect(0, 0, pool_bitmap_.PixelWidth, pool_bitmap_.PixelHeight), bitmap_bits_, pool_bitmap_.PixelWidth * sizeof(int), 0); })); ExecutionStopTime = DateTime.Now; ExecutionTime = ExecutionStopTime - ExecutionStartTime; SetContent.SetPoolImageLabel(String.Format("Use {0} ms", Math.Round(ExecutionTime.TotalMilliseconds) )); #endregion ExecutionStopTime_new = DateTime.Now; ExecutionTime_new = ExecutionStopTime_new - ExecutionStartTime_new; Console.WriteLine("Use {0} ms for processing steps", ExecutionTime_new.TotalMilliseconds.ToString()); SetContent.SetMetaInformation(String.Format("Use {0} ms for everything", Math.Round(ExecutionTime_new.TotalMilliseconds) )); /* lock (bitmap_lock_) { if (paused) return; foreach (Filter.Step step in pipeline) process(step); } ExecutionStopTime_new = DateTime.Now; ExecutionTime_new = ExecutionStopTime_new - ExecutionStartTime_new; Console.WriteLine("Use {0} ms for processing steps", ExecutionTime_new.TotalMilliseconds.ToString()); bitmap_.Dispatcher.Invoke(new Action(() => { bitmap_.WritePixels(new Int32Rect(0, 0, bitmap_.PixelWidth, bitmap_.PixelHeight), bitmap_bits_, bitmap_.PixelWidth * sizeof(int), 0); })); */ /* ExecutionStopTime = DateTime.Now; ExecutionTime = ExecutionStopTime - ExecutionStartTime; Console.WriteLine("Use {0} ms for per frame update", ExecutionTime.TotalMilliseconds.ToString()); */ }
public void update(KinectData data) { // Is data_ going to be nullifies? (Michael) if (data_ == null) { this.data_ = data; this.depth_ = data.depth(); this.rgb_ = data.color(); PackageState(); } lock (bitmap_lock_) { if (paused) return; foreach (Filter.Step step in pipeline) process(step); } bitmap_.Dispatcher.Invoke(new Action(() => { bitmap_.WritePixels(new Int32Rect(0, 0, bitmap_.PixelWidth, bitmap_.PixelHeight), bitmap_bits_, bitmap_.PixelWidth * sizeof(int), 0); })); }