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.
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 namespace GRT{
38 
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 
71 
80  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
81 
90  virtual bool process(const VectorDouble &inputVector);
91 
99  virtual bool reset();
100 
108  virtual bool saveModelToFile(string filename) const;
109 
117  virtual bool saveModelToFile(fstream &file) const;
118 
126  virtual bool loadModelFromFile(string filename);
127 
135  virtual bool loadModelFromFile(fstream &file);
136 
143  bool init(UINT numLeftHandPoints,UINT numRightHandPoints,UINT derivativeOrder,UINT smoothingPolynomialOrder,UINT numDimensions);
144 
151  double filter(const double x);
152 
159  VectorDouble filter(const VectorDouble &x);
160 
166  VectorDouble getFilteredData() const { return processedData; }
167 
168 protected:
169  inline int min_(int a,int b) {return b < a ? (b) : (a);}
170  inline double min_(double a,double b) {return b < a ? (b) : (a);}
171  bool calCoeff();
172 
173  UINT numPoints; //The physical length of the output array
174  UINT numLeftHandPoints; //Num of leftward (past) points to use
175  UINT numRightHandPoints; //Num of rightward (future) points to use
176  UINT derivativeOrder; //Order of the derivative desired
177  UINT smoothingPolynomialOrder; //Order of smoothing polynomial
178  CircularBuffer< VectorDouble > data; //A buffer to hold the input data
179  VectorDouble yy; //The filtered values
180  VectorDouble coeff; //Buffer for the filter coefficients
181 
182  static RegisterPreProcessingModule< SavitzkyGolayFilter > registerModule;
183 
184 };
185 
186 }//End of namespace GRT
187 
188 #endif //GRT_SAVITZKY_GOLAY_FILTER_HEADER
SavitzkyGolayFilter(UINT numLeftHandPoints=10, UINT numRightHandPoints=10, UINT derivativeOrder=0, UINT smoothingPolynomialOrder=2, UINT numDimensions=1)
Definition: AdaBoost.cpp:25
SavitzkyGolayFilter & operator=(const SavitzkyGolayFilter &rhs)
VectorDouble getFilteredData() const
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
virtual bool saveModelToFile(string filename) const
virtual bool loadModelFromFile(string filename)
virtual bool process(const VectorDouble &inputVector)
double filter(const double x)