OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
wKeepTopNPeople.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_CORE_W_KEEP_TOP_N_PEOPLE_HPP
2 #define OPENPOSE_CORE_W_KEEP_TOP_N_PEOPLE_HPP
3
4 #include <openpose/core/common.hpp>
5 #include <openpose/core/keepTopNPeople.hpp>
6 #include <openpose/thread/worker.hpp>
7
8 namespace op
9 {
10 template<typename TDatums>
11 class WKeepTopNPeople : public Worker<TDatums>
12 {
13 public:
14 explicit WKeepTopNPeople(const std::shared_ptr<KeepTopNPeople>& keepTopNPeople);
15
16 virtual ~WKeepTopNPeople();
17
18 void initializationOnThread();
19
20 void work(TDatums& tDatums);
21
22 private:
23 std::shared_ptr<KeepTopNPeople> spKeepTopNPeople;
24 };
25 }
26
27
28
29
30
31 // Implementation
32 #include <openpose/utilities/pointerContainer.hpp>
33 namespace op
34 {
35 template<typename TDatums>
36 WKeepTopNPeople<TDatums>::WKeepTopNPeople(const std::shared_ptr<KeepTopNPeople>& keepTopNPeople) :
37 spKeepTopNPeople{keepTopNPeople}
38 {
39 }
40
41 template<typename TDatums>
42 WKeepTopNPeople<TDatums>::~WKeepTopNPeople()
43 {
44 }
45
46 template<typename TDatums>
47 void WKeepTopNPeople<TDatums>::initializationOnThread()
48 {
49 }
50
51 template<typename TDatums>
52 void WKeepTopNPeople<TDatums>::work(TDatums& tDatums)
53 {
54 try
55 {
56 if (checkNoNullNorEmpty(tDatums))
57 {
58 // Debugging log
59 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
60 // Profiling speed
61 const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
62 // Rescale pose data
63 for (auto& tDatum : *tDatums)
64 {
65 tDatum.poseKeypoints = spKeepTopNPeople->keepTopPeople(tDatum.poseKeypoints, tDatum.poseScores);
66 tDatum.faceKeypoints = spKeepTopNPeople->keepTopPeople(tDatum.faceKeypoints, tDatum.poseScores);
67 tDatum.handKeypoints[0] = spKeepTopNPeople->keepTopPeople(tDatum.handKeypoints[0],
68 tDatum.poseScores);
69 tDatum.handKeypoints[1] = spKeepTopNPeople->keepTopPeople(tDatum.handKeypoints[1],
70 tDatum.poseScores);
71 }
72 // Profiling speed
73 Profiler::timerEnd(profilerKey);
74 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
75 // Debugging log
76 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
77 }
78 }
79 catch (const std::exception& e)
80 {
81 this->stop();
82 tDatums = nullptr;
83 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
84 }
85 }
86
87 COMPILE_TEMPLATE_DATUM(WKeepTopNPeople);
88 }
89
90 #endif // OPENPOSE_CORE_W_KEEP_TOP_N_PEOPLE_HPP
op::Priority::Low
keepTopNPeople.hpp
op::Worker
Definition: worker.hpp:9
op::WKeepTopNPeople::initializationOnThread
void initializationOnThread()
Definition: wKeepTopNPeople.hpp:47
op::WKeepTopNPeople::work
void work(TDatums &tDatums)
Definition: wKeepTopNPeople.hpp:52
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::WKeepTopNPeople
Definition: wKeepTopNPeople.hpp:11
op::WKeepTopNPeople::WKeepTopNPeople
WKeepTopNPeople(const std::shared_ptr< KeepTopNPeople > &keepTopNPeople)
Definition: wKeepTopNPeople.hpp:36
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::WKeepTopNPeople::~WKeepTopNPeople
virtual ~WKeepTopNPeople()
Definition: wKeepTopNPeople.hpp:42
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::COMPILE_TEMPLATE_DATUM
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
op::Profiler::timerEnd
static void timerEnd(const std::string &key)