Image Component Library (ICL)
FPSLimiter.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLUtils/src/ICLUtils/FPSLimiter.h **
10 ** Module : ICLUtils **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Time.h>
35 #include <ICLUtils/FPSEstimator.h>
36 
37 namespace icl{
38  namespace utils{
39 
40 
43  float m_maxFPS;
44  mutable Time m_lastTime;
45  mutable bool m_waitOff;
46 
47  public:
49  FPSLimiter(float maxFPS, int fpsEstimationInterval=10);
50 
52  virtual ~FPSLimiter() {}
53 
55  void setMaxFPS(float maxFPS) { m_maxFPS = maxFPS; }
56 
58  float getMaxFPS() const { return m_maxFPS; }
59 
61 
62  float wait() const;
63 
65  virtual void tic() const;
66 
68  virtual float getFPSVal() const;
69 
71  virtual std::string getFPSString(const std::string &fmt="%3.4f fps", int bufferSize=30) const;
72 
74  virtual void showFPS(const std::string &text="") const;
75  };
76  } // namespace utils
77 }
78 
undocument this line if you encounter any issues!
Definition: Any.h:37
void setMaxFPS(float maxFPS)
sets max fps value
Definition: FPSLimiter.h:55
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
ICL Time class (taken from the Ice lib)
Definition: Time.h:52
An fps limiter can be used to limit online applications FPS.
Definition: FPSLimiter.h:42
bool m_waitOff
Definition: FPSLimiter.h:45
virtual ~FPSLimiter()
virtual destructor
Definition: FPSLimiter.h:52
Time m_lastTime
Definition: FPSLimiter.h:44
float m_maxFPS
Definition: FPSLimiter.h:43
ICLQt_API void tic(const std::string &label="")
starts a timer
float getMaxFPS() const
returns max fps value
Definition: FPSLimiter.h:58
Utility clas for online FPS estimation.
Definition: FPSEstimator.h:41