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.
FiniteStateMachine.h
Go to the documentation of this file.
1 
26 #ifndef GRT_FINITE_STATE_MACHINE_HEADER
27 #define GRT_FINITE_STATE_MACHINE_HEADER
28 
29 #include "../../CoreModules/Classifier.h"
30 #include "FSMParticleFilter.h"
31 #include "../../ClusteringModules/KMeans/KMeans.h"
32 
33 GRT_BEGIN_NAMESPACE
34 
35 class GRT_API FiniteStateMachine : public Classifier
36 {
37 public:
38 
43  FiniteStateMachine(const UINT numParticles = 200,const UINT numClustersPerState = 20,const Float stateTransitionSmoothingCoeff = 0.0,const Float measurementNoise = 10.0);
44 
51 
55  virtual ~FiniteStateMachine(void);
56 
63  FiniteStateMachine &operator=(const FiniteStateMachine &rhs);
64 
72  virtual bool deepCopyFrom(const Classifier *classifier);
73 
82  virtual bool train_( ClassificationData &trainingData );
83 
92  virtual bool train_( TimeSeriesClassificationData &trainingData );
93 
101  virtual bool train_( TimeSeriesClassificationDataStream &data );
102 
110  virtual bool predict_(VectorFloat &inputVector);
111 
119  virtual bool reset();
120 
127  virtual bool clear();
128 
135  virtual bool print() const;
136 
144  virtual bool save( std::fstream &file ) const;
145 
153  virtual bool load( std::fstream &file );
154 
155 
156  bool setNumParticles(const UINT numParticles);
157  bool setNumClustersPerState(const UINT numClustersPerState);
158  bool setStateTransitionSmoothingCoeff(const Float stateTransitionSmoothingCoeff);
159  bool setMeasurementNoise(const Float measurementNoise);
160 
166  static std::string getId();
167 
168  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
169  using MLBase::save;
170  using MLBase::load;
171  using MLBase::train_;
172  using MLBase::predict_;
173 
174 protected:
175  bool recomputePT();
176  bool recomputePE();
177  bool initParticles();
178 
179  UINT numParticles;
180  UINT numClustersPerState;
181  Float stateTransitionSmoothingCoeff;
182  Float measurementNoise;
183  FSMParticleFilter particles;
184  MatrixFloat stateTransitions;
185  Vector< MatrixFloat > stateEmissions;
188 
189 private:
191  static const std::string id;
192 };
193 
194 GRT_END_NAMESPACE
195 
196 #endif
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 print() const
Definition: MLBase.cpp:165
Vector< Vector< IndexedDouble > > pt
This stores the stateTransitions matrix in a format more efficient for the particle filter...
virtual bool reset()
Definition: Classifier.cpp:132
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
Vector< Vector< VectorFloat > > pe
This stores the stateEmissions model in a format more efficient for the particle filter.
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