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
wFpsMax.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_THREAD_W_FPS_MAX_HPP
2 #define OPENPOSE_THREAD_W_FPS_MAX_HPP
3
4 #include <thread>
5 #include <openpose/core/common.hpp>
6 #include <openpose/thread/worker.hpp>
7 #include <openpose/utilities/fastMath.hpp>
8
9 namespace op
10 {
11 template<typename TDatums>
12 class WFpsMax : public Worker<TDatums>
13 {
14 public:
15 explicit WFpsMax(const double fpsMax);
16
17 virtual ~WFpsMax();
18
19 void initializationOnThread();
20
21 void work(TDatums& tDatums);
22
23 private:
24 const unsigned long long mNanosecondsToSleep;
25
26 DELETE_COPY(WFpsMax);
27 };
28 }
29
30
31
32
33
34 // Implementation
35 namespace op
36 {
37 template<typename TDatums>
38 WFpsMax<TDatums>::WFpsMax(const double fpsMax) :
39 mNanosecondsToSleep{uLongLongRound(1e9/fpsMax)}
40 {
41 }
42
43 template<typename TDatums>
44 WFpsMax<TDatums>::~WFpsMax()
45 {
46 }
47
48 template<typename TDatums>
49 void WFpsMax<TDatums>::initializationOnThread()
50 {
51 }
52
53 template<typename TDatums>
54 void WFpsMax<TDatums>::work(TDatums& tDatums)
55 {
56 try
57 {
58 // Debugging log
59 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
60 // Profiling speed
61 const auto profilerKey = Profiler::timerInit(__LINE__, __FUNCTION__, __FILE__);
62 // tDatums not used --> Avoid warning
63 UNUSED(tDatums);
64 // Sleep the desired time
65 std::this_thread::sleep_for(std::chrono::nanoseconds{mNanosecondsToSleep});
66 // Profiling speed
67 Profiler::timerEnd(profilerKey);
68 Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__);
69 // Debugging log
70 dLog("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
71 }
72 catch (const std::exception& e)
73 {
74 this->stop();
75 tDatums = nullptr;
76 error(e.what(), __LINE__, __FUNCTION__, __FILE__);
77 }
78 }
79
80 COMPILE_TEMPLATE_DATUM(WFpsMax);
81 }
82
83 #endif // OPENPOSE_THREAD_W_FPS_MAX_HPP
fastMath.hpp
op::Priority::Low
op::WFpsMax::initializationOnThread
void initializationOnThread()
Definition: wFpsMax.hpp:49
op::WFpsMax
Definition: wFpsMax.hpp:12
op::WFpsMax::work
void work(TDatums &tDatums)
Definition: wFpsMax.hpp:54
op::Worker
Definition: worker.hpp:9
op::WFpsMax::WFpsMax
WFpsMax(const double fpsMax)
Definition: wFpsMax.hpp:38
UNUSED
#define UNUSED(unusedVariable)
Definition: macros.hpp:32
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::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
worker.hpp
op::WFpsMax::~WFpsMax
virtual ~WFpsMax()
Definition: wFpsMax.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::uLongLongRound
unsigned long long uLongLongRound(const T a)
Definition: fastMath.hpp:63
op::Profiler::timerEnd
static void timerEnd(const std::string &key)