OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 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 
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 
17 
18  void work(TDatums& tDatums);
19 
20  private:
21  std::shared_ptr<KeepTopNPeople> spKeepTopNPeople;
22  };
23 }
24 
25 
26 
27 
28 
29 // Implementation
31 namespace op
32 {
33  template<typename TDatums>
34  WKeepTopNPeople<TDatums>::WKeepTopNPeople(const std::shared_ptr<KeepTopNPeople>& keepTopNPeople) :
35  spKeepTopNPeople{keepTopNPeople}
36  {
37  }
38 
39  template<typename TDatums>
41  {
42  }
43 
44  template<typename TDatums>
45  void WKeepTopNPeople<TDatums>::work(TDatums& tDatums)
46  {
47  try
48  {
49  if (checkNoNullNorEmpty(tDatums))
50  {
51  // Debugging log
52  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
53  // Profiling speed
54  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
55  // Rescale pose data
56  for (auto& tDatum : *tDatums)
57  {
58  tDatum.poseKeypoints = spKeepTopNPeople->keepTopPeople(tDatum.poseKeypoints, tDatum.poseScores);
59  tDatum.faceKeypoints = spKeepTopNPeople->keepTopPeople(tDatum.faceKeypoints, tDatum.poseScores);
60  tDatum.handKeypoints[0] = spKeepTopNPeople->keepTopPeople(tDatum.handKeypoints[0],
61  tDatum.poseScores);
62  tDatum.handKeypoints[1] = spKeepTopNPeople->keepTopPeople(tDatum.handKeypoints[1],
63  tDatum.poseScores);
64  }
65  // Profiling speed
66  Profiler::timerEnd(profilerKey);
67  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
68  // Debugging log
69  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
70  }
71  }
72  catch (const std::exception& e)
73  {
74  this->stop();
75  tDatums = nullptr;
76  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
77  }
78  }
79 
81 }
82 
83 #endif // OPENPOSE_CORE_W_KEEP_TOP_N_PEOPLE_HPP
Definition: worker.hpp:9
void initializationOnThread()
Definition: wKeepTopNPeople.hpp:40
void work(TDatums &tDatums)
Definition: wKeepTopNPeople.hpp:45
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
Definition: wKeepTopNPeople.hpp:11
WKeepTopNPeople(const std::shared_ptr< KeepTopNPeople > &keepTopNPeople)
Definition: wKeepTopNPeople.hpp:34
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
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
Definition: pointerContainer.hpp:7
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)
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
static void timerEnd(const std::string &key)