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.
Derivative.h
Go to the documentation of this file.
1 
28 #ifndef GRT_DERIVATIVE_HEADER
29 #define GRT_DERIVATIVE_HEADER
30 
31 #include "../CoreModules/PreProcessing.h"
32 #include "MovingAverageFilter.h"
33 
34 GRT_BEGIN_NAMESPACE
35 
39 class GRT_API Derivative : public PreProcessing{
40 public:
41  enum DerivativeOrders{FIRST_DERIVATIVE=1,SECOND_DERIVATIVE};
42 
53  Derivative(const UINT derivativeOrder=FIRST_DERIVATIVE,const Float delta = 1,const UINT numDimensions = 1,const bool filterData = true,const 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(const UINT derivativeOrder,const Float delta,const UINT numDimensions,const bool filterData,const UINT filterSize);
134 
141  Float computeDerivative(const Float x);
142 
149  VectorFloat computeDerivative(const VectorFloat &x);
150 
158  bool setDerivativeOrder(const UINT derivativeOrder);
159 
168  bool setFilterSize(const UINT filterSize);
169 
179  bool setDelta(const Float delta);
180 
188  bool enableFiltering(const bool filterData);
189 
195  UINT getFilterSize() const;
196 
204  Float getDerivative(const UINT derivativeOrder = FIRST_DERIVATIVE) const;
205 
213  VectorFloat getDerivatives(const UINT derivativeOrder = FIRST_DERIVATIVE) const;
214 
220  static std::string getId();
221 
222  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
223  using MLBase::save;
224  using MLBase::load;
225  using MLBase::train;
226  using MLBase::train_;
227  using MLBase::predict;
228  using MLBase::predict_;
229 
230 protected:
232  UINT filterSize;
233  Float delta;
234  bool filterData;
238 
239 private:
240  static const std::string id;
241  static RegisterPreProcessingModule< Derivative > registerModule;
242 
243 };
244 
245 GRT_END_NAMESPACE
246 
247 #endif //GRT_DERIVATIVE_HEADER
248 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:135
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:58
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
The MovingAverageFilter implements a low pass moving average filter.
UINT filterSize
The size of the filter used to filter the input data before the derivative is computed.
Definition: Derivative.h:232
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:107
VectorFloat yy
A buffer holding the previous input value(s)
Definition: Derivative.h:236
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool reset() override
VectorFloat yyy
A buffer holding the previous first derivative values.
Definition: Derivative.h:237
bool filterData
Flags if the input data should be filtered before the derivative is computed.
Definition: Derivative.h:234
The Derivative class computes either the first or second order derivative of the input signal...
Definition: Derivative.h:39
Float delta
The estimated time between sensor samples.
Definition: Derivative.h:233
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:74
UINT derivativeOrder
The order of the derivative that will be computed (either FIRST_DERIVATIVE or SECOND_DERIVATIVE) ...
Definition: Derivative.h:231
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
MovingAverageFilter filter
The filter used to low pass filter the input data.
Definition: Derivative.h:235