All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wKeypointScaler.hpp
Go to the documentation of this file.
#ifndef OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
#define OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
#include <openpose/core/common.hpp>
#include <openpose/core/keypointScaler.hpp>
#include <openpose/thread/worker.hpp>
namespace op
{
template<typename TDatums>
class WKeypointScaler : public Worker<TDatums>
{
public:
explicit WKeypointScaler(const std::shared_ptr<KeypointScaler>& keypointScaler);
virtual ~WKeypointScaler();
void initializationOnThread();
void work(TDatums& tDatums);
private:
std::shared_ptr<KeypointScaler> spKeypointScaler;
};
}
// Implementation
#include <openpose/utilities/pointerContainer.hpp>
namespace op
{
template<typename TDatums>
WKeypointScaler<TDatums>::WKeypointScaler(const std::shared_ptr<KeypointScaler>& keypointScaler) :
spKeypointScaler{keypointScaler}
{
}
template<typename TDatums>
WKeypointScaler<TDatums>::~WKeypointScaler()
{
}
template<typename TDatums>
void WKeypointScaler<TDatums>::initializationOnThread()
{
}
template<typename TDatums>
void WKeypointScaler<TDatums>::work(TDatums& tDatums)
{
try
{
if (checkNoNullNorEmpty(tDatums))
{
// Debugging log
dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
// Profiling speed
const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
// Rescale pose data
for (auto& tDatum : *tDatums)
{
std::vector<Array<float>> arraysToScale{tDatum.poseKeypoints, tDatum.handKeypoints[0],
tDatum.handKeypoints[1], tDatum.faceKeypoints};
spKeypointScaler->scale(arraysToScale, tDatum.scaleInputToOutput, tDatum.scaleNetToOutput,
Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows});
// Rescale part candidates
spKeypointScaler->scale(tDatum.poseCandidates, tDatum.scaleInputToOutput, tDatum.scaleNetToOutput,
Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows});
}
// Profiling speed
Profiler::timerEnd(profilerKey);
Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
// Debugging log
dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
}
}
catch (const std::exception& e)
{
this->stop();
tDatums = nullptr;
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
COMPILE_TEMPLATE_DATUM(WKeypointScaler);
}
#endif // OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
op::Priority::Low
keypointScaler.hpp
op::WKeypointScaler::~WKeypointScaler
virtual ~WKeypointScaler()
Definition: wKeypointScaler.hpp:42
op::Worker
Definition: worker.hpp:9
COMPILE_TEMPLATE_DATUM
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:390
op::WKeypointScaler
Definition: wKeypointScaler.hpp:11
op::Point< int >
common.hpp
op::Profiler::timerInit
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
op::error
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
pointerContainer.hpp
op::WKeypointScaler::WKeypointScaler
WKeypointScaler(const std::shared_ptr< KeypointScaler > &keypointScaler)
Definition: wKeypointScaler.hpp:36
op::dLog
void dLog(const T &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
Definition: errorAndLog.hpp:53
worker.hpp
op::WKeypointScaler::work
void work(TDatums &tDatums)
Definition: wKeypointScaler.hpp:52
op::checkNoNullNorEmpty
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
Definition: pointerContainer.hpp:7
op::Profiler::printAveragedTimeMsOnIterationX
static void printAveragedTimeMsOnIterationX(const std::string &key, const int line, const std::string &function, const std::string &file, const unsigned long long x=DEFAULT_X)
op::Profiler::timerEnd
static void timerEnd(const std::string &key)
op::WKeypointScaler::initializationOnThread
void initializationOnThread()
Definition: wKeypointScaler.hpp:47