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.
SwipeDetector.h
Go to the documentation of this file.
1 
26 #ifndef GRT_SWIPE_DETECTION_HEADER
27 #define GRT_SWIPE_DETECTION_HEADER
28 
29 #include "../../CoreModules/Classifier.h"
30 #include "../../Util/ThresholdCrossingDetector.h"
31 #include "../../PreProcessingModules/MedianFilter.h"
32 
33 GRT_BEGIN_NAMESPACE
34 
40 class GRT_API SwipeDetector : public Classifier
41 {
42 public:
43  enum SwipeDirections{POSITIVE_SWIPE=0,NEGATIVE_SWIPE};
44 
50  SwipeDetector(const unsigned int swipeIndex = 0, const unsigned int swipeThreshold = 100,
51  const unsigned int hysteresisThreshold =0, const unsigned int swipeDirection = POSITIVE_SWIPE,bool useScaling=false);
52 
58  SwipeDetector(const SwipeDetector &rhs);
59 
63  virtual ~SwipeDetector(void);
64 
71  SwipeDetector &operator=(const SwipeDetector &rhs);
72 
80  virtual bool deepCopyFrom(const Classifier *classifier);
81 
82  bool init(const unsigned int numInputDimensions);
83 
91  virtual bool train_(ClassificationData &trainingData);
92 
100  virtual bool predict_(VectorDouble &inputVector);
101 
108  virtual bool clear();
109 
115  virtual bool reset();
116 
124  virtual bool save( std::fstream &file ) const;
125 
133  virtual bool load( std::fstream &file );
134 
138  bool getSwipeDetected() const;
139 
143  Float getSwipeValue() const;
144 
148  Float getSwipeThreshold() const ;
149 
153  Float getHysteresisThreshold() const;
154 
160  Float getMovementVelocity() const;
161 
165  Float getMovementThreshold() const;
166 
170  Float getContextValue() const;
171 
175  Float getSwipeIntegrationCoeff() const;
176 
181  bool setContext(const bool context);
182 
190  bool setSwipeIndex(const unsigned int swipeIndex);
191 
197  bool setSwipeDirection(const unsigned int swipeDirection);
198 
205  bool setSwipeThreshold(const Float swipeThreshold);
206 
213  bool setHysteresisThreshold(const Float hysteresisThreshold);
214 
222  bool setMovementThreshold(const Float movementThreshold);
223 
230  bool setSwipeIntegrationCoeff(const Float swipeIntegrationCoeff);
231 
237  static std::string getId();
238 
239  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
240  using MLBase::save;
241  using MLBase::load;
242  using MLBase::train_;
243  using MLBase::predict_;
244 
245 protected:
246 
247  bool firstSample;
248  bool swipeDetected;
249  bool contextInput;
250  unsigned int swipeIndex;
251  unsigned int swipeDirection;
252  unsigned int contextFilterSize;
253  Float swipeIntegrationCoeff;
254  Float movementIntegrationCoeff;
255  Float swipeThreshold;
256  Float hysteresisThreshold;
257  Float swipeVelocity;
258  Float movementVelocity;
259  Float movementThreshold;
260  Float contextFilteredValue;
261  VectorFloat lastX;
262  GRT::ThresholdCrossingDetector thresholdDetector;
263  GRT::MedianFilter contextFilter;
264 
265 private:
266  static const std::string id;
267  static RegisterClassifierModule< SwipeDetector > registerModule;
268 };
269 
270 GRT_END_NAMESPACE
271 
272 #endif //GRT_SWIPE_DETECTION_HEADER
273 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool deepCopyFrom(const Classifier *classifier)
Definition: Classifier.h:64
virtual bool reset()
Definition: Classifier.cpp:132
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
This class implements a basic swipe detection classification algorithm.
Definition: SwipeDetector.h:40
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
virtual bool clear()
Definition: Classifier.cpp:151
This is the main base class that all GRT Classification algorithms should inherit from...
Definition: Classifier.h:41