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
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  void initializationOnThread();
18 
19  void workConsumer(const TDatums& tDatums);
20 
21  private:
22  std::shared_ptr<GuiAdam> spGuiAdam;
23 
24  DELETE_COPY(WGuiAdam);
25  };
26 }
27 
28 
29 
30 
31 
32 // Implementation
34 namespace op
35 {
36  template<typename TDatums>
37  WGuiAdam<TDatums>::WGuiAdam(const std::shared_ptr<GuiAdam>& guiAdam) :
38  spGuiAdam{guiAdam}
39  {
40  }
41 
42  template<typename TDatums>
43  void WGuiAdam<TDatums>::initializationOnThread()
44  {
45  try
46  {
47  spGuiAdam->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 WGuiAdam<TDatums>::workConsumer(const TDatums& tDatums)
57  {
58  try
59  {
60  // tDatums might be empty but we still wanna update the GUI
61  if (tDatums != nullptr)
62  {
63  // Debugging log
64  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
65  // Profiling speed
66  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
67  // Update cvMat & keypoints
68  if (!tDatums->empty())
69  {
70  // Update cvMat
71  std::vector<cv::Mat> cvOutputDatas;
72  for (auto& tDatum : *tDatums)
73  cvOutputDatas.emplace_back(tDatum.cvOutputData);
74  spGuiAdam->setImage(cvOutputDatas);
75  // Update keypoints
76  const auto& tDatum = (*tDatums)[0];
77  if (!tDatum.poseKeypoints3D.empty())
78  spGuiAdam->generateMesh(tDatum.poseKeypoints3D, tDatum.faceKeypoints3D, tDatum.handKeypoints3D,
79  tDatum.adamPose.data(), tDatum.adamTranslation.data(),
80  tDatum.vtVec.data(), tDatum.vtVec.rows(),
81  tDatum.j0Vec.data(), tDatum.j0Vec.rows(),
82  tDatum.adamFaceCoeffsExp.data());
83  }
84  // Refresh/update GUI
85  spGuiAdam->update();
86  // Profiling speed
87  if (!tDatums->empty())
88  {
89  Profiler::timerEnd(profilerKey);
90  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
91  }
92  // Debugging log
93  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
94  }
95  }
96  catch (const std::exception& e)
97  {
98  this->stop();
99  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
100  }
101  }
102 
103  COMPILE_TEMPLATE_DATUM(WGuiAdam);
104 }
105 
106 #endif // OPENPOSE_GUI_W_GUI_ADAM_HPP
107 #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
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)