All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wPoseExtractorNet.hpp
Go to the documentation of this file.
#ifndef OPENPOSE_POSE_W_POSE_EXTRACTOR_NET_HPP
#define OPENPOSE_POSE_W_POSE_EXTRACTOR_NET_HPP
#include <openpose/core/common.hpp>
#include <openpose/pose/poseExtractorNet.hpp>
#include <openpose/thread/worker.hpp>
namespace op
{
template<typename TDatums>
class WPoseExtractorNet : public Worker<TDatums>
{
public:
explicit WPoseExtractorNet(const std::shared_ptr<PoseExtractorNet>& poseExtractorSharedPtr);
virtual ~WPoseExtractorNet();
void initializationOnThread();
void work(TDatums& tDatums);
private:
std::shared_ptr<PoseExtractorNet> spPoseExtractorNet;
DELETE_COPY(WPoseExtractorNet);
};
}
// Implementation
#include <openpose/utilities/pointerContainer.hpp>
namespace op
{
template<typename TDatums>
WPoseExtractorNet<TDatums>::WPoseExtractorNet(const std::shared_ptr<PoseExtractorNet>& poseExtractorSharedPtr) :
spPoseExtractorNet{poseExtractorSharedPtr}
{
}
template<typename TDatums>
WPoseExtractorNet<TDatums>::~WPoseExtractorNet()
{
}
template<typename TDatums>
void WPoseExtractorNet<TDatums>::initializationOnThread()
{
try
{
spPoseExtractorNet->initializationOnThread();
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
template<typename TDatums>
void WPoseExtractorNet<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__);
// Extract people pose
for (auto& tDatum : *tDatums)
{
spPoseExtractorNet->forwardPass(tDatum.inputNetData,
Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows},
tDatum.scaleInputToNetInputs);
tDatum.poseCandidates = spPoseExtractorNet->getCandidatesCopy();
tDatum.poseHeatMaps = spPoseExtractorNet->getHeatMapsCopy();
tDatum.poseKeypoints = spPoseExtractorNet->getPoseKeypoints().clone();
tDatum.poseScores = spPoseExtractorNet->getPoseScores().clone();
tDatum.scaleNetToOutput = spPoseExtractorNet->getScaleNetToOutput();
}
// 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(WPoseExtractorNet);
}
#endif // OPENPOSE_POSE_W_POSE_EXTRACTOR_NET_HPP
op::Priority::Low
op::WPoseExtractorNet::initializationOnThread
void initializationOnThread()
Definition: wPoseExtractorNet.hpp:49
op::Worker
Definition: worker.hpp:9
COMPILE_TEMPLATE_DATUM
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:390
poseExtractorNet.hpp
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="")
op::WPoseExtractorNet::WPoseExtractorNet
WPoseExtractorNet(const std::shared_ptr< PoseExtractorNet > &poseExtractorSharedPtr)
Definition: wPoseExtractorNet.hpp:38
pointerContainer.hpp
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::WPoseExtractorNet::~WPoseExtractorNet
virtual ~WPoseExtractorNet()
Definition: wPoseExtractorNet.hpp:44
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::WPoseExtractorNet::work
void work(TDatums &tDatums)
Definition: wPoseExtractorNet.hpp:62
op::WPoseExtractorNet
Definition: wPoseExtractorNet.hpp:11