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.
SavitzkyGolayFilter.h
Go to the documentation of this file.
1 
31 #ifndef GRT_SAVITZKY_GOLAY_FILTER_HEADER
32 #define GRT_SAVITZKY_GOLAY_FILTER_HEADER
33 
34 #include "../CoreModules/PreProcessing.h"
35 #include "../Util/LUDecomposition.h"
36 
37 GRT_BEGIN_NAMESPACE
38 
39 class GRT_API SavitzkyGolayFilter : public PreProcessing{
40 public:
50  SavitzkyGolayFilter(UINT numLeftHandPoints=10,UINT numRightHandPoints=10,UINT derivativeOrder=0,UINT smoothingPolynomialOrder=2,UINT numDimensions = 1);
51 
58 
62  virtual ~SavitzkyGolayFilter();
63 
70  SavitzkyGolayFilter& operator=(const SavitzkyGolayFilter &rhs);
71 
80  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
81 
90  virtual bool process(const VectorFloat &inputVector);
91 
99  virtual bool reset();
100 
108  virtual bool save(std::fstream &file) const;
109 
117  virtual bool load(std::fstream &file);
118 
125  bool init(UINT numLeftHandPoints,UINT numRightHandPoints,UINT derivativeOrder,UINT smoothingPolynomialOrder,UINT numDimensions);
126 
133  Float filter(const Float x);
134 
141  VectorFloat filter(const VectorFloat &x);
142 
148  VectorFloat getFilteredData() const { return processedData; }
149 
150  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
151  using MLBase::save;
152  using MLBase::load;
153 
154 protected:
155  inline int min_(int a,int b) {return b < a ? (b) : (a);}
156  inline Float min_(Float a,Float b) {return b < a ? (b) : (a);}
157  bool calCoeff();
158 
159  UINT numPoints; //The physical length of the output array
160  UINT numLeftHandPoints; //Num of leftward (past) points to use
161  UINT numRightHandPoints; //Num of rightward (future) points to use
162  UINT derivativeOrder; //Order of the derivative desired
163  UINT smoothingPolynomialOrder; //Order of smoothing polynomial
164  CircularBuffer< VectorFloat > data; //A buffer to hold the input data
165  VectorFloat yy; //The filtered values
166  VectorFloat coeff; //Buffer for the filter coefficients
167 
169 
170 };
171 
172 GRT_END_NAMESPACE
173 
174 #endif //GRT_SAVITZKY_GOLAY_FILTER_HEADER
175 
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:57
VectorFloat getFilteredData() const
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
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:73