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
wUdpSender.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_FILESTREAM_W_UDP_SENDER_HPP
2 #define OPENPOSE_FILESTREAM_W_UDP_SENDER_HPP
3 
7 
8 namespace op
9 {
10  template<typename TDatums>
11  class WUdpSender : public WorkerConsumer<TDatums>
12  {
13  public:
14  explicit WUdpSender(const std::shared_ptr<UdpSender>& udpSender);
15 
17 
18  void workConsumer(const TDatums& tDatums);
19 
20  private:
21  const std::shared_ptr<UdpSender> spUdpSender;
22 
23  DELETE_COPY(WUdpSender);
24  };
25 }
26 
27 
28 
29 
30 
31 // Implementation
33 namespace op
34 {
35  template<typename TDatums>
36  WUdpSender<TDatums>::WUdpSender(const std::shared_ptr<UdpSender>& udpSender) :
37  spUdpSender{udpSender}
38  {
39  }
40 
41  template<typename TDatums>
43  {
44  }
45 
46  template<typename TDatums>
47  void WUdpSender<TDatums>::workConsumer(const TDatums& tDatums)
48  {
49  try
50  {
51  if (checkNoNullNorEmpty(tDatums))
52  {
53  // Debugging log
54  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
55  // Profiling speed
56  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
57  // Send though UDP communication
58 #ifdef USE_3D_ADAM_MODEL
59  const auto& tDatum = (*tDatums)[0];
60  if (!tDatum.poseKeypoints3D.empty())
61  {
62  const auto& adamPose = tDatum.adamPose; // Eigen::Matrix<double, 62, 3, Eigen::RowMajor>
63  const auto& adamTranslation = tDatum.adamTranslation; // Eigen::Vector3d(3, 1)
64  const auto adamFaceCoeffsExp = tDatum.adamFaceCoeffsExp; // Eigen::VectorXd resized to (200, 1)
65  //const float mouth_open = tDatum.mouthOpening; // tDatum.mouth_open;
66  //const float leye_open = tDatum.rightEyeOpening; // tDatum.leye_open;
67  //const float reye_open = tDatum.leftEyeOpening; // tDatum.reye_open;
68  //const float dist_root_foot = Datum.distanceRootFoot; // tDatum.dist_root_foot;
69  // m_adam_t:
70  // 1. Total translation (centimeters) of the root in camera/global coordinate representation.
71  // m_adam_pose:
72  // 1. First row is global rotation, in AngleAxis representation. Radians (not degrees!)
73  // 2. Rest are joint-angles in Euler-Angle representation. Degrees.
74  spUdpSender->sendJointAngles(adamPose.data(), adamPose.rows(),
75  adamTranslation.data(),
76  adamFaceCoeffsExp.data(), adamFaceCoeffsExp.rows());
77  }
78 #endif
79  // Profiling speed
80  Profiler::timerEnd(profilerKey);
81  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
82  // Debugging log
83  dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
84  }
85  }
86  catch (const std::exception& e)
87  {
88  this->stop();
89  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
90  }
91  }
92 
94 }
95 
96 #endif // OPENPOSE_FILESTREAM_W_UDP_SENDER_HPP
Definition: workerConsumer.hpp:10
void workConsumer(const TDatums &tDatums)
Definition: wUdpSender.hpp:47
void initializationOnThread()
Definition: wUdpSender.hpp:42
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="")
Definition: wUdpSender.hpp:11
WUdpSender(const std::shared_ptr< UdpSender > &udpSender)
Definition: wUdpSender.hpp:36
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)