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
wJointAngleEstimation.hpp
Go to the documentation of this file.
1 #ifdef USE_3D_ADAM_MODEL
2 #ifndef OPENPOSE_3D_W_JOINT_ANGLE_ESTIMATION_HPP
3 #define OPENPOSE_3D_W_JOINT_ANGLE_ESTIMATION_HPP
4 
8 
9 namespace op
10 {
11  template<typename TDatums>
12  class WJointAngleEstimation : public Worker<TDatums>
13  {
14  public:
15  explicit WJointAngleEstimation(const std::shared_ptr<JointAngleEstimation>& jointAngleEstimation);
16 
17  void initializationOnThread();
18 
19  void work(TDatums& tDatums);
20 
21  private:
22  const std::shared_ptr<JointAngleEstimation> spJointAngleEstimation;
23 
24  DELETE_COPY(WJointAngleEstimation);
25  };
26 }
27 
28 
29 
30 
31 
32 // Implementation
34 namespace op
35 {
36  template<typename TDatums>
37  WJointAngleEstimation<TDatums>::WJointAngleEstimation(const std::shared_ptr<JointAngleEstimation>& jointAngleEstimation) :
38  spJointAngleEstimation{jointAngleEstimation}
39  {
40  }
41 
42  template<typename TDatums>
43  void WJointAngleEstimation<TDatums>::initializationOnThread()
44  {
45  try
46  {
47  spJointAngleEstimation->initializationOnThread();
48  }
49  catch (const std::exception& e)
50  {
51  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
52  }
53  }
54 
55  template<typename TDatums>
56  void WJointAngleEstimation<TDatums>::work(TDatums& tDatums)
57  {
58  try
59  {
60  if (checkNoNullNorEmpty(tDatums))
61  {
62  // Debugging log
63  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
64  // Profiling speed
65  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
66  // Input
67  auto& datum = tDatums->at(0);
68  const auto& poseKeypoints3D = datum.poseKeypoints3D;
69  const auto& faceKeypoints3D = datum.faceKeypoints3D;
70  const auto& handKeypoints3D = datum.handKeypoints3D;
71  // Running Adam model
72  spJointAngleEstimation->adamFastFit(
73  datum.adamPose, datum.adamTranslation, datum.vtVec, datum.j0Vec,
74  datum.adamFaceCoeffsExp, poseKeypoints3D, faceKeypoints3D, handKeypoints3D);
75  // Profiling speed
76  Profiler::timerEnd(profilerKey);
77  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
78  // Debugging log
79  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
80  }
81  }
82  catch (const std::exception& e)
83  {
84  this->stop();
85  tDatums = nullptr;
86  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
87  }
88  }
89 
90  COMPILE_TEMPLATE_DATUM(WJointAngleEstimation);
91 }
92 
93 #endif // OPENPOSE_3D_W_JOINT_ANGLE_ESTIMATION_HPP
94 #endif
#define DELETE_COPY(className)
Definition: macros.hpp:31
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="")
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)