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
wGui3D.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_GUI_W_GUI_3D_HPP
2 #define OPENPOSE_GUI_W_GUI_3D_HPP
3
4 #include <openpose/core/common.hpp>
5 #include <openpose/gui/gui3D.hpp>
6 #include <openpose/thread/workerConsumer.hpp>
7
8 namespace op
9 {
10 // This worker will do 3-D rendering
11 template<typename TDatums>
12 class WGui3D : public WorkerConsumer<TDatums>
13 {
14 public:
15 explicit WGui3D(const std::shared_ptr<Gui3D>& gui3D);
16
17 virtual ~WGui3D();
18
19 void initializationOnThread();
20
21 void workConsumer(const TDatums& tDatums);
22
23 private:
24 std::shared_ptr<Gui3D> spGui3D;
25
26 DELETE_COPY(WGui3D);
27 };
28 }
29
30
31
32
33
34 // Implementation
35 #include <openpose/utilities/pointerContainer.hpp>
36 namespace op
37 {
38 template<typename TDatums>
39 WGui3D<TDatums>::WGui3D(const std::shared_ptr<Gui3D>& gui3D) :
40 spGui3D{gui3D}
41 {
42 }
43
44 template<typename TDatums>
45 WGui3D<TDatums>::~WGui3D()
46 {
47 }
48
49 template<typename TDatums>
50 void WGui3D<TDatums>::initializationOnThread()
51 {
52 try
53 {
54 spGui3D->initializationOnThread();
55 }
56 catch (const std::exception& e)
57 {
58 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
59 }
60 }
61
62 template<typename TDatums>
63 void WGui3D<TDatums>::workConsumer(const TDatums& tDatums)
64 {
65 try
66 {
67 // tDatums might be empty but we still wanna update the GUI
68 if (tDatums != nullptr)
69 {
70 // Debugging log
71 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
72 // Profiling speed
73 const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
74 // Update cvMat & keypoints
75 if (!tDatums->empty())
76 {
77 // Update cvMat
78 std::vector<cv::Mat> cvOutputDatas;
79 for (auto& tDatum : *tDatums)
80 cvOutputDatas.emplace_back(tDatum.cvOutputData);
81 spGui3D->setImage(cvOutputDatas);
82 // Update keypoints
83 auto& tDatum = (*tDatums)[0];
84 spGui3D->setKeypoints(tDatum.poseKeypoints3D, tDatum.faceKeypoints3D, tDatum.handKeypoints3D[0],
85 tDatum.handKeypoints3D[1]);
86 }
87 // Refresh/update GUI
88 spGui3D->update();
89 // Read OpenCV mat equivalent
90 if (!tDatums->empty())
91 {
92 auto& tDatum = (*tDatums)[0];
93 tDatum.cvOutputData3D = spGui3D->readCvMat();
94 }
95 // Profiling speed
96 if (!tDatums->empty())
97 {
98 Profiler::timerEnd(profilerKey);
99 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
100 }
101 // Debugging log
102 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
103 }
104 }
105 catch (const std::exception& e)
106 {
107 this->stop();
108 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
109 }
110 }
111
112 COMPILE_TEMPLATE_DATUM(WGui3D);
113 }
114
115 #endif // OPENPOSE_GUI_W_GUI_3D_HPP
op::Priority::Low
op::WorkerConsumer
Definition: workerConsumer.hpp:10
op::WGui3D::workConsumer
void workConsumer(const TDatums &tDatums)
Definition: wGui3D.hpp:63
op::WGui3D::~WGui3D
virtual ~WGui3D()
Definition: wGui3D.hpp:45
gui3D.hpp
op::WGui3D::WGui3D
WGui3D(const std::shared_ptr< Gui3D > &gui3D)
Definition: wGui3D.hpp:39
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="")
pointerContainer.hpp
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
op::WGui3D::initializationOnThread
void initializationOnThread()
Definition: wGui3D.hpp:50
workerConsumer.hpp
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)
op::WGui3D
Definition: wGui3D.hpp:12