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.
PreProcessing.h
Go to the documentation of this file.
1 
31 #ifndef GRT_PRE_PROCESSING_HEADER
32 #define GRT_PRE_PROCESSING_HEADER
33 
34 #include "MLBase.h"
35 
36 GRT_BEGIN_NAMESPACE
37 
38 class GRT_API PreProcessing : public MLBase
39 {
40 public:
44  PreProcessing(void);
45 
49  virtual ~PreProcessing(void);
50 
57  virtual bool deepCopyFrom(const PreProcessing *rhs){ return false; }
58 
65  bool copyBaseVariables(const PreProcessing *preProcessingModule);
66 
73  virtual bool process(const VectorFloat &inputVector){ return false; }
74 
80  virtual bool reset();
81 
88  virtual bool clear();
89 
93  std::string getPreProcessingType() const;
94 
100  UINT getNumInputDimensions() const;
101 
107  UINT getNumOutputDimensions() const;
108 
114  bool getInitialized() const;
115 
119  VectorFloat getProcessedData() const;
120 
124  typedef std::map< std::string, PreProcessing*(*)() > StringPreProcessingMap;
125 
132  static PreProcessing* createInstanceFromString(std::string const &preProcessingType);
133 
137  PreProcessing* createNewInstance() const;
138 
139 protected:
146  bool init();
147 
153  bool savePreProcessingSettingsToFile(std::fstream &file) const;
154 
160  bool loadPreProcessingSettingsFromFile(std::fstream &file);
161 
162  std::string preProcessingType;
163  bool initialized;
164  VectorFloat processedData;
165 
166  static StringPreProcessingMap *getMap() {
167  if( !stringPreProcessingMap ){ stringPreProcessingMap = new StringPreProcessingMap; }
168  return stringPreProcessingMap;
169  }
170 
171 private:
172  static StringPreProcessingMap *stringPreProcessingMap;
173  static UINT numPreProcessingInstances;
174 };
175 
176 //These two functions/classes are used to register any new PreProcessing Module with the PreProcessing base class
177 template< typename T > PreProcessing *newPreProcessingModuleInstance() { return new T; }
178 
179 template< typename T >
181 public:
182  RegisterPreProcessingModule( const std::string &newPreProcessingModuleName ) {
183  getMap()->insert( std::pair< std::string, PreProcessing*(*)() >(newPreProcessingModuleName, &newPreProcessingModuleInstance< T > ) );
184  }
185 };
186 
187 GRT_END_NAMESPACE
188 
189 #endif // GRT_POST_PROCESSING_HEADER
190 
191 
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:57
virtual bool reset()
Definition: MLBase.cpp:125
UINT getNumOutputDimensions() const
Definition: MLBase.cpp:214
This is the main base class that all GRT machine learning algorithms should inherit from...
virtual bool clear()
Definition: MLBase.cpp:127
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:73
UINT getNumInputDimensions() const
Definition: MLBase.cpp:212
Definition: MLBase.h:70
std::map< std::string, PreProcessing *(*)() > StringPreProcessingMap