OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
wGuiAdam.hpp
Go to the documentation of this file.
1 #ifdef USE_3D_ADAM_MODEL
2 #ifndef OPENPOSE_GUI_W_GUI_ADAM_HPP
3 #define OPENPOSE_GUI_W_GUI_ADAM_HPP
4 
8 
9 namespace op
10 {
11  template<typename TDatums>
12  class WGuiAdam : public WorkerConsumer<TDatums>
13  {
14  public:
15  explicit WGuiAdam(const std::shared_ptr<GuiAdam>& guiAdam);
16 
17  virtual ~WGuiAdam();
18 
19  void initializationOnThread();
20 
21  void workConsumer(const TDatums& tDatums);
22 
23  private:
24  std::shared_ptr<GuiAdam> spGuiAdam;
25 
26  DELETE_COPY(WGuiAdam);
27  };
28 }
29 
30 
31 
32 
33 
34 // Implementation
36 namespace op
37 {
38  template<typename TDatums>
39  WGuiAdam<TDatums>::WGuiAdam(const std::shared_ptr<GuiAdam>& guiAdam) :
40  spGuiAdam{guiAdam}
41  {
42  }
43 
44  template<typename TDatums>
45  WGuiAdam<TDatums>::~WGuiAdam()
46  {
47  }
48 
49  template<typename TDatums>
50  void WGuiAdam<TDatums>::initializationOnThread()
51  {
52  try
53  {
54  spGuiAdam->initializationOnThread();
55  }
56  catch (const std::exception& e)
57  {
58  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
59  }
60  }
61 
62  template<typename TDatums>
63  void WGuiAdam<TDatums>::workConsumer(const TDatums& tDatums)
64  {
65  try
66  {
67  // tDatums might be empty but we still wanna update the GUI
68  if (tDatums != nullptr)
69  {
70  // Debugging log
71  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
72  // Profiling speed
73  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
74  // Update cvMat & keypoints
75  if (!tDatums->empty())
76  {
77  // Update cvMat
78  std::vector<Mat> cvOutputDatas;
79  for (auto& tDatum : *tDatums)
80  cvOutputDatas.emplace_back(tDatumPtr->cvOutputData);
81  spGuiAdam->setImage(cvOutputDatas);
82  // Update keypoints
83  const auto& tDatumPtr = (*tDatums)[0];
84  if (!tDatumPtr->poseKeypoints3D.empty())
85  spGuiAdam->generateMesh(
86  tDatumPtr->poseKeypoints3D, tDatumPtr->faceKeypoints3D, tDatumPtr->handKeypoints3D,
87  tDatumPtr->adamPose.data(), tDatumPtr->adamTranslation.data(), tDatumPtr->vtVec.data(),
88  tDatumPtr->vtVec.rows(), tDatumPtr->j0Vec.data(), tDatumPtr->j0Vec.rows(),
89  tDatumPtr->adamFaceCoeffsExp.data());
90  }
91  // Refresh/update GUI
92  spGuiAdam->update();
93  // Profiling speed
94  if (!tDatums->empty())
95  {
96  Profiler::timerEnd(profilerKey);
97  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
98  }
99  // Debugging log
100  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
101  }
102  }
103  catch (const std::exception& e)
104  {
105  this->stop();
106  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
107  }
108  }
109 
110  COMPILE_TEMPLATE_DATUM(WGuiAdam);
111 }
112 
113 #endif // OPENPOSE_GUI_W_GUI_ADAM_HPP
114 #endif
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:407
#define DELETE_COPY(className)
Definition: macros.hpp:32
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
void opLogIfDebug(const T &message, const Priority priority=Priority::Max, const int line=-1, const std::string &function="", const std::string &file="")
Definition: errorAndLog.hpp:97