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