All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wPoseExtractor.hpp
Go to the documentation of this file.
#ifndef OPENPOSE_POSE_W_POSE_EXTRACTOR_HPP
#define OPENPOSE_POSE_W_POSE_EXTRACTOR_HPP
#include <openpose/core/common.hpp>
#include <openpose/pose/poseExtractor.hpp>
#include <openpose/thread/worker.hpp>
namespace op
{
template<typename TDatums>
class WPoseExtractor : public Worker<TDatums>
{
public:
explicit WPoseExtractor(const std::shared_ptr<PoseExtractor>& poseExtractorSharedPtr);
virtual ~WPoseExtractor();
void initializationOnThread();
void work(TDatums& tDatums);
private:
std::shared_ptr<PoseExtractor> spPoseExtractor;
DELETE_COPY(WPoseExtractor);
};
}
// Implementation
#include <openpose/utilities/pointerContainer.hpp>
namespace op
{
template<typename TDatums>
WPoseExtractor<TDatums>::WPoseExtractor(const std::shared_ptr<PoseExtractor>& poseExtractorSharedPtr) :
spPoseExtractor{poseExtractorSharedPtr}
{
}
template<typename TDatums>
WPoseExtractor<TDatums>::~WPoseExtractor()
{
}
template<typename TDatums>
void WPoseExtractor<TDatums>::initializationOnThread()
{
try
{
spPoseExtractor->initializationOnThread();
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
template<typename TDatums>
void WPoseExtractor<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 i = 0u ; i < tDatums->size() ; i++)
// for (auto& tDatum : *tDatums)
{
auto& tDatum = (*tDatums)[i];
// OpenPose net forward pass
spPoseExtractor->forwardPass(tDatum.inputNetData,
Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows},
tDatum.scaleInputToNetInputs, tDatum.id);
// OpenPose keypoint detector
tDatum.poseCandidates = spPoseExtractor->getCandidatesCopy();
tDatum.poseHeatMaps = spPoseExtractor->getHeatMapsCopy();
tDatum.poseKeypoints = spPoseExtractor->getPoseKeypoints().clone();
tDatum.poseScores = spPoseExtractor->getPoseScores().clone();
tDatum.scaleNetToOutput = spPoseExtractor->getScaleNetToOutput();
// Keep desired top N people
spPoseExtractor->keepTopPeople(tDatum.poseKeypoints, tDatum.poseScores);
// ID extractor (experimental)
tDatum.poseIds = spPoseExtractor->extractIdsLockThread(tDatum.poseKeypoints, tDatum.cvInputData,
i, tDatum.id);
// Tracking (experimental)
spPoseExtractor->trackLockThread(tDatum.poseKeypoints, tDatum.poseIds, tDatum.cvInputData, i,
tDatum.id);
}
// 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(WPoseExtractor);
}
#endif // OPENPOSE_POSE_W_POSE_EXTRACTOR_HPP
op::Priority::Low
op::WPoseExtractor::WPoseExtractor
WPoseExtractor(const std::shared_ptr< PoseExtractor > &poseExtractorSharedPtr)
Definition: wPoseExtractor.hpp:38
op::Worker
Definition: worker.hpp:9
COMPILE_TEMPLATE_DATUM
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:390
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::WPoseExtractor::~WPoseExtractor
virtual ~WPoseExtractor()
Definition: wPoseExtractor.hpp:44
pointerContainer.hpp
op::WPoseExtractor::initializationOnThread
void initializationOnThread()
Definition: wPoseExtractor.hpp:49
op::WPoseExtractor
Definition: wPoseExtractor.hpp:11
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::WPoseExtractor::work
void work(TDatums &tDatums)
Definition: wPoseExtractor.hpp:62
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)
poseExtractor.hpp