GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
ZeroCrossingCounter.h
Go to the documentation of this file.
1 
41 #ifndef GRT_ZERO_CROSSING_COUNTER_HEADER
42 #define GRT_ZERO_CROSSING_COUNTER_HEADER
43 
44 #include "../../CoreModules/FeatureExtraction.h"
45 #include "../../PreProcessingModules/Derivative.h"
46 #include "../../PreProcessingModules/DeadZone.h"
47 
48 GRT_BEGIN_NAMESPACE
49 
50 class GRT_API ZeroCrossingCounter : public FeatureExtraction{
51 public:
52  enum ZeroCrossingFeatureIDs{NUM_ZERO_CROSSINGS_COUNTED=0,ZERO_CROSSING_MAGNITUDE,TOTAL_NUM_ZERO_CROSSING_FEATURES};
53  enum FeatureModes{INDEPENDANT_FEATURE_MODE=0,COMBINED_FEATURE_MODE};
54 
64  ZeroCrossingCounter(const UINT searchWindowSize = 20,const Float deadZoneThreshold = 0.01,const UINT numDimensions = 1,const UINT featureMode = INDEPENDANT_FEATURE_MODE);
65 
72 
76  virtual ~ZeroCrossingCounter();
77 
84  ZeroCrossingCounter& operator=(const ZeroCrossingCounter &rhs);
85 
94  virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction);
95 
104  virtual bool computeFeatures(const VectorFloat &inputVector);
105 
113  virtual bool reset();
114 
122  virtual bool save( std::fstream &file ) const;
123 
131  virtual bool load( std::fstream &file );
132 
144  bool init(const UINT searchWindowSize,const Float deadZoneThreshold,const UINT numDimensions,const UINT featureMode);
145 
152  VectorFloat update(const Float x);
153 
160  VectorFloat update(const VectorFloat &x);
161 
169  bool setSearchWindowSize(const UINT searchWindowSize);
170 
178  bool setFeatureMode(const UINT featureMode);
179 
187  bool setDeadZoneThreshold(const Float deadZoneThreshold);
188 
194  UINT getSearchWindowSize() const { if( initialized ){ return searchWindowSize; } return 0; }
195 
202  UINT getNumFeatures() const { return TOTAL_NUM_ZERO_CROSSING_FEATURES; }
203 
209  UINT getFeatureMode() const { return featureMode; }
210 
216  Float getDeadZoneThreshold() const { if( initialized ){ return deadZoneThreshold; } return 0; }
217 
224  CircularBuffer< VectorFloat > getDataBuffer() const { if( initialized ){ return dataBuffer; } return CircularBuffer< VectorFloat >(); }
225 
226  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
227  using MLBase::save;
228  using MLBase::load;
229  using MLBase::train;
230  using MLBase::train_;
231  using MLBase::predict;
232  using MLBase::predict_;
233 
239  static std::string getId();
240 
241 protected:
243  UINT featureMode;
248 
249 private:
251  static std::string id;
252 
253 };
254 
255 GRT_END_NAMESPACE
256 
257 #endif //GRT_ZERO_CROSSING_COUNTER_HEADER
258 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:135
CircularBuffer< VectorFloat > getDataBuffer() const
DeadZone deadZone
Used to remove small amounts of noise from the data.
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
virtual bool reset()
Definition: MLBase.cpp:147
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:107
UINT getNumFeatures() const
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
The DeadZone class sets any values in the input signal that fall within the dead-zone region to zero...
Definition: DeadZone.h:38
CircularBuffer< VectorFloat > dataBuffer
A buffer used to store the previous derivative data.
virtual bool computeFeatures(const VectorFloat &inputVector)
UINT searchWindowSize
The size of the search window, i.e. the amount of previous data stored and searched.
The Derivative class computes either the first or second order derivative of the input signal...
Definition: Derivative.h:39
UINT featureMode
The featureMode controls how the features are added to the feature vector.
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
UINT getFeatureMode() const
Float deadZoneThreshold
The threshold value used for the dead zone filter.
Derivative derivative
Used to compute the derivative of the input signal.
UINT getSearchWindowSize() const
Float getDeadZoneThreshold() const
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
virtual bool deepCopyFrom(const FeatureExtraction *rhs)