提交 18266eb8 编写于 作者: G gineshidalgo99

Rescaled GUI text at image size

上级 e1409b21
doc/GUI_help/GUI_help.png

81.7 KB | W: | H:

doc/GUI_help/GUI_help.png

81.2 KB | W: | H:

doc/GUI_help/GUI_help.png
doc/GUI_help/GUI_help.png
doc/GUI_help/GUI_help.png
doc/GUI_help/GUI_help.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -191,6 +191,9 @@ OpenPose Library - Release Notes
19. Flag `--camera_resolution` applicable to `--flir_camera`.
20. Throw error message if requested GPU IDs does not exist (e.g. asking for 2 GPUs starting in ID 1 if there is only 2 GPUs in total).
21. VideoSaver (`--write_video`) compatible with multi-camera setting. It will save all the different views concatenated.
22. OpenPose small GUI rescale the verbose text to the displayed image, to avoid the text to be either too big or small.
23. OpenPose small GUI shows the frame number w.r.t. the original producer, rather than the frame id. E.g., if video is started at frame 30, OpenPose will display 30 rather than 0 in the first frame.
23. OpenPose GUI: 'l' and 'k' functionality swapped.
2. Functions or parameters renamed:
1. Flag `no_display` renamed as `display`, able to select between `NoDisplay`, `Display2D`, `Display3D`, and `DisplayAll`.
2. 3-D reconstruction demo is now inside the OpenPose demo binary.
......
......@@ -22,6 +22,13 @@ namespace op
*/
std::string name;
/**
* Corresponding frame number.
* If the producer (e.g., video) starts from frame 0 and does not repeat any frame, then frameNumber should
* match the field id.
*/
unsigned long long frameNumber;
// ------------------------------ Input image and rendered version parameters ------------------------------ //
/**
* Original image to be processed in cv::Mat uchar format.
......
......@@ -13,7 +13,7 @@ namespace op
GuiInfoAdder(const int numberGpus, const bool guiEnabled = false);
void addInfo(cv::Mat& cvOutputData, const int numberPeople, const unsigned long long id,
const std::string& elementRenderedName);
const std::string& elementRenderedName, const unsigned long long frameNumber);
private:
// Const variables
......
......@@ -58,7 +58,7 @@ namespace op
for (auto& tDatum : *tDatums)
spGuiInfoAdder->addInfo(tDatum.cvOutputData, std::max(tDatum.poseKeypoints.getSize(0),
tDatum.faceKeypoints.getSize(0)),
tDatum.id, tDatum.elementRendered.second);
tDatum.id, tDatum.elementRendered.second, tDatum.frameNumber);
// Profiling speed
Profiler::timerEnd(profilerKey);
Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
......
......@@ -97,6 +97,7 @@ namespace op
spVideoSeek->second = 0;
}
auto nextFrameName = spProducer->getNextFrameName();
auto nextFrameNumber = (unsigned long long)spProducer->get(CV_CAP_PROP_POS_FRAMES);
auto cvMats = spProducer->getFrames();
auto cameraMatrices = spProducer->getCameraMatrices();
// Check frames are not empty
......@@ -108,6 +109,7 @@ namespace op
auto& datum = (*datums)[0];
// Filling first element
std::swap(datum.name, nextFrameName);
datum.frameNumber = nextFrameNumber;
datum.cvInputData = cvMats[0];
if (!cameraMatrices.empty())
datum.cameraMatrix = cameraMatrices[0];
......@@ -133,6 +135,7 @@ namespace op
{
auto& datumI = (*datums)[i];
datumI.name = datum.name;
datumI.frameNumber = datum.frameNumber;
datumI.cvInputData = cvMats[i];
datumI.cvOutputData = datumI.cvInputData;
if (cameraMatrices.size() > i)
......
......@@ -7,9 +7,11 @@
namespace op
{
OP_API void putTextOnCvMat(cv::Mat& cvMat, const std::string& textToDisplay, const Point<int>& position, const cv::Scalar& color, const bool normalizeWidth);
OP_API void putTextOnCvMat(cv::Mat& cvMat, const std::string& textToDisplay, const Point<int>& position,
const cv::Scalar& color, const bool normalizeWidth, const int imageWidth);
OP_API void floatPtrToUCharCvMat(cv::Mat& uCharCvMat, const float* const floatPtrImage, const std::array<int, 3> resolutionSize);
OP_API void floatPtrToUCharCvMat(cv::Mat& uCharCvMat, const float* const floatPtrImage,
const std::array<int, 3> resolutionSize);
OP_API void unrollArrayToUCharCvMat(cv::Mat& cvMatResult, const Array<float>& array);
......@@ -17,7 +19,8 @@ namespace op
OP_API double resizeGetScaleFactor(const Point<int>& initialSize, const Point<int>& targetSize);
OP_API cv::Mat resizeFixedAspectRatio(const cv::Mat& cvMat, const double scaleFactor, const Point<int>& targetSize, const int borderMode = cv::BORDER_CONSTANT,
OP_API cv::Mat resizeFixedAspectRatio(const cv::Mat& cvMat, const double scaleFactor, const Point<int>& targetSize,
const int borderMode = cv::BORDER_CONSTANT,
const cv::Scalar& borderValue = cv::Scalar{0,0,0});
}
......
......@@ -73,10 +73,10 @@ namespace op
{
// Normal case, +-30 frames
if (!videoSeekSharedPtr->first)
videoSeekSharedPtr->second += 30 * (castedKey=='l' ? -2 : 1);
videoSeekSharedPtr->second += 30 * (castedKey=='k' ? -2 : 1);
// Frame by frame (if forced paused)
else
videoSeekSharedPtr->second += (castedKey=='l' ? -1 : 1);
videoSeekSharedPtr->second += (castedKey=='k' ? -1 : 1);
}
}
// Enable/disable blending
......
......@@ -59,7 +59,7 @@ namespace op
}
void GuiInfoAdder::addInfo(cv::Mat& cvOutputData, const int numberPeople, const unsigned long long id,
const std::string& elementRenderedName)
const std::string& elementRenderedName, const unsigned long long frameNumber)
{
try
{
......@@ -78,7 +78,7 @@ namespace op
// Recording inverse: sec/gpu
// std::snprintf(charArrayAux, 15, "%4.2f s/gpu", (mFps != 0. ? mNumberGpus/mFps : 0.));
putTextOnCvMat(cvOutputData, charArrayAux, {intRound(cvOutputData.cols - borderMargin), borderMargin},
white, true);
white, true, cvOutputData.cols);
// Part to show
// Allowing some buffer when changing the part to show (if >= 2 GPUs)
// I.e. one GPU might return a previous part after the other GPU returns the new desired part, it looks
......@@ -96,14 +96,14 @@ namespace op
putTextOnCvMat(cvOutputData, "OpenPose - " +
(!mLastElementRenderedName.empty() ?
mLastElementRenderedName : (mGuiEnabled ? "'h' for help" : "")),
{borderMargin, borderMargin}, white, false);
{borderMargin, borderMargin}, white, false, cvOutputData.cols);
// Frame number
putTextOnCvMat(cvOutputData, "Frame: " + std::to_string(id),
{borderMargin, (int)(cvOutputData.rows - borderMargin)}, white, false);
putTextOnCvMat(cvOutputData, "Frame: " + std::to_string(frameNumber),
{borderMargin, (int)(cvOutputData.rows - borderMargin)}, white, false, cvOutputData.cols);
// Number people
putTextOnCvMat(cvOutputData, "People: " + std::to_string(numberPeople),
{(int)(cvOutputData.cols - borderMargin), (int)(cvOutputData.rows - borderMargin)},
white, true);
white, true, cvOutputData.cols);
}
catch (const std::exception& e)
{
......
......@@ -42,7 +42,7 @@ namespace op
{
try
{
return {};
return mCameraParameterReader.getCameraMatrices();
}
catch (const std::exception& e)
{
......
......@@ -4,15 +4,16 @@
namespace op
{
void putTextOnCvMat(cv::Mat& cvMat, const std::string& textToDisplay, const Point<int>& position,
const cv::Scalar& color, const bool normalizeWidth)
const cv::Scalar& color, const bool normalizeWidth, const int imageWidth)
{
try
{
const auto font = cv::FONT_HERSHEY_SIMPLEX;
const auto ratio = imageWidth/1280.;
// const auto fontScale = 0.75;
const auto fontScale = 0.8;
const auto fontThickness = 2;
const auto shadowOffset = 2;
const auto fontScale = 0.8 * std::sqrt(ratio);
const auto fontThickness = std::max(1, intRound(2*ratio));
const auto shadowOffset = std::max(1, intRound(2*ratio));
int baseline = 0;
const auto textSize = cv::getTextSize(textToDisplay, font, fontScale, fontThickness, &baseline);
const cv::Size finalPosition{position.x - (normalizeWidth ? textSize.width : 0),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册