FrameRateCounter.cpp 693 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * NICE-Core - efficient algebra and computer vision methods
  3. * - libfbasics - library of some basic tools
  4. * See file License for license information.
  5. */
  6. #include "core/basics/FrameRateCounter.h"
  7. namespace NICE {
  8. FrameRateCounter::FrameRateCounter(unsigned int lookBack)
  9. : m_lookBack(lookBack), m_counter(0), m_frameRate(0.0) {
  10. reset();
  11. }
  12. FrameRateCounter::~FrameRateCounter() {
  13. }
  14. void FrameRateCounter::newFrame() {
  15. m_counter++;
  16. if (m_counter == m_lookBack) {
  17. m_timer.stop();
  18. m_timer.start();
  19. m_frameRate = double(m_lookBack) / double(m_timer.getLastAbsolute());
  20. m_counter = 0;
  21. }
  22. }
  23. void FrameRateCounter::reset() {
  24. m_timer.start();
  25. }
  26. } // namespace