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.
MedianFilter.h
Go to the documentation of this file.
1 
28 #ifndef GRT_MEDIAN_FILTER_HEADER
29 #define GRT_MEDIAN_FILTER_HEADER
30 
31 #include "../CoreModules/PreProcessing.h"
32 
33 GRT_BEGIN_NAMESPACE
34 
38 class GRT_API MedianFilter : public PreProcessing {
39  public:
46  MedianFilter(const UINT filterSize = 5,const UINT numDimensions = 1);
47 
53  MedianFilter(const MedianFilter &rhs);
54 
58  virtual ~MedianFilter();
59 
66  MedianFilter& operator=(const MedianFilter &rhs);
67 
76  virtual bool deepCopyFrom(const PreProcessing *preProcessing);
77 
86  virtual bool process(const VectorFloat &inputVector);
87 
95  virtual bool reset();
96 
104  virtual bool save( std::fstream &file) const;
105 
113  virtual bool load( std::fstream &file );
114 
122  bool init(const UINT filterSize,const UINT numDimensions);
123 
130  Float filter(const Float x);
131 
138  VectorFloat filter(const VectorFloat &x);
139 
145  UINT getFilterSize() const;
146 
152  VectorFloat getFilteredData() const;
153 
162  Vector< VectorFloat > getDataBuffer() const;
163 
169  static std::string getId();
170 
171  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
172  using MLBase::save;
173  using MLBase::load;
174 
175 protected:
176  UINT filterSize;
179 
180 private:
181  static const std::string id;
182  static RegisterPreProcessingModule< MedianFilter > registerModule;
183 };
184 
185 GRT_END_NAMESPACE
186 
187 #endif //GRT_MEDIAN_FILTER_HEADER
188 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:58
CircularBuffer< VectorFloat > dataBuffer
A buffer to store the previous N values, N = filterSize.
Definition: MedianFilter.h:178
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool reset() override
The MedianFilter implements a simple median filter: https://en.wikipedia.org/wiki/Median_filter.
Definition: MedianFilter.h:38
UINT filterSize
The size of the filter.
Definition: MedianFilter.h:176
UINT inputSampleCounter
A counter to keep track of the number of input samples.
Definition: MedianFilter.h:177
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:74
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190