diff --git a/src/MMALSharp.Processing/Processors/Motion/FrameDiffDriver.cs b/src/MMALSharp.Processing/Processors/Motion/FrameDiffDriver.cs index 5ebe5486..6ad5fd10 100644 --- a/src/MMALSharp.Processing/Processors/Motion/FrameDiffDriver.cs +++ b/src/MMALSharp.Processing/Processors/Motion/FrameDiffDriver.cs @@ -83,48 +83,47 @@ public override void Apply(ImageContext context) { base.Apply(context); - if (context.Eos) + if (context.Eos == false) { - // if zero bytes buffered, EOS is the end of a physical input video filestream - if (this.WorkingData.Count > 0) - { - if (!_fullTestFrame) - { - MMALLog.Logger.LogDebug("EOS reached for test frame."); + return; + } - this.PrepareTestFrame(); - _fullTestFrame = true; - } - else - { - MMALLog.Logger.LogDebug("Have full frame, invoking motion algorithm."); + // if zero bytes buffered, EOS is the end of a physical input video filestream + if (this.WorkingData.Count == 0) + { + MMALLog.Logger.LogDebug("EOS reached, no working data buffered"); + return; + } - // frameCounter++; - // frameTimer.Restart(); + if (!_fullTestFrame) + { + MMALLog.Logger.LogDebug("EOS reached for test frame."); - var detected = _motionConfig.MotionAlgorithm.DetectMotion(this, Metadata); + this.PrepareTestFrame(); + _fullTestFrame = true; + return; + } - // frameTimer.Stop(); - // totalElapsed += frameTimer.ElapsedMilliseconds; + MMALLog.Logger.LogDebug("Have full frame, invoking motion algorithm."); - if (detected) - { - this.LastDetectionEvent.Restart(); + // frameCounter++; + // frameTimer.Restart(); - if(this.OnDetectEnabled) - { - _onDetect?.Invoke(); - } - } + var detected = _motionConfig.MotionAlgorithm.DetectMotion(this, Metadata); - this.TryUpdateTestFrame(); - } - } - else + // frameTimer.Stop(); + // totalElapsed += frameTimer.ElapsedMilliseconds; + + if (detected) + { + this.LastDetectionEvent.Restart(); + if (this.OnDetectEnabled) { - MMALLog.Logger.LogDebug("EOS reached, no working data buffered"); + _onDetect?.Invoke(); } } + + this.TryUpdateTestFrame(); } ///