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.
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 
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 VectorFloat &inputVector);
91 
99  virtual bool reset();
100 
108  virtual bool saveModelToFile(std::string filename) const;
109 
117  virtual bool saveModelToFile(std::fstream &file) const;
118 
126  virtual bool loadModelFromFile(std::string filename);
127 
135  virtual bool loadModelFromFile(std::fstream &file);
136 
143  bool init(UINT numLeftHandPoints,UINT numRightHandPoints,UINT derivativeOrder,UINT smoothingPolynomialOrder,UINT numDimensions);
144 
151  Float filter(const Float x);
152 
159  VectorFloat filter(const VectorFloat &x);
160 
166  VectorFloat getFilteredData() const { return processedData; }
167 
168 protected:
169  inline int min_(int a,int b) {return b < a ? (b) : (a);}
170  inline Float min_(Float a,Float 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< VectorFloat > data; //A buffer to hold the input data
179  VectorFloat yy; //The filtered values
180  VectorFloat coeff; //Buffer for the filter coefficients
181 
183 
184 };
185 
186 GRT_END_NAMESPACE
187 
188 #endif //GRT_SAVITZKY_GOLAY_FILTER_HEADER
virtual bool loadModelFromFile(std::string filename)
Float filter(const Float x)
virtual bool saveModelToFile(std::string filename) const
VectorFloat getFilteredData() const
SavitzkyGolayFilter(UINT numLeftHandPoints=10, UINT numRightHandPoints=10, UINT derivativeOrder=0, UINT smoothingPolynomialOrder=2, UINT numDimensions=1)
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
SavitzkyGolayFilter & operator=(const SavitzkyGolayFilter &rhs)
virtual bool process(const VectorFloat &inputVector)