OpenPose 1.0.0rc2 OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <openpose/core/common.hpp>
5 #include <openpose/filestream/udpSender.hpp>
6 #include <openpose/thread/workerConsumer.hpp>
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
18 void initializationOnThread();
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
34 #include <openpose/utilities/pointerContainer.hpp>
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>
44 WUdpSender<TDatums>::~WUdpSender()
45 {
46 }
47
48 template<typename TDatums>
49 void WUdpSender<TDatums>::initializationOnThread()
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 dLog("", 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& tDatum = (*tDatums)[0];
67 if (!tDatum.poseKeypoints3D.empty())
68 {
69 const auto& adamPose = tDatum.adamPose; // Eigen::Matrix<double, 62, 3, Eigen::RowMajor>
70 const auto& adamTranslation = tDatum.adamTranslation; // Eigen::Vector3d(3, 1)
71 const auto adamFaceCoeffsExp = tDatum.adamFaceCoeffsExp; // Eigen::VectorXd resized to (200, 1)
72 //const float mouth_open = tDatum.mouthOpening; // tDatum.mouth_open;
73 //const float leye_open = tDatum.rightEyeOpening; // tDatum.leye_open;
74 //const float reye_open = tDatum.leftEyeOpening; // tDatum.reye_open;
75 //const float dist_root_foot = Datum.distanceRootFoot; // tDatum.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(adamPose.data(), adamPose.rows(),
82 adamTranslation.data(),
83 adamFaceCoeffsExp.data(), adamFaceCoeffsExp.rows());
84 }
85 #endif
86 // Profiling speed
87 Profiler::timerEnd(profilerKey);
88 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
89 // Debugging log
90 dLog("", 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
100 COMPILE_TEMPLATE_DATUM(WUdpSender);
101 }
102
103 #endif // OPENPOSE_FILESTREAM_W_UDP_SENDER_HPP
op::Priority::Low
op::WorkerConsumer
Definition: workerConsumer.hpp:10
op::WUdpSender::~WUdpSender
virtual ~WUdpSender()
Definition: wUdpSender.hpp:44
op::WUdpSender::workConsumer
void workConsumer(const TDatums &tDatums)
Definition: wUdpSender.hpp:54
op::WUdpSender::initializationOnThread
void initializationOnThread()
Definition: wUdpSender.hpp:49
common.hpp
op::Profiler::timerInit
static const std::string timerInit(const int line, const std::string &function, const std::string &file)
op::error
OP_API void error(const std::string &message, const int line=-1, const std::string &function="", const std::string &file="")
op::WUdpSender
Definition: wUdpSender.hpp:11
pointerContainer.hpp
udpSender.hpp
op::WUdpSender::WUdpSender
WUdpSender(const std::shared_ptr< UdpSender > &udpSender)
Definition: wUdpSender.hpp:38
op::dLog
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
workerConsumer.hpp
op::checkNoNullNorEmpty
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
Definition: pointerContainer.hpp:7
op::Profiler::printAveragedTimeMsOnIterationX
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)
op::COMPILE_TEMPLATE_DATUM
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
op::Profiler::timerEnd
static void timerEnd(const std::string &key)