提交 fd35bd9e 编写于 作者: G gineshidalgo99

GUI info adder working multi-frame

上级 b47c780f
...@@ -26,6 +26,7 @@ namespace op ...@@ -26,6 +26,7 @@ namespace op
unsigned int mFpsCounter; unsigned int mFpsCounter;
std::string mLastElementRenderedName; std::string mLastElementRenderedName;
int mLastElementRenderedCounter; int mLastElementRenderedCounter;
unsigned long long mLastId;
}; };
} }
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
namespace op namespace op
{ {
void getFps(double& fps, unsigned int& fpsCounter, std::queue<std::chrono::high_resolution_clock::time_point>& fpsQueue, const int numberGpus) void updateFps(unsigned long long& lastId, double& fps, unsigned int& fpsCounter, std::queue<std::chrono::high_resolution_clock::time_point>& fpsQueue,
const unsigned long long id, const int numberGpus)
{ {
try try
{ {
...@@ -17,21 +18,25 @@ namespace op ...@@ -17,21 +18,25 @@ namespace op
// However, we update every frame during the first few frames to have an initial estimator. // However, we update every frame during the first few frames to have an initial estimator.
// In any of the previous cases, the fps value is estimated during the last several frames. // In any of the previous cases, the fps value is estimated during the last several frames.
// In this way, a sudden fps drop will be quickly visually identified. // In this way, a sudden fps drop will be quickly visually identified.
fpsQueue.emplace(std::chrono::high_resolution_clock::now()); if (lastId != id)
bool updatePrintedFps = true;
if (fpsQueue.size() > 5)
{ {
const auto factor = (numberGpus > 1 ? 25u : 15u); lastId = id;
updatePrintedFps = (fpsCounter % factor == 0); fpsQueue.emplace(std::chrono::high_resolution_clock::now());
// updatePrintedFps = (numberGpus == 1 ? true : fpsCounter % (3*numberGpus) == 0); bool updatePrintedFps = true;
fpsCounter++; if (fpsQueue.size() > 5)
if (fpsQueue.size() > factor) {
fpsQueue.pop(); const auto factor = (numberGpus > 1 ? 25u : 15u);
} updatePrintedFps = (fpsCounter % factor == 0);
if (updatePrintedFps) // updatePrintedFps = (numberGpus == 1 ? true : fpsCounter % (3*numberGpus) == 0);
{ fpsCounter++;
const auto timeSec = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(fpsQueue.back()-fpsQueue.front()).count() * 1e-9; if (fpsQueue.size() > factor)
fps = (fpsQueue.size()-1) / (timeSec != 0. ? timeSec : 1.); fpsQueue.pop();
}
if (updatePrintedFps)
{
const auto timeSec = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(fpsQueue.back()-fpsQueue.front()).count() * 1e-9;
fps = (fpsQueue.size()-1) / (timeSec != 0. ? timeSec : 1.);
}
} }
} }
catch (const std::exception& e) catch (const std::exception& e)
...@@ -46,7 +51,8 @@ namespace op ...@@ -46,7 +51,8 @@ namespace op
mNumberGpus{numberGpus}, mNumberGpus{numberGpus},
mGuiEnabled{guiEnabled}, mGuiEnabled{guiEnabled},
mFpsCounter{0u}, mFpsCounter{0u},
mLastElementRenderedCounter{std::numeric_limits<int>::max()} mLastElementRenderedCounter{std::numeric_limits<int>::max()},
mLastId{-1u}
{ {
} }
...@@ -57,10 +63,12 @@ namespace op ...@@ -57,10 +63,12 @@ namespace op
// Security checks // Security checks
if (cvOutputData.empty()) if (cvOutputData.empty())
error("Wrong input element (empty cvOutputData).", __LINE__, __FUNCTION__, __FILE__); error("Wrong input element (empty cvOutputData).", __LINE__, __FUNCTION__, __FILE__);
// Used colors
const cv::Scalar white{255,255,255};
// Update fps // Update fps
getFps(mFps, mFpsCounter, mFpsQueue, mNumberGpus); updateFps(mLastId, mFps, mFpsCounter, mFpsQueue, id, mNumberGpus);
// Used colors
const cv::Scalar white{255, 255, 255};
// Fps or s/gpu // Fps or s/gpu
char charArrayAux[15]; char charArrayAux[15];
std::snprintf(charArrayAux, 15, "%4.1f fps", mFps); std::snprintf(charArrayAux, 15, "%4.1f fps", mFps);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册