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
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  void initializationOnThread();
18 
19  void workConsumer(const TDatums& tDatums);
20 
21  private:
22  std::shared_ptr<BvhSaver> spBvhSaver;
23 
24  DELETE_COPY(WBvhSaver);
25  };
26 }
27 
28 
29 
30 
31 
32 // Implementation
34 namespace op
35 {
36  template<typename TDatums>
37  WBvhSaver<TDatums>::WBvhSaver(const std::shared_ptr<BvhSaver>& bvhSaver) :
38  spBvhSaver{bvhSaver}
39  {
40  }
41 
42  template<typename TDatums>
43  void WBvhSaver<TDatums>::initializationOnThread()
44  {
45  }
46 
47  template<typename TDatums>
48  void WBvhSaver<TDatums>::workConsumer(const TDatums& tDatums)
49  {
50  try
51  {
52  if (checkNoNullNorEmpty(tDatums))
53  {
54  // Debugging log
55  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
56  // Profiling speed
57  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
58  // Record BVH file
59  const auto& tDatum = (*tDatums)[0];
60  if (!tDatum.poseKeypoints3D.empty())
61  spBvhSaver->updateBvh(tDatum.adamPose, tDatum.adamTranslation, tDatum.j0Vec);
62  // Profiling speed
63  Profiler::timerEnd(profilerKey);
64  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
65  // Debugging log
66  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
67  }
68  }
69  catch (const std::exception& e)
70  {
71  this->stop();
72  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
73  }
74  }
75 
76  COMPILE_TEMPLATE_DATUM(WBvhSaver);
77 }
78 
79 #endif // OPENPOSE_FILESTREAM_W_BVH_SAVER_HPP
80 #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)