1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

compute fps changed (now only interop counts). fixed d3d10 and d3d11 print info method (there were issues with texture mapping)

This commit is contained in:
Vladimir Dudnik
2015-07-13 23:40:45 +03:00
parent 38723b0339
commit dee05f982b
6 changed files with 121 additions and 102 deletions
+25 -34
View File
@@ -175,6 +175,8 @@ public:
return -1;
}
m_timer.start();
switch (m_mode)
{
case MODE_CPU:
@@ -183,7 +185,7 @@ public:
UINT subResource = ::D3D10CalcSubresource(0, 0, 1);
D3D10_MAPPED_TEXTURE2D mappedTex;
r = m_pSurface->Map(subResource, D3D10_MAP_WRITE_DISCARD, 0, &mappedTex);
r = pSurface->Map(subResource, D3D10_MAP_WRITE_DISCARD, 0, &mappedTex);
if (FAILED(r))
{
return r;
@@ -197,7 +199,17 @@ public:
cv::blur(m, m, cv::Size(15, 15), cv::Point(-7, -7));
}
m_pSurface->Unmap(subResource);
cv::String strMode = cv::format("%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::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, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
pSurface->Unmap(subResource);
break;
}
@@ -215,6 +227,16 @@ 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 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::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, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
cv::directx::convertToD3D10Texture2D(u, pSurface);
break;
@@ -222,7 +244,7 @@ public:
} // switch
print_info(pSurface, m_mode, getFps(), m_oclDevName);
m_timer.stop();
// traditional DX render pipeline:
// BitBlt surface to backBuffer and flip backBuffer to frontBuffer
@@ -247,37 +269,6 @@ public:
} // render()
void print_info(ID3D10Texture2D* pSurface, int mode, float fps, cv::String oclDevName)
{
HRESULT r;
UINT subResource = ::D3D10CalcSubresource(0, 0, 1);
D3D10_MAPPED_TEXTURE2D mappedTex;
r = pSurface->Map(subResource, D3D10_MAP_WRITE_DISCARD, 0, &mappedTex);
if (FAILED(r))
{
return;
}
cv::Mat m(m_height, m_width, CV_8UC4, mappedTex.pData, (int)mappedTex.RowPitch);
cv::String strMode = cv::format("%s", m_modeStr[mode].c_str());
cv::String strProcessing = m_demo_processing ? "blur frame" : "copy frame";
cv::String strFPS = cv::format("%2.1f", fps);
cv::String strDevName = cv::format("%s", 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, strDevName, cv::Point(0, 64), 1, 0.8, cv::Scalar(0, 0, 0));
m_pSurface->Unmap(subResource);
return;
} // print_info()
int cleanup(void)
{
SAFE_RELEASE(m_pSurface);