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.
Derivative.h
Go to the documentation of this file.
1 
31 #ifndef GRT_DERIVATIVE_HEADER
32 #define GRT_DERIVATIVE_HEADER
33 
34 #include "../CoreModules/PreProcessing.h"
35 #include "MovingAverageFilter.h"
36 
37 GRT_BEGIN_NAMESPACE
38 
39 class GRT_API Derivative : public PreProcessing{
40 public:
41  enum DerivativeOrders{FIRST_DERIVATIVE=1,SECOND_DERIVATIVE};
42 
53  Derivative(UINT derivativeOrder=FIRST_DERIVATIVE,Float delta = 1,UINT numDimensions = 1,bool filterData = true,UINT filterSize = 3);
54 
60  Derivative(const Derivative &rhs);
61 
65  virtual ~Derivative();
66 
73  Derivative& operator=(const Derivative &rhs);
74 
83  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
84 
93  virtual bool process(const VectorFloat &inputVector);
94 
102  virtual bool reset();
103 
111  virtual bool save(std::fstream &file) const;
112 
120  virtual bool load(std::fstream &file);
121 
133  bool init(UINT derivativeOrder,Float delta,UINT numDimensions,bool filterData,UINT filterSize);
134 
141  Float computeDerivative(const Float x);
142 
149  VectorFloat computeDerivative(const VectorFloat &x);
150 
158  bool setDerivativeOrder(UINT derivativeOrder);
159 
168  bool setFilterSize(UINT filterSize);
169 
179  bool setDelta(Float delta);
180 
188  bool enableFiltering(bool filterData);
189 
195  UINT getFilterSize(){ if( initialized ){ return filterSize; } return 0; }
196 
204  Float getDerivative(UINT derivativeOrder = FIRST_DERIVATIVE);
205 
213  VectorFloat getDerivatives(UINT derivativeOrder = FIRST_DERIVATIVE);
214 
215  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
216  using MLBase::save;
217  using MLBase::load;
218  using MLBase::train;
219  using MLBase::train_;
220  using MLBase::predict;
221  using MLBase::predict_;
222 
223 protected:
225  UINT filterSize;
226  Float delta;
227  bool filterData;
231 
232  static RegisterPreProcessingModule< Derivative > registerModule;
233 
234 };
235 
236 GRT_END_NAMESPACE
237 
238 #endif //GRT_DERIVATIVE_HEADER
239 
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:113
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:57
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:115
UINT filterSize
The size of the filter used to filter the input data before the derivative is computed.
Definition: Derivative.h:225
The MovingAverageFilter implements a low pass moving average filter.
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:89
VectorFloat yy
A buffer holding the previous input value(s)
Definition: Derivative.h:229
VectorFloat yyy
A buffer holding the previous first derivative values.
Definition: Derivative.h:230
virtual bool save(const std::string filename) const
Definition: MLBase.cpp:143
virtual bool reset()
virtual bool load(const std::string filename)
Definition: MLBase.cpp:167
bool filterData
Flags if the input data should be filtered before the derivative is computed.
Definition: Derivative.h:227
Float delta
The estimated time between sensor samples.
Definition: Derivative.h:226
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:91
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:73
UINT derivativeOrder
The order of the derivative that will be computed (either FIRST_DERIVATIVE or SECOND_DERIVATIVE) ...
Definition: Derivative.h:224
UINT getFilterSize()
Definition: Derivative.h:195
MovingAverageFilter filter
The filter used to low pass filter the input data.
Definition: Derivative.h:228