Beispiel #1
0
        private void Recorder_FrameReady(object sender, Mat e)
        {
            if (frame != null)
            {
                frame.Dispose();
                frame = null;
            }

            Profiler.Count("fps");

            if (e != null && !e.IsEmpty)
            {
                frame = e.Clone();
                FaceRect[] rect = detector.Detect(frame);
                foreach (FaceRect r in rect)
                {
                    r.Draw(frame, 2, true, true);
                }
                frame.DrawText(0, 50, $"fps:{Profiler.Get("fps").ToString().PadRight(2)} wpfFPS:{Profiler.Get("wpfFPS").ToString().PadRight(2)} recorded:{((recorder == null) ? 0 : recorder.CaptureCount)}");
                if (recorder.IsPaused)
                {
                    frame.DrawText(-offset, 50, "PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED-PAUSED", Vision.Scalar.BgrBlue);
                    offset += 2;
                    offset  = offset % (26 * 7);
                }

                Dispatcher.Invoke(() =>
                {
                    var source = frame.ToBitmapSource();
                    Background = new ImageBrush(source)
                    {
                        Stretch = System.Windows.Media.Stretch.Uniform
                    };
                    Background.Freeze();
                });
            }
        }
Beispiel #2
0
 private void CompositionTarget_Rendering(object sender, EventArgs e)
 {
     Profiler.Count("wpfFPS");
 }