GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
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 namespace GRT{
37 
38 class 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 VectorDouble &inputVector){ return false; }
74 
80  virtual bool reset();
81 
88  virtual bool clear();
89 
97  virtual bool saveModelToFile(string filename) const;
98 
106  virtual bool loadModelFromFile(string filename);
107 
115  virtual bool saveModelToFile(fstream &file) const{ return false; }
116 
124  virtual bool loadModelFromFile(fstream &file){ return false; }
125 
129  string getPreProcessingType() const;
130 
136  UINT getNumInputDimensions() const;
137 
143  UINT getNumOutputDimensions() const;
144 
150  bool getInitialized() const;
151 
155  VectorDouble getProcessedData() const;
156 
160  typedef std::map< string, PreProcessing*(*)() > StringPreProcessingMap;
161 
168  static PreProcessing* createInstanceFromString(string const &preProcessingType);
169 
174 
175 protected:
182  bool init();
183 
189  bool savePreProcessingSettingsToFile(fstream &file) const;
190 
196  bool loadPreProcessingSettingsFromFile(fstream &file);
197 
198  string preProcessingType;
199  bool initialized;
200  VectorDouble processedData;
201 
202  static StringPreProcessingMap *getMap() {
203  if( !stringPreProcessingMap ){ stringPreProcessingMap = new StringPreProcessingMap; }
204  return stringPreProcessingMap;
205  }
206 
207 private:
208  static StringPreProcessingMap *stringPreProcessingMap;
209  static UINT numPreProcessingInstances;
210 };
211 
212 //These two functions/classes are used to register any new PreProcessing Module with the PreProcessing base class
213 template< typename T > PreProcessing *newPreProcessingModuleInstance() { return new T; }
214 
215 template< typename T >
217 public:
218  RegisterPreProcessingModule(string const &newPreProcessingModuleName) {
219  getMap()->insert( std::pair<string, PreProcessing*(*)()>(newPreProcessingModuleName, &newPreProcessingModuleInstance< T > ) );
220  }
221 };
222 
223 } //End of namespace GRT
224 
225 #endif // GRT_POST_PROCESSING_HEADER
226 
227 
virtual ~PreProcessing(void)
std::map< string, PreProcessing *(*)() > StringPreProcessingMap
virtual bool clear()
virtual bool loadModelFromFile(string filename)
Definition: AdaBoost.cpp:25
bool savePreProcessingSettingsToFile(fstream &file) const
UINT getNumOutputDimensions() const
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:57
virtual bool loadModelFromFile(fstream &file)
string getPreProcessingType() const
virtual bool process(const VectorDouble &inputVector)
Definition: PreProcessing.h:73
This is the main base class that all GRT machine learning algorithms should inherit from...
virtual bool reset()
bool getInitialized() const
UINT getNumInputDimensions() const
bool copyBaseVariables(const PreProcessing *preProcessingModule)
virtual bool saveModelToFile(string filename) const
PreProcessing * createNewInstance() const
bool loadPreProcessingSettingsFromFile(fstream &file)
VectorDouble getProcessedData() const
static PreProcessing * createInstanceFromString(string const &preProcessingType)
virtual bool saveModelToFile(fstream &file) const