GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
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 namespace GRT{
42 
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 
74 
76 public:
97  ClassLabelTimeoutFilter(unsigned long timeoutDuration = 1000,UINT filterMode = ALL_CLASS_LABELS);
98 
107 
111  virtual ~ClassLabelTimeoutFilter();
112 
120 
129  virtual bool deepCopyFrom(const PostProcessing *postProcessing);
130 
139  virtual bool process(const VectorDouble &inputVector);
140 
148  virtual bool reset();
149 
157  virtual bool saveModelToFile(string filename) const;
158 
166  virtual bool saveModelToFile(fstream &file) const;
167 
175  virtual bool loadModelFromFile(string filename);
176 
184  virtual bool loadModelFromFile(fstream &file);
185 
193  bool init(unsigned long timeoutDuration,UINT filterMode = ALL_CLASS_LABELS);
194 
201  UINT filter(UINT predictedClassLabel);
202 
208  UINT getFilteredClassLabel(){ return filteredClassLabel; }
209 
215  bool isTimeoutActive();
216 
229  bool setTimeoutDuration(unsigned long timeoutDuration);
230 
250  bool setFilterMode(UINT filterMode);
251 
252  enum FilterModes{ALL_CLASS_LABELS=0,INDEPENDENT_CLASS_LABELS};
253 
254 protected:
255  UINT filteredClassLabel;
256  UINT filterMode;
257  unsigned long timeoutDuration;
258  vector< ClassLabelAndTimer > classLabelTimers;
259 
260  static RegisterPostProcessingModule< ClassLabelTimeoutFilter > registerModule;
261 };
262 
263 }//End of namespace GRT
264 
265 #endif //GRT_CLASS_LABEL_TIMEOUT_FILTER_HEADER
virtual bool loadModelFromFile(string filename)
ClassLabelTimeoutFilter & operator=(const ClassLabelTimeoutFilter &rhs)
Definition: AdaBoost.cpp:25
virtual bool deepCopyFrom(const PostProcessing *postProcessing)
bool init()
UINT filter(UINT predictedClassLabel)
bool start()
Definition: Timer.h:59
signed long getMilliSeconds() const
Definition: Timer.h:100
bool timerReached() const
Definition: Timer.h:156
virtual bool process(const VectorDouble &inputVector)
virtual bool saveModelToFile(string filename) const
bool setTimeoutDuration(unsigned long timeoutDuration)
ClassLabelTimeoutFilter(unsigned long timeoutDuration=1000, UINT filterMode=ALL_CLASS_LABELS)