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 
17 
18  void work(TDatums& tDatums);
19 
20  private:
21  std::shared_ptr<KeypointScaler> spKeypointScaler;
22  };
23 }
24 
25 
26 
27 
28 
29 // Implementation
31 namespace op
32 {
33  template<typename TDatums>
34  WKeypointScaler<TDatums>::WKeypointScaler(const std::shared_ptr<KeypointScaler>& keypointScaler) :
35  spKeypointScaler{keypointScaler}
36  {
37  }
38 
39  template<typename TDatums>
41  {
42  }
43 
44  template<typename TDatums>
45  void WKeypointScaler<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  std::vector<Array<float>> arraysToScale{tDatum.poseKeypoints, tDatum.handKeypoints[0],
59  tDatum.handKeypoints[1], tDatum.faceKeypoints};
60  spKeypointScaler->scale(arraysToScale, tDatum.scaleInputToOutput, tDatum.scaleNetToOutput,
61  Point<int>{tDatum.cvInputData.cols, tDatum.cvInputData.rows});
62  }
63  // Profiling speed
64  Profiler::timerEnd(profilerKey);
65  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
66  // Debugging log
67  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
68  }
69  }
70  catch (const std::exception& e)
71  {
72  this->stop();
73  tDatums = nullptr;
74  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
75  }
76  }
77 
78  COMPILE_TEMPLATE_DATUM(WKeypointScaler);
79 }
80 
81 #endif // OPENPOSE_CORE_W_KEYPOINT_SCALER_HPP
Definition: worker.hpp:9
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:339
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: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
void work(TDatums &tDatums)
Definition: wKeypointScaler.hpp:45
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:40