OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
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 
16  virtual ~WUdpSender();
17 
19 
20  void workConsumer(const TDatums& tDatums);
21 
22  private:
23  const std::shared_ptr<UdpSender> spUdpSender;
24 
25  DELETE_COPY(WUdpSender);
26  };
27 }
28 
29 
30 
31 
32 
33 // Implementation
35 namespace op
36 {
37  template<typename TDatums>
38  WUdpSender<TDatums>::WUdpSender(const std::shared_ptr<UdpSender>& udpSender) :
39  spUdpSender{udpSender}
40  {
41  }
42 
43  template<typename TDatums>
45  {
46  }
47 
48  template<typename TDatums>
50  {
51  }
52 
53  template<typename TDatums>
54  void WUdpSender<TDatums>::workConsumer(const TDatums& tDatums)
55  {
56  try
57  {
58  if (checkNoNullNorEmpty(tDatums))
59  {
60  // Debugging log
61  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
62  // Profiling speed
63  const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
64  // Send though UDP communication
65 #ifdef USE_3D_ADAM_MODEL
66  const auto& tDatumPtr = (*tDatums)[0];
67  if (!tDatumPtr->poseKeypoints3D.empty())
68  {
69  const auto& adamPose = tDatumPtr->adamPose; // Eigen::Matrix<double, 62, 3, Eigen::RowMajor>
70  const auto& adamTranslation = tDatumPtr->adamTranslation; // Eigen::Vector3d(3, 1)
71  const auto adamFaceCoeffsExp = tDatumPtr->adamFaceCoeffsExp; // Eigen::VectorXd resized to (200, 1)
72  //const float mouth_open = tDatumPtr->mouthOpening; // tDatumPtr->mouth_open;
73  //const float leye_open = tDatumPtr->rightEyeOpening; // tDatumPtr->leye_open;
74  //const float reye_open = tDatumPtr->leftEyeOpening; // tDatumPtr->reye_open;
75  //const float dist_root_foot = Datum.distanceRootFoot; // tDatumPtr->dist_root_foot;
76  // m_adam_t:
77  // 1. Total translation (centimeters) of the root in camera/global coordinate representation.
78  // m_adam_pose:
79  // 1. First row is global rotation, in AngleAxis representation. Radians (not degrees!)
80  // 2. Rest are joint-angles in Euler-Angle representation. Degrees.
81  spUdpSender->sendJointAngles(
82  adamPose.data(), adamPose.rows(), adamTranslation.data(), adamFaceCoeffsExp.data(),
83  adamFaceCoeffsExp.rows());
84  }
85 #endif
86  // Profiling speed
87  Profiler::timerEnd(profilerKey);
88  Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
89  // Debugging log
90  opLogIfDebug("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
91  }
92  }
93  catch (const std::exception& e)
94  {
95  this->stop();
96  error(e.what(), __LINE__, __FUNCTION__, __FILE__);
97  }
98  }
99 
101 }
102 
103 #endif // OPENPOSE_FILESTREAM_W_UDP_SENDER_HPP
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)
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
static void timerEnd(const std::string &key)
WUdpSender(const std::shared_ptr< UdpSender > &udpSender)
Definition: wUdpSender.hpp:38
void initializationOnThread()
Definition: wUdpSender.hpp:49
void workConsumer(const TDatums &tDatums)
Definition: wUdpSender.hpp:54
virtual ~WUdpSender()
Definition: wUdpSender.hpp:44
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
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