GestureRecognitionToolkit  Version: 0.1.0
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 
51 public:
61  ZeroCrossingCounter(UINT searchWindowSize = 20,Float deadZoneThreshold = 0.01,UINT numDimensions = 1,UINT featureMode = INDEPENDANT_FEATURE_MODE);
62 
69 
73  virtual ~ZeroCrossingCounter();
74 
82 
91  virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction);
92 
101  virtual bool computeFeatures(const VectorFloat &inputVector);
102 
110  virtual bool reset();
111 
118  virtual bool saveModelToFile( std::string filename ) const;
119 
126  virtual bool loadModelFromFile( std::string filename );
127 
135  virtual bool saveModelToFile( std::fstream &file ) const;
136 
144  virtual bool loadModelFromFile( std::fstream &file );
145 
157  bool init(UINT searchWindowSize,Float deadZoneThreshold,UINT numDimensions,UINT featureMode);
158 
165  VectorFloat update(Float x);
166 
173  VectorFloat update(const VectorFloat &x);
174 
182  bool setSearchWindowSize(UINT searchWindowSize);
183 
191  bool setFeatureMode(UINT featureMode);
192 
200  bool setDeadZoneThreshold(Float deadZoneThreshold);
201 
207  UINT getSearchWindowSize(){ if( initialized ){ return searchWindowSize; } return 0; }
208 
215  UINT getNumFeatures(){ return TOTAL_NUM_ZERO_CROSSING_FEATURES; }
216 
222  UINT getFeatureMode(){ return featureMode; }
223 
229  Float getDeadZoneThreshold(){ if( initialized ){ return deadZoneThreshold; } return 0; }
230 
238 
239  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
242  using MLBase::train;
243  using MLBase::train_;
244  using MLBase::predict;
245  using MLBase::predict_;
246 
247 protected:
249  UINT featureMode;
254 
256 
257 public:
258  enum ZeroCrossingFeatureIDs{NUM_ZERO_CROSSINGS_COUNTED=0,ZERO_CROSSING_MAGNITUDE,TOTAL_NUM_ZERO_CROSSING_FEATURES};
259  enum FeatureModes{INDEPENDANT_FEATURE_MODE=0,COMBINED_FEATURE_MODE};
260 };
261 
262 GRT_END_NAMESPACE
263 
264 #endif //GRT_ZERO_CROSSING_COUNTER_HEADER
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
bool setDeadZoneThreshold(Float deadZoneThreshold)
DeadZone deadZone
Used to remove small amounts of noise from the data.
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:114
VectorFloat update(Float x)
virtual bool saveModelToFile(std::fstream &file) const
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction)
virtual bool loadModelFromFile(std::fstream &file)
CircularBuffer< VectorFloat > dataBuffer
A buffer used to store the previous derivative data.
CircularBuffer< VectorFloat > getDataBuffer()
virtual bool saveModelToFile(std::string filename) const
UINT searchWindowSize
The size of the search window, i.e. the amount of previous data stored and searched.
ZeroCrossingCounter & operator=(const ZeroCrossingCounter &rhs)
virtual bool computeFeatures(const VectorFloat &inputVector)
UINT featureMode
The featureMode controls how the features are added to the feature vector.
bool setSearchWindowSize(UINT searchWindowSize)
virtual bool loadModelFromFile(std::string filename)
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:90
Float deadZoneThreshold
The threshold value used for the dead zone filter.
Derivative derivative
Used to compute the derivative of the input signal.
bool setFeatureMode(UINT featureMode)
ZeroCrossingCounter(UINT searchWindowSize=20, Float deadZoneThreshold=0.01, UINT numDimensions=1, UINT featureMode=INDEPENDANT_FEATURE_MODE)