ESP  0.1
The Example-based Sensor Predictions (ESP) system tries to bring machine learning to the maker community.
Filter.h
Go to the documentation of this file.
1 
31 #ifndef GRT_FILTER_HEADER
32 #define GRT_FILTER_HEADER
33 
34 #include "GRT/CoreModules/PreProcessing.h"
35 
36 namespace GRT{
37 
38 class Filter : public PreProcessing {
39 public:
47  Filter(const char *classType, UINT filterSize = 5,UINT numDimensions = 1);
48 
54  Filter(const Filter &rhs);
55 
59  virtual ~Filter();
60 
67  Filter& operator=(const Filter &rhs);
68 
77  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
78 
87  virtual bool process(const VectorDouble &inputVector);
88 
96  virtual bool reset();
97 
105  virtual bool saveModelToFile(string filename) const;
106 
114  virtual bool saveModelToFile(fstream &file) const;
115 
123  virtual bool loadModelFromFile(string filename);
124 
132  virtual bool loadModelFromFile(fstream &file);
133 
141  bool init(UINT filterSize,UINT numDimensions);
142 
149  double filter(const double x);
150 
157  VectorDouble filter(const VectorDouble &x);
158 
165  virtual double computeFilter(const VectorDouble &buf) = 0;
166 
172  UINT getFilterSize() const { return filterSize; }
173 
179  VectorDouble getFilteredData() const { return processedData; }
180 
189  vector< VectorDouble > getDataBuffer() const;
190 
191 protected:
192  UINT filterSize;
194  CircularBuffer< VectorDouble > dataBuffer;
195 
196  //static RegisterPreProcessingModule< Filter > registerModule;
197 };
198 
199 }//End of namespace GRT
200 
201 #endif //GRT_FILTER_HEADER
CircularBuffer< VectorDouble > dataBuffer
A buffer to store the previous N values, N = filterSize.
Definition: Filter.h:194
double filter(const double x)
Definition: Filter.cpp:247
UINT getFilterSize() const
Definition: Filter.h:172
virtual ~Filter()
Definition: Filter.cpp:54
vector< VectorDouble > getDataBuffer() const
Definition: Filter.cpp:284
UINT inputSampleCounter
A counter to keep track of the number of input samples.
Definition: Filter.h:193
Definition: Filter.cpp:23
virtual bool process(const VectorDouble &inputVector)
Definition: Filter.cpp:95
VectorDouble getFilteredData() const
Definition: Filter.h:179
virtual bool loadModelFromFile(string filename)
Definition: Filter.cpp:155
virtual double computeFilter(const VectorDouble &buf)=0
bool init(UINT filterSize, UINT numDimensions)
Definition: Filter.cpp:216
Filter(const char *classType, UINT filterSize=5, UINT numDimensions=1)
Definition: Filter.cpp:28
UINT filterSize
The size of the filter.
Definition: Filter.h:192
Definition: Filter.h:38
Filter & operator=(const Filter &rhs)
Definition: Filter.cpp:58
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
Definition: Filter.cpp:77
virtual bool saveModelToFile(string filename) const
Definition: Filter.cpp:119
virtual bool reset()
Definition: Filter.cpp:114