change displaying of fps to time (ms)

This commit is contained in:
Alexey Ershov
2015-07-30 19:57:11 +03:00
parent 0a4830b3d5
commit ea10290153
2 changed files with 114 additions and 68 deletions

View File

@@ -22,6 +22,54 @@
#define SAFE_RELEASE(p) if (p) { p->Release(); p = NULL; }
class Timer
{
public:
enum UNITS
{
USEC = 0,
MSEC,
SEC
};
Timer() : m_t0(0), m_diff(0)
{
m_tick_frequency = (float)cv::getTickFrequency();
m_unit_mul[USEC] = 1000000;
m_unit_mul[MSEC] = 1000;
m_unit_mul[SEC] = 1;
}
void clear()
{
m_t0 = m_diff = 0;
}
void start()
{
m_t0 = cv::getTickCount();
}
void stop()
{
m_diff = cv::getTickCount() - m_t0;
}
float time(UNITS u = UNITS::MSEC)
{
float sec = m_diff / m_tick_frequency;
return sec * m_unit_mul[u];
}
public:
float m_tick_frequency;
int64 m_t0;
int64 m_diff;
int m_unit_mul[3];
};
class WinApp
{
public:
@@ -218,4 +266,5 @@ protected:
int m_width;
int m_height;
std::string m_window_name;
Timer m_timer;
};