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
wGuiAdam.hpp
Go to the documentation of this file.
1 #ifdef USE_3D_ADAM_MODEL
2 #ifndef OPENPOSE_GUI_W_GUI_ADAM_HPP
3 #define OPENPOSE_GUI_W_GUI_ADAM_HPP
4
5 #include <openpose/core/common.hpp>
6 #include <openpose/gui/guiAdam.hpp>
7 #include <openpose/thread/workerConsumer.hpp>
8
9 namespace op
10 {
11 template<typename TDatums>
12 class WGuiAdam : public WorkerConsumer<TDatums>
13 {
14 public:
15 explicit WGuiAdam(const std::shared_ptr<GuiAdam>& guiAdam);
16
17 virtual ~WGuiAdam();
18
19 void initializationOnThread();
20
21 void workConsumer(const TDatums& tDatums);
22
23 private:
24 std::shared_ptr<GuiAdam> spGuiAdam;
25
26 DELETE_COPY(WGuiAdam);
27 };
28 }
29
30
31
32
33
34 // Implementation
35 #include <openpose/utilities/pointerContainer.hpp>
36 namespace op
37 {
38 template<typename TDatums>
39 WGuiAdam<TDatums>::WGuiAdam(const std::shared_ptr<GuiAdam>& guiAdam) :
40 spGuiAdam{guiAdam}
41 {
42 }
43
44 template<typename TDatums>
45 WGuiAdam<TDatums>::~WGuiAdam()
46 {
47 }
48
49 template<typename TDatums>
50 void WGuiAdam<TDatums>::initializationOnThread()
51 {
52 try
53 {
54 spGuiAdam->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 WGuiAdam<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 spGuiAdam->setImage(cvOutputDatas);
82 // Update keypoints
83 const auto& tDatum = (*tDatums)[0];
84 if (!tDatum.poseKeypoints3D.empty())
85 spGuiAdam->generateMesh(tDatum.poseKeypoints3D, tDatum.faceKeypoints3D, tDatum.handKeypoints3D,
86 tDatum.adamPose.data(), tDatum.adamTranslation.data(),
87 tDatum.vtVec.data(), tDatum.vtVec.rows(),
88 tDatum.j0Vec.data(), tDatum.j0Vec.rows(),
89 tDatum.adamFaceCoeffsExp.data());
90 }
91 // Refresh/update GUI
92 spGuiAdam->update();
93 // Profiling speed
94 if (!tDatums->empty())
95 {
96 Profiler::timerEnd(profilerKey);
97 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
98 }
99 // Debugging log
100 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
101 }
102 }
103 catch (const std::exception& e)
104 {
105 this->stop();
106 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
107 }
108 }
109
110 COMPILE_TEMPLATE_DATUM(WGuiAdam);
111 }
112
113 #endif // OPENPOSE_GUI_W_GUI_ADAM_HPP
114 #endif
DELETE_COPY
#define DELETE_COPY(className)
Definition: macros.hpp:34
op::Priority::Low
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
workerConsumer.hpp
guiAdam.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)