OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
wBvhSaver.hpp
Go to the documentation of this file.
1 #ifdef USE_3D_ADAM_MODEL
2 #ifndef OPENPOSE_FILESTREAM_W_BVH_SAVER_HPP
3 #define OPENPOSE_FILESTREAM_W_BVH_SAVER_HPP
4 
8 
9 namespace op
10 {
11  template<typename TDatums>
12  class WBvhSaver : public WorkerConsumer<TDatums>
13  {
14  public:
15  explicit WBvhSaver(const std::shared_ptr<BvhSaver>& bvhSaver);
16 
17  virtual ~WBvhSaver();
18 
19  void initializationOnThread();
20 
21  void workConsumer(const TDatums& tDatums);
22 
23  private:
24  std::shared_ptr<BvhSaver> spBvhSaver;
25 
26  DELETE_COPY(WBvhSaver);
27  };
28 }
29 
30 
31 
32 
33 
34 // Implementation
36 namespace op
37 {
38  template<typename TDatums>
39  WBvhSaver<TDatums>::WBvhSaver(const std::shared_ptr<BvhSaver>& bvhSaver) :
40  spBvhSaver{bvhSaver}
41  {
42  }
43 
44  template<typename TDatums>
45  WBvhSaver<TDatums>::~WBvhSaver()
46  {
47  }
48 
49  template<typename TDatums>
50  void WBvhSaver<TDatums>::initializationOnThread()
51  {
52  }
53 
54  template<typename TDatums>
55  void WBvhSaver<TDatums>::workConsumer(const TDatums& tDatums)
56  {
57  try
58  {
59  if (checkNoNullNorEmpty(tDatums))
60  {
61  // Debugging log
62  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
63  // Profiling speed
64  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
65  // Record BVH file
66  const auto& tDatumPtr = (*tDatums)[0];
67  if (!tDatumPtr->poseKeypoints3D.empty())
68  spBvhSaver->updateBvh(tDatumPtr->adamPose, tDatumPtr->adamTranslation, tDatumPtr->j0Vec);
69  // Profiling speed
70  Profiler::timerEnd(profilerKey);
71  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
72  // Debugging log
73  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
74  }
75  }
76  catch (const std::exception& e)
77  {
78  this->stop();
79  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
80  }
81  }
82 
83  COMPILE_TEMPLATE_DATUM(WBvhSaver);
84 }
85 
86 #endif // OPENPOSE_FILESTREAM_W_BVH_SAVER_HPP
87 #endif
#define COMPILE_TEMPLATE_DATUM(templateName)
Definition: datum.hpp:407
#define DELETE_COPY(className)
Definition: macros.hpp:32
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
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