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
wGui.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_GUI_W_GUI_HPP
2 #define OPENPOSE_GUI_W_GUI_HPP
3
4 #include <openpose/core/common.hpp>
5 #include <openpose/gui/gui.hpp>
6 #include <openpose/thread/workerConsumer.hpp>
7
8 namespace op
9 {
10 template<typename TDatums>
11 class WGui : public WorkerConsumer<TDatums>
12 {
13 public:
14 explicit WGui(const std::shared_ptr<Gui>& gui);
15
16 virtual ~WGui();
17
18 void initializationOnThread();
19
20 void workConsumer(const TDatums& tDatums);
21
22 private:
23 std::shared_ptr<Gui> spGui;
24
25 DELETE_COPY(WGui);
26 };
27 }
28
29
30
31
32
33 // Implementation
34 #include <openpose/utilities/pointerContainer.hpp>
35 namespace op
36 {
37 template<typename TDatums>
38 WGui<TDatums>::WGui(const std::shared_ptr<Gui>& gui) :
39 spGui{gui}
40 {
41 }
42
43 template<typename TDatums>
44 WGui<TDatums>::~WGui()
45 {
46 }
47
48 template<typename TDatums>
49 void WGui<TDatums>::initializationOnThread()
50 {
51 try
52 {
53 spGui->initializationOnThread();
54 }
55 catch (const std::exception& e)
56 {
57 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
58 }
59 }
60
61 template<typename TDatums>
62 void WGui<TDatums>::workConsumer(const TDatums& tDatums)
63 {
64 try
65 {
66 // tDatums might be empty but we still wanna update the GUI
67 if (tDatums != nullptr)
68 {
69 // Debugging log
70 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
71 // Profiling speed
72 const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
73 // Update cvMat
74 if (!tDatums->empty())
75 {
76 std::vector<cv::Mat> cvOutputDatas;
77 for (auto& tDatum : *tDatums)
78 cvOutputDatas.emplace_back(tDatum.cvOutputData);
79 spGui->setImage(cvOutputDatas);
80 }
81 // Refresh/update GUI
82 spGui->update();
83 // Profiling speed
84 if (!tDatums->empty())
85 {
86 Profiler::timerEnd(profilerKey);
87 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
88 }
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(WGui);
101 }
102
103 #endif // OPENPOSE_GUI_W_GUI_HPP
op::Priority::Low
op::WorkerConsumer
Definition: workerConsumer.hpp:10
op::WGui
Definition: wGui.hpp:11
op::WGui::workConsumer
void workConsumer(const TDatums &tDatums)
Definition: wGui.hpp:62
op::WGui::initializationOnThread
void initializationOnThread()
Definition: wGui.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="")
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
gui.hpp
workerConsumer.hpp
op::WGui::~WGui
virtual ~WGui()
Definition: wGui.hpp:44
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::WGui::WGui
WGui(const std::shared_ptr< Gui > &gui)
Definition: wGui.hpp:38
op::Profiler::timerEnd
static void timerEnd(const std::string &key)