FrameRateCounter.h 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef _FRAMERATECOUNTER_H_
  7. #define _FRAMERATECOUNTER_H_
  8. #include <string>
  9. #include <core/basics/Timer.h>
  10. namespace NICE {
  11. /**
  12. * Frame rate counter: compute frames per second.
  13. */
  14. class FrameRateCounter {
  15. public:
  16. /**
  17. *
  18. */
  19. FrameRateCounter(unsigned int lookBack = 30);
  20. ~FrameRateCounter();
  21. /**
  22. * Reset measurements.
  23. */
  24. void reset();
  25. /**
  26. * A new frame.
  27. */
  28. void newFrame();
  29. /**
  30. * Frame rate in seconds (FPS).
  31. */
  32. inline double getFrameRate() const {
  33. return m_frameRate;
  34. }
  35. /**
  36. * The number of calls to \c newFrame().
  37. */
  38. inline int getCounter() const {
  39. return m_counter;
  40. }
  41. private:
  42. Timer m_timer;
  43. unsigned int m_lookBack;
  44. unsigned int m_counter;
  45. double m_frameRate;
  46. };
  47. } // namespace
  48. #endif // _FRAMERATECOUNTER_H_