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.
WeightedAverageFilter.h
Go to the documentation of this file.
1 
27 #ifndef GRT_WEIGHTED_AVERAGE_FILTER_HEADER
28 #define GRT_WEIGHTED_AVERAGE_FILTER_HEADER
29 
30 #include "../CoreModules/PreProcessing.h"
31 
32 GRT_BEGIN_NAMESPACE
33 
37 class GRT_API WeightedAverageFilter : public PreProcessing {
38 public:
45  WeightedAverageFilter(const UINT filterSize = 5,const UINT numDimensions = 1);
46 
53 
57  virtual ~WeightedAverageFilter();
58 
65  WeightedAverageFilter& operator=(const WeightedAverageFilter &rhs);
66 
75  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
76 
85  virtual bool process(const VectorFloat &inputVector);
86 
94  virtual bool reset();
95 
103  virtual bool save( std::fstream &file ) const;
104 
112  virtual bool load( std::fstream &file );
113 
121  bool init(const UINT filterSize,const UINT numDimensions);
122 
129  Float filter(const Float x);
130 
137  VectorFloat filter(const VectorFloat &x);
138 
144  UINT getFilterSize() const;
145 
150  VectorFloat getFilteredData() const;
151 
157  static std::string getId();
158 
159  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
160  using MLBase::save;
161  using MLBase::load;
162 
163 protected:
164  UINT filterSize;
168 
169 private:
170  static const std::string id;
172 };
173 
174 GRT_END_NAMESPACE
175 
176 #endif //GRT_MOVING_AVERAGE_FILTER_HEADER
177 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:58
UINT inputSampleCounter
A counter to keep track of the number of input samples.
CircularBuffer< VectorFloat > dataBuffer
A buffer to store the previous N values, N = filterSize.
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool reset() override
The WeightedAverageFilter implements a weighted average filter that gives a larger weight to more rec...
UINT filterSize
The size of the filter.
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:74
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
VectorFloat weights
Stores the weights for each sample in the buffer, the size of this vector will match the filterSize...