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
wKeypointScaler.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
2 #define OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
3 
7 
8 namespace op
9 {
10  template<typename TDatums>
11  class WKeypointScaler : public Worker<TDatums>
12  {
13  public:
14  explicit WKeypointScaler(const std::shared_ptr<KeypointScaler>& keypointScaler);
15 
16  virtual ~WKeypointScaler();
17 
19 
20  void work(TDatums& tDatums);
21 
22  private:
23  std::shared_ptr<KeypointScaler> spKeypointScaler;
24  };
25 }
26 
27 
28 
29 
30 
31 // Implementation
33 namespace op
34 {
35  template<typename TDatums>
36  WKeypointScaler<TDatums>::WKeypointScaler(const std::shared_ptr<KeypointScaler>& keypointScaler) :
37  spKeypointScaler{keypointScaler}
38  {
39  }
40 
41  template<typename TDatums>
43  {
44  }
45 
46  template<typename TDatums>
48  {
49  }
50 
51  template<typename TDatums>
52  void WKeypointScaler<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  std::vector<Array<float>> arraysToScale{tDatum.poseKeypoints, tDatum.handKeypoints[0],
66  tDatum.handKeypoints[1], tDatum.faceKeypoints};
67  spKeypointScaler->scale(arraysToScale, tDatum.scaleInputToOutput, tDatum.scaleNetToOutput,
68  Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows});
69  // Rescale part candidates
70  spKeypointScaler->scale(tDatum.poseCandidates, tDatum.scaleInputToOutput, tDatum.scaleNetToOutput,
71  Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows});
72  }
73  // Profiling speed
74  Profiler::timerEnd(profilerKey);
75  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
76  // Debugging log
77  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
78  }
79  }
80  catch (const std::exception& e)
81  {
82  this->stop();
83  tDatums = nullptr;
84  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
85  }
86  }
87 
88  COMPILE_TEMPLATE_DATUM(WKeypointScaler);
89 }
90 
91 #endif // OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
virtual ~WKeypointScaler()
Definition: wKeypointScaler.hpp:42
Definition: worker.hpp:9
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:395
Definition: wKeypointScaler.hpp:11
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="")
WKeypointScaler(const std::shared_ptr< KeypointScaler > &keypointScaler)
Definition: wKeypointScaler.hpp:36
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
void work(TDatums &tDatums)
Definition: wKeypointScaler.hpp:52
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)
static void timerEnd(const std::string &key)
void initializationOnThread()
Definition: wKeypointScaler.hpp:47