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
wPoseTriangulation.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_3D_W_POSE_TRIANGULATION_HPP
2 #define OPENPOSE_3D_W_POSE_TRIANGULATION_HPP
3 
7 
8 namespace op
9 {
10  template<typename TDatums>
11  class WPoseTriangulation : public Worker<TDatums>
12  {
13  public:
14  explicit WPoseTriangulation();
15 
17 
18  void work(TDatums& tDatums);
19 
20  private:
21  DELETE_COPY(WPoseTriangulation);
22  };
23 }
24 
25 
26 
27 
28 
29 // Implementation
31 namespace op
32 {
33  template<typename TDatums>
35  {
36  }
37 
38  template<typename TDatums>
40  {
41  }
42 
43  template<typename TDatums>
44  void WPoseTriangulation<TDatums>::work(TDatums& tDatums)
45  {
46  try
47  {
48  if (checkNoNullNorEmpty(tDatums))
49  {
50  // Debugging log
51  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
52  // Profiling speed
53  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
54  // 3-D triangulation and reconstruction
55  std::vector<cv::Mat> cameraMatrices;
56  std::vector<Array<float>> poseKeypointVector;
57  std::vector<Array<float>> faceKeypointVector;
58  std::vector<Array<float>> leftHandKeypointVector;
59  std::vector<Array<float>> rightHandKeypointVector;
60  for (auto& datumsElement : *tDatums)
61  {
62  poseKeypointVector.emplace_back(datumsElement.poseKeypoints);
63  faceKeypointVector.emplace_back(datumsElement.faceKeypoints);
64  leftHandKeypointVector.emplace_back(datumsElement.handKeypoints[0]);
65  rightHandKeypointVector.emplace_back(datumsElement.handKeypoints[1]);
66  cameraMatrices.emplace_back(datumsElement.cameraMatrix);
67  }
68  // Pose 3-D reconstruction
69  auto poseKeypoints3D = reconstructArray(poseKeypointVector, cameraMatrices);
70  auto faceKeypoints3D = reconstructArray(faceKeypointVector, cameraMatrices);
71  auto leftHandKeypoints3D = reconstructArray(leftHandKeypointVector, cameraMatrices);
72  auto rightHandKeypoints3D = reconstructArray(rightHandKeypointVector, cameraMatrices);
73  // Assign to all tDatums
74  for (auto& datumsElement : *tDatums)
75  {
76  datumsElement.poseKeypoints3D = poseKeypoints3D;
77  datumsElement.faceKeypoints3D = faceKeypoints3D;
78  datumsElement.handKeypoints3D[0] = leftHandKeypoints3D;
79  datumsElement.handKeypoints3D[1] = rightHandKeypoints3D;
80  }
81  // Profiling speed
82  Profiler::timerEnd(profilerKey);
83  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
84  // Debugging log
85  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
86  }
87  }
88  catch (const std::exception& e)
89  {
90  this->stop();
91  tDatums = nullptr;
92  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
93  }
94  }
95 
97 }
98 
99 #endif // OPENPOSE_3D_W_POSE_TRIANGULATION_HPP
WPoseTriangulation()
Definition: wPoseTriangulation.hpp:34
Definition: worker.hpp:9
OP_API Array< float > reconstructArray(const std::vector< Array< float >> &keypointsVector, const std::vector< cv::Mat > &matrixEachCamera)
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)
Definition: wPoseTriangulation.hpp:11
void work(TDatums &tDatums)
Definition: wPoseTriangulation.hpp:44
void initializationOnThread()
Definition: wPoseTriangulation.hpp:39
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
static void timerEnd(const std::string &key)