提交 fd35bd9e 编写于 作者: G gineshidalgo99

GUI info adder working multi-frame

上级 b47c780f
......@@ -26,6 +26,7 @@ namespace op
unsigned int mFpsCounter;
std::string mLastElementRenderedName;
int mLastElementRenderedCounter;
unsigned long long mLastId;
};
}
......
......@@ -7,7 +7,8 @@
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
{
......@@ -17,6 +18,9 @@ namespace op
// 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 this way, a sudden fps drop will be quickly visually identified.
if (lastId != id)
{
lastId = id;
fpsQueue.emplace(std::chrono::high_resolution_clock::now());
bool updatePrintedFps = true;
if (fpsQueue.size() > 5)
......@@ -34,6 +38,7 @@ namespace op
fps = (fpsQueue.size()-1) / (timeSec != 0. ? timeSec : 1.);
}
}
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
......@@ -46,7 +51,8 @@ namespace op
mNumberGpus{numberGpus},
mGuiEnabled{guiEnabled},
mFpsCounter{0u},
mLastElementRenderedCounter{std::numeric_limits<int>::max()}
mLastElementRenderedCounter{std::numeric_limits<int>::max()},
mLastId{-1u}
{
}
......@@ -57,10 +63,12 @@ namespace op
// Security checks
if (cvOutputData.empty())
error("Wrong input element (empty cvOutputData).", __LINE__, __FUNCTION__, __FILE__);
// Used colors
const cv::Scalar white{255,255,255};
// 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
char charArrayAux[15];
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.
先完成此消息的编辑!
想要评论请 注册