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.
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 Derivative : public PreProcessing{
40 public:
51  Derivative(UINT derivativeOrder=FIRST_DERIVATIVE,Float delta = 1,UINT numDimensions = 1,bool filterData = true,UINT filterSize = 3);
52 
58  Derivative(const Derivative &rhs);
59 
63  virtual ~Derivative();
64 
71  Derivative& operator=(const Derivative &rhs);
72 
81  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
82 
91  virtual bool process(const VectorFloat &inputVector);
92 
100  virtual bool reset();
101 
109  virtual bool saveModelToFile(std::string filename) const;
110 
118  virtual bool saveModelToFile(std::fstream &file) const;
119 
127  virtual bool loadModelFromFile(std::string filename);
128 
136  virtual bool loadModelFromFile(std::fstream &file);
137 
149  bool init(UINT derivativeOrder,Float delta,UINT numDimensions,bool filterData,UINT filterSize);
150 
157  Float computeDerivative(const Float x);
158 
166 
174  bool setDerivativeOrder(UINT derivativeOrder);
175 
184  bool setFilterSize(UINT filterSize);
185 
195  bool setDelta(Float delta);
196 
204  bool enableFiltering(bool filterData);
205 
211  UINT getFilterSize(){ if( initialized ){ return filterSize; } return 0; }
212 
220  Float getDerivative(UINT derivativeOrder = 0);
221 
229  VectorFloat getDerivatives(UINT derivativeOrder = 0);
230 
231 protected:
233  UINT filterSize;
234  Float delta;
235  bool filterData;
239 
240  static RegisterPreProcessingModule< Derivative > registerModule;
241 
242 public:
243  enum DerivativeOrders{FIRST_DERIVATIVE=1,SECOND_DERIVATIVE};
244 
245 };
246 
247 GRT_END_NAMESPACE
248 
249 #endif //GRT_DERIVATIVE_HEADER
bool setDelta(Float delta)
UINT filterSize
The size of the filter used to filter the input data before the derivative is computed.
Definition: Derivative.h:233
bool setDerivativeOrder(UINT derivativeOrder)
Definition: Derivative.cpp:338
The MovingAverageFilter implements a low pass moving average filter.
VectorFloat yy
A buffer holding the previous input value(s)
Definition: Derivative.h:237
Float getDerivative(UINT derivativeOrder=0)
Definition: Derivative.cpp:364
VectorFloat yyy
A buffer holding the previous first derivative values.
Definition: Derivative.h:238
Float computeDerivative(const Float x)
Definition: Derivative.cpp:290
virtual bool loadModelFromFile(std::string filename)
Definition: Derivative.cpp:164
virtual bool reset()
Definition: Derivative.cpp:120
Derivative & operator=(const Derivative &rhs)
Definition: Derivative.cpp:62
VectorFloat getDerivatives(UINT derivativeOrder=0)
Definition: Derivative.cpp:384
virtual bool process(const VectorFloat &inputVector)
Definition: Derivative.cpp:102
bool filterData
Flags if the input data should be filtered before the derivative is computed.
Definition: Derivative.h:235
Float delta
The estimated time between sensor samples.
Definition: Derivative.h:234
virtual bool saveModelToFile(std::string filename) const
Definition: Derivative.cpp:125
virtual ~Derivative()
Definition: Derivative.cpp:58
bool enableFiltering(bool filterData)
Definition: Derivative.cpp:358
UINT derivativeOrder
The order of the derivative that will be computed (either FIRST_DERIVATIVE or SECOND_DERIVATIVE) ...
Definition: Derivative.h:232
UINT getFilterSize()
Definition: Derivative.h:211
Derivative(UINT derivativeOrder=FIRST_DERIVATIVE, Float delta=1, UINT numDimensions=1, bool filterData=true, UINT filterSize=3)
Definition: Derivative.cpp:28
bool setFilterSize(UINT filterSize)
Definition: Derivative.cpp:348
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
Definition: Derivative.cpp:76
MovingAverageFilter filter
The filter used to low pass filter the input data.
Definition: Derivative.h:236