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
wHandSaver.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_FILESTREAM_W_HAND_SAVER_HPP
2 #define OPENPOSE_FILESTREAM_W_HAND_SAVER_HPP
3
4 #include <openpose/core/common.hpp>
5 #include <openpose/filestream/enumClasses.hpp>
6 #include <openpose/filestream/keypointSaver.hpp>
7 #include <openpose/thread/workerConsumer.hpp>
8
9 namespace op
10 {
11 template<typename TDatums>
12 class WHandSaver : public WorkerConsumer<TDatums>
13 {
14 public:
15 explicit WHandSaver(const std::shared_ptr<KeypointSaver>& keypointSaver);
16
17 virtual ~WHandSaver();
18
19 void initializationOnThread();
20
21 void workConsumer(const TDatums& tDatums);
22
23 private:
24 const std::shared_ptr<KeypointSaver> spKeypointSaver;
25
26 DELETE_COPY(WHandSaver);
27 };
28 }
29
30
31
32
33
34 // Implementation
35 #include <openpose/utilities/pointerContainer.hpp>
36 namespace op
37 {
38 template<typename TDatums>
39 WHandSaver<TDatums>::WHandSaver(const std::shared_ptr<KeypointSaver>& keypointSaver) :
40 spKeypointSaver{keypointSaver}
41 {
42 }
43
44 template<typename TDatums>
45 WHandSaver<TDatums>::~WHandSaver()
46 {
47 }
48
49 template<typename TDatums>
50 void WHandSaver<TDatums>::initializationOnThread()
51 {
52 }
53
54 template<typename TDatums>
55 void WHandSaver<TDatums>::workConsumer(const TDatums& tDatums)
56 {
57 try
58 {
59 if (checkNoNullNorEmpty(tDatums))
60 {
61 // Debugging log
62 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
63 // Profiling speed
64 const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
65 // T* to T
66 auto& tDatumsNoPtr = *tDatums;
67 // Record people hand keypoint data
68 const auto fileName = (!tDatumsNoPtr[0].name.empty() ? tDatumsNoPtr[0].name : std::to_string(tDatumsNoPtr[0].id));
69 std::vector<Array<float>> keypointVector(tDatumsNoPtr.size());
70 // Left hand
71 for (auto i = 0u; i < tDatumsNoPtr.size(); i++)
72 keypointVector[i] = tDatumsNoPtr[i].handKeypoints[0];
73 spKeypointSaver->saveKeypoints(keypointVector, fileName, "hand_left");
74 // Right hand
75 for (auto i = 0u; i < tDatumsNoPtr.size(); i++)
76 keypointVector[i] = tDatumsNoPtr[i].handKeypoints[1];
77 spKeypointSaver->saveKeypoints(keypointVector, fileName, "hand_right");
78 // Profiling speed
79 Profiler::timerEnd(profilerKey);
80 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
81 // Debugging log
82 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
83 }
84 }
85 catch (const std::exception& e)
86 {
87 this->stop();
88 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
89 }
90 }
91
92 COMPILE_TEMPLATE_DATUM(WHandSaver);
93 }
94
95 #endif // OPENPOSE_FILESTREAM_W_HAND_SAVER_HPP
op::Priority::Low
op::WorkerConsumer
Definition: workerConsumer.hpp:10
keypointSaver.hpp
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::WHandSaver::WHandSaver
WHandSaver(const std::shared_ptr< KeypointSaver > &keypointSaver)
Definition: wHandSaver.hpp:39
pointerContainer.hpp
op::WHandSaver::initializationOnThread
void initializationOnThread()
Definition: wHandSaver.hpp:50
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
enumClasses.hpp
op::WHandSaver::workConsumer
void workConsumer(const TDatums &tDatums)
Definition: wHandSaver.hpp:55
workerConsumer.hpp
op::checkNoNullNorEmpty
bool checkNoNullNorEmpty(const TPointerContainer &tPointerContainer)
Definition: pointerContainer.hpp:7
op::WHandSaver
Definition: wHandSaver.hpp:12
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::WHandSaver::~WHandSaver
virtual ~WHandSaver()
Definition: wHandSaver.hpp:45
op::COMPILE_TEMPLATE_DATUM
COMPILE_TEMPLATE_DATUM(WPoseTriangulation)
op::Profiler::timerEnd
static void timerEnd(const std::string &key)