GestureRecognitionToolkit  Version: 0.1.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 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 
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 saveModelToFile( std::fstream &file ) const;
123 
131  virtual bool loadModelFromFile( 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 protected:
231 
232  bool firstSample;
233  bool swipeDetected;
234  bool contextInput;
235  unsigned int swipeIndex;
236  unsigned int swipeDirection;
237  unsigned int contextFilterSize;
238  Float swipeIntegrationCoeff;
239  Float movementIntegrationCoeff;
240  Float swipeThreshold;
241  Float hysteresisThreshold;
242  Float swipeVelocity;
243  Float movementVelocity;
244  Float movementThreshold;
245  Float contextFilteredValue;
246  VectorFloat lastX;
247  GRT::ThresholdCrossingDetector thresholdDetector;
248  GRT::MedianFilter contextFilter;
249 
250  static RegisterClassifierModule< SwipeDetector > registerModule;
251 
252 public:
253  enum SwipeDirections{POSITIVE_SWIPE=0,NEGATIVE_SWIPE};
254 };
255 
256 GRT_END_NAMESPACE
257 
258 #endif //GRT_SWIPE_DETECTION_HEADER
259 
virtual bool predict_(VectorDouble &inputVector)
virtual bool reset()
bool setMovementThreshold(const Float movementThreshold)
bool setSwipeIntegrationCoeff(const Float swipeIntegrationCoeff)
Float getHysteresisThreshold() const
virtual bool clear()
SwipeDetector(const unsigned int swipeIndex=0, const unsigned int swipeThreshold=100, const unsigned int hysteresisThreshold=0, const unsigned int swipeDirection=POSITIVE_SWIPE, bool useScaling=false)
virtual ~SwipeDetector(void)
bool setContext(const bool context)
bool setSwipeThreshold(const Float swipeThreshold)
Float getContextValue() const
Float getMovementVelocity() const
virtual bool loadModelFromFile(std::fstream &file)
bool setSwipeDirection(const unsigned int swipeDirection)
Float getMovementThreshold() const
SwipeDetector & operator=(const SwipeDetector &rhs)
bool getSwipeDetected() const
bool setHysteresisThreshold(const Float hysteresisThreshold)
virtual bool deepCopyFrom(const Classifier *classifier)
virtual bool saveModelToFile(std::fstream &file) const
Float getSwipeIntegrationCoeff() const
virtual bool train_(ClassificationData &trainingData)
Float getSwipeThreshold() const
Float getSwipeValue() const
bool setSwipeIndex(const unsigned int swipeIndex)