GestureRecognitionToolkit  Version: 0.2.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
SwipeDetector.h
Go to the documentation of this file.
1 
31 #ifndef GRT_SWIPE_DETECTION_HEADER
32 #define GRT_SWIPE_DETECTION_HEADER
33 
34 #include "../../CoreModules/Classifier.h"
35 #include "../../Util/ThresholdCrossingDetector.h"
36 #include "../../PreProcessingModules/MedianFilter.h"
37 
38 GRT_BEGIN_NAMESPACE
39 
40 class GRT_API SwipeDetector : public Classifier
41 {
42 public:
48  SwipeDetector(const unsigned int swipeIndex = 0, const unsigned int swipeThreshold = 100,
49  const unsigned int hysteresisThreshold =0, const unsigned int swipeDirection = POSITIVE_SWIPE,bool useScaling=false);
50 
56  SwipeDetector(const SwipeDetector &rhs);
57 
61  virtual ~SwipeDetector(void);
62 
69  SwipeDetector &operator=(const SwipeDetector &rhs);
70 
78  virtual bool deepCopyFrom(const Classifier *classifier);
79 
80  bool init(const unsigned int numInputDimensions);
81 
89  virtual bool train_(ClassificationData &trainingData);
90 
98  virtual bool predict_(VectorDouble &inputVector);
99 
106  virtual bool clear();
107 
113  virtual bool reset();
114 
122  virtual bool save( std::fstream &file ) const;
123 
131  virtual bool load( std::fstream &file );
132 
136  bool getSwipeDetected() const;
137 
141  Float getSwipeValue() const;
142 
146  Float getSwipeThreshold() const ;
147 
151  Float getHysteresisThreshold() const;
152 
158  Float getMovementVelocity() const;
159 
163  Float getMovementThreshold() const;
164 
168  Float getContextValue() const;
169 
173  Float getSwipeIntegrationCoeff() const;
174 
179  bool setContext(const bool context);
180 
188  bool setSwipeIndex(const unsigned int swipeIndex);
189 
195  bool setSwipeDirection(const unsigned int swipeDirection);
196 
203  bool setSwipeThreshold(const Float swipeThreshold);
204 
211  bool setHysteresisThreshold(const Float hysteresisThreshold);
212 
220  bool setMovementThreshold(const Float movementThreshold);
221 
228  bool setSwipeIntegrationCoeff(const Float swipeIntegrationCoeff);
229 
230  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
231  using MLBase::save;
232  using MLBase::load;
233  using MLBase::train_;
234  using MLBase::predict_;
235 
236 protected:
237 
238  bool firstSample;
239  bool swipeDetected;
240  bool contextInput;
241  unsigned int swipeIndex;
242  unsigned int swipeDirection;
243  unsigned int contextFilterSize;
244  Float swipeIntegrationCoeff;
245  Float movementIntegrationCoeff;
246  Float swipeThreshold;
247  Float hysteresisThreshold;
248  Float swipeVelocity;
249  Float movementVelocity;
250  Float movementThreshold;
251  Float contextFilteredValue;
252  VectorFloat lastX;
253  GRT::ThresholdCrossingDetector thresholdDetector;
254  GRT::MedianFilter contextFilter;
255 
256  static RegisterClassifierModule< SwipeDetector > registerModule;
257 
258 public:
259  enum SwipeDirections{POSITIVE_SWIPE=0,NEGATIVE_SWIPE};
260 };
261 
262 GRT_END_NAMESPACE
263 
264 #endif //GRT_SWIPE_DETECTION_HEADER
265 
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:115
virtual bool save(const std::string filename) const
Definition: MLBase.cpp:143
virtual bool load(const std::string filename)
Definition: MLBase.cpp:167
virtual bool deepCopyFrom(const Classifier *classifier)
Definition: Classifier.h:63
virtual bool reset()
Definition: Classifier.cpp:123
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:91
virtual bool clear()
Definition: Classifier.cpp:142