예제 #1
0
        /// <summary>
        /// Steps to perform each detection started
        /// 1. Count frame
        /// 2. Start detection stopwatch
        /// If not same second as in previous frame then update statistics and start from the beginning
        /// </summary>
        public void Begin()
        {
            DateTime now = _dateTime.Now;

            if (_currenWorkingSecond.Second != now.Second)
            {
                DetectionRate        = (_totalFramesPerSecond < 1) ? 100 : 100 * _successDetectionFrame / _totalFramesPerSecond;
                AverageDetectionTime = (_totalFramesPerSecond < 1) ? 0 : _spentOnDetectionInSecond.Milliseconds / _totalFramesPerSecond;
                DetectedFPS          = _successDetectionFrame;
                TotalFPS             = _totalFramesPerSecond;

                Statistics.TryUpdateBasicImageProcessingInfo(String.Format("Detection: Rate {0}% ({1}/{2}) Average T {3}(ms)",
                                                                           DetectionRate, DetectedFPS, TotalFPS, AverageDetectionTime));

                _totalFramesPerSecond     = 0;
                _successDetectionFrame    = 0;
                _spentOnDetectionInSecond = TimeSpan.FromMilliseconds(0);
                _currenWorkingSecond      = now;
            }
            _totalFramesPerSecond++;
            _dateTime.Start();
        }