Exemple #1
0
        private bool ApplyMotionDetector(UnmanagedImage lfu)
        {
            if (Detect != null && lfu != null)
            {
                if ((DateTime.UtcNow - _lastProcessed).TotalMilliseconds > CW.Camobject.detector.processframeinterval || CW.Calibrating)
                {
                    _lastProcessed = DateTime.UtcNow;

                    try
                    {
                        MotionLevel = _motionDetector.ProcessFrame(Filter != null ? Filter.Apply(lfu) : lfu);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Error processing motion: " + ex.Message);
                    }

                    MotionLevel = MotionLevel * CW.Camobject.detector.gain;

                    if (MotionLevel >= _alarmLevel)
                    {
                        if (Math.Min(MotionLevel, 0.99) <= _alarmLevelMax)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        MotionDetected = false;
                    }
                }
                else
                {
                    _motionDetector.ApplyOverlay(lfu);
                }
            }
            else
            {
                MotionDetected = false;
            }
            return(false);
        }