Commit 6c452add authored by Vladimir Dudnik's avatar Vladimir Dudnik

changed output from fps to time (in msec). Notes for dx10 and dx11: the first…

changed output from fps to time (in msec). Notes for dx10 and dx11: the first measure is wrong (zero), the followiing are correct; measured time includes output text to surface.
parent dee05f98
......@@ -199,14 +199,14 @@ public:
cv::blur(m, m, cv::Size(15, 15), cv::Point(-7, -7));
}
cv::String strMode = cv::format("%s", m_modeStr[MODE_CPU].c_str());
cv::String strMode = cv::format("mode: %s", m_modeStr[MODE_CPU].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", m_timer.fps());
cv::String strDevName = cv::format("%s", m_oclDevName.c_str());
cv::String strTime = cv::format("time: %4.1f msec", m_timer.time(Timer::UNITS::MSEC));
cv::String strDevName = cv::format("OpenCL device: %s", m_oclDevName.c_str());
cv::putText(m, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strProcessing, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strFPS, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strTime, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
pSurface->Unmap(subResource);
......@@ -227,14 +227,14 @@ public:
cv::blur(u, u, cv::Size(15, 15), cv::Point(-7, -7));
}
cv::String strMode = cv::format("%s", m_modeStr[MODE_GPU].c_str());
cv::String strMode = cv::format("mode: %s", m_modeStr[MODE_GPU].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", m_timer.fps());
cv::String strDevName = cv::format("%s", m_oclDevName.c_str());
cv::String strTime = cv::format("time: %4.1f msec", m_timer.time(Timer::UNITS::MSEC));
cv::String strDevName = cv::format("OpenCL device: %s", m_oclDevName.c_str());
cv::putText(u, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strProcessing, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strFPS, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strTime, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
cv::directx::convertToD3D10Texture2D(u, pSurface);
......
......@@ -204,14 +204,14 @@ public:
cv::blur(m, m, cv::Size(15, 15), cv::Point(-7, -7));
}
cv::String strMode = cv::format("%s", m_modeStr[MODE_CPU].c_str());
cv::String strMode = cv::format("mode: %s", m_modeStr[MODE_CPU].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", m_timer.fps());
cv::String strDevName = cv::format("%s", m_oclDevName.c_str());
cv::String strTime = cv::format("time: %4.1f msec", m_timer.time(Timer::UNITS::MSEC));
cv::String strDevName = cv::format("OpenCL device: %s", m_oclDevName.c_str());
cv::putText(m, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strProcessing, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strFPS, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strTime, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(m, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
m_pD3D11Ctx->Unmap(pSurface, subResource);
......@@ -232,14 +232,14 @@ public:
cv::blur(u, u, cv::Size(15, 15), cv::Point(-7, -7));
}
cv::String strMode = cv::format("%s", m_modeStr[MODE_GPU].c_str());
cv::String strMode = cv::format("mode: %s", m_modeStr[MODE_GPU].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", m_timer.fps());
cv::String strDevName = cv::format("%s", m_oclDevName.c_str());
cv::String strTime = cv::format("time: %4.1f msec", m_timer.time(Timer::UNITS::MSEC));
cv::String strDevName = cv::format("OpenCL device: %s", m_oclDevName.c_str());
cv::putText(u, strMode, cv::Point(0, 16), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strProcessing, cv::Point(0, 32), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strFPS, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strTime, cv::Point(0, 48), 1, 0.8, cv::Scalar(0, 0, 0));
cv::putText(u, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
cv::directx::convertToD3D11Texture2D(u, pSurface);
......
......@@ -207,7 +207,7 @@ public:
m_timer.stop();
print_info(pSurface, m_mode, m_timer.fps(), m_oclDevName);
print_info(pSurface, m_mode, m_timer.time(Timer::UNITS::MSEC), m_oclDevName);
// traditional DX render pipeline:
// BitBlt surface to backBuffer and flip backBuffer to frontBuffer
......@@ -235,7 +235,7 @@ public:
} // render()
void print_info(LPDIRECT3DSURFACE9 pSurface, int mode, float fps, cv::String oclDevName)
void print_info(LPDIRECT3DSURFACE9 pSurface, int mode, float time, cv::String oclDevName)
{
HDC hDC;
......@@ -258,7 +258,7 @@ public:
int y = 0;
buf[0] = 0;
sprintf(buf, "Mode: %s", m_modeStr[mode].c_str());
sprintf(buf, "mode: %s", m_modeStr[mode].c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
......@@ -268,7 +268,7 @@ public:
y += tm.tmHeight;
buf[0] = 0;
sprintf(buf, "FPS: %2.1f", fps);
sprintf(buf, "time: %4.1f msec", time);
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
......
......@@ -207,7 +207,7 @@ public:
m_timer.stop();
print_info(pSurface, m_mode, m_timer.fps(), m_oclDevName);
print_info(pSurface, m_mode, m_timer.time(Timer::UNITS::MSEC), m_oclDevName);
// traditional DX render pipeline:
// BitBlt surface to backBuffer and flip backBuffer to frontBuffer
......@@ -236,7 +236,7 @@ public:
} // render()
void print_info(LPDIRECT3DSURFACE9 pSurface, int mode, float fps, cv::String oclDevName)
void print_info(LPDIRECT3DSURFACE9 pSurface, int mode, float time, cv::String oclDevName)
{
HDC hDC;
......@@ -259,7 +259,7 @@ public:
int y = 0;
buf[0] = 0;
sprintf(buf, "Mode: %s", m_modeStr[mode].c_str());
sprintf(buf, "mode: %s", m_modeStr[mode].c_str());
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
......@@ -269,7 +269,7 @@ public:
y += tm.tmHeight;
buf[0] = 0;
sprintf(buf, "FPS: %2.1f", fps);
sprintf(buf, "time: %4.1f msec", time);
::TextOut(hDC, 0, y, buf, (int)strlen(buf));
y += tm.tmHeight;
......
......@@ -20,40 +20,44 @@
class Timer
{
public:
Timer() : m_t0(0), m_t1(0)
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 start()
{
m_t0 = cv::getTickCount();
time_queue.push(m_t0);
}
void stop()
{
if (time_queue.size() > 1)
m_t1 = time_queue.front();
if (time_queue.size() >= 25)
time_queue.pop();
m_diff = cv::getTickCount() - m_t0;
}
float fps()
float time(UNITS u = UNITS::MSEC)
{
size_t sz = time_queue.size();
float fps = sz * m_tick_frequency / (m_t0 - m_t1);
float sec = m_diff / m_tick_frequency;
return fps;
return sec * m_unit_mul[u];
}
public:
float m_tick_frequency;
int64 m_t0;
int64 m_t1;
std::queue<int64> time_queue;
int64 m_diff;
int m_unit_mul[3];
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment