GestureRecognitionToolkit  Version: 0.2.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
ClassLabelTimeoutFilter.h
Go to the documentation of this file.
1 
35 #ifndef GRT_CLASS_LABEL_TIMEOUT_FILTER_HEADER
36 #define GRT_CLASS_LABEL_TIMEOUT_FILTER_HEADER
37 
38 #include "../Util/GRTCommon.h"
39 #include "../CoreModules/PostProcessing.h"
40 
41 GRT_BEGIN_NAMESPACE
42 
43 class GRT_API ClassLabelAndTimer{
44 public:
46  classLabel = 0;
47  }
48  ClassLabelAndTimer(UINT classLabel,unsigned long timeoutDuration){
49  this->classLabel = classLabel;
50  timer.start(timeoutDuration);
51  }
52 
53  //Setters
54  bool set(UINT classLabel,unsigned long timeoutDuration){
55  if( classLabel > 0 && timeoutDuration > 0 ){
56  this->classLabel = classLabel;
57  timer.start(timeoutDuration);
58  return true;
59  }
60  return false;
61  }
62 
63  //Getters
64  UINT getClassLabel(){ return classLabel; }
65  bool timerReached(){ return timer.timerReached(); }
66  unsigned long getRemainingTime(){ return timer.getMilliSeconds(); }
67 
68 protected:
69  UINT classLabel;
70  Timer timer;
71 };
72 
73 class GRT_API ClassLabelTimeoutFilter : public PostProcessing{
74 public:
95  ClassLabelTimeoutFilter(unsigned long timeoutDuration = 1000,UINT filterMode = ALL_CLASS_LABELS);
96 
105 
109  virtual ~ClassLabelTimeoutFilter();
110 
117  ClassLabelTimeoutFilter& operator=(const ClassLabelTimeoutFilter &rhs);
118 
127  virtual bool deepCopyFrom(const PostProcessing *postProcessing);
128 
137  virtual bool process(const VectorDouble &inputVector);
138 
146  virtual bool reset();
147 
155  virtual bool saveModelToFile( std::string filename ) const;
156 
164  virtual bool saveModelToFile( std::fstream &file ) const;
165 
173  virtual bool loadModelFromFile( std::string filename );
174 
182  virtual bool loadModelFromFile( std::fstream &file );
183 
191  bool init(unsigned long timeoutDuration,UINT filterMode = ALL_CLASS_LABELS);
192 
199  UINT filter(UINT predictedClassLabel);
200 
206  UINT getFilteredClassLabel(){ return filteredClassLabel; }
207 
213  bool isTimeoutActive();
214 
227  bool setTimeoutDuration(unsigned long timeoutDuration);
228 
248  bool setFilterMode(UINT filterMode);
249 
250  enum FilterModes{ALL_CLASS_LABELS=0,INDEPENDENT_CLASS_LABELS};
251 
252 protected:
253  UINT filteredClassLabel;
254  UINT filterMode;
255  unsigned long timeoutDuration;
256  Vector< ClassLabelAndTimer > classLabelTimers;
257 
259 };
260 
261 GRT_END_NAMESPACE
262 
263 #endif //GRT_CLASS_LABEL_TIMEOUT_FILTER_HEADER
virtual bool deepCopyFrom(const PostProcessing *postProcessing)
Definition: Timer.h:43
virtual bool process(const VectorFloat &inputVector)
virtual bool loadModelFromFile(std::string filename)
virtual bool reset()
bool init()
virtual bool saveModelToFile(std::string filename) const