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.
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 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 
97  virtual bool saveModelToFile(std::string filename) const;
98 
106  virtual bool loadModelFromFile(std::string filename);
107 
115  virtual bool saveModelToFile(std::fstream &file) const{ return false; }
116 
124  virtual bool loadModelFromFile(std::fstream &file){ return false; }
125 
129  std::string getPreProcessingType() const;
130 
136  UINT getNumInputDimensions() const;
137 
143  UINT getNumOutputDimensions() const;
144 
150  bool getInitialized() const;
151 
156 
160  typedef std::map< std::string, PreProcessing*(*)() > StringPreProcessingMap;
161 
168  static PreProcessing* createInstanceFromString(std::string const &preProcessingType);
169 
174 
175 protected:
182  bool init();
183 
189  bool savePreProcessingSettingsToFile(std::fstream &file) const;
190 
196  bool loadPreProcessingSettingsFromFile(std::fstream &file);
197 
198  std::string preProcessingType;
199  bool initialized;
200  VectorFloat 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( const std::string &newPreProcessingModuleName ) {
219  getMap()->insert( std::pair< std::string, PreProcessing*(*)() >(newPreProcessingModuleName, &newPreProcessingModuleInstance< T > ) );
220  }
221 };
222 
223 GRT_END_NAMESPACE
224 
225 #endif // GRT_POST_PROCESSING_HEADER
226 
227 
virtual ~PreProcessing(void)
UINT getNumInputDimensions() const
UINT getNumOutputDimensions() const
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:57
virtual bool saveModelToFile(std::fstream &file) const
bool savePreProcessingSettingsToFile(std::fstream &file) const
bool loadPreProcessingSettingsFromFile(std::fstream &file)
PreProcessing * createNewInstance() const
static PreProcessing * createInstanceFromString(std::string const &preProcessingType)
virtual bool reset()
virtual bool loadModelFromFile(std::string filename)
This is the main base class that all GRT machine learning algorithms should inherit from...
std::string getPreProcessingType() const
virtual bool saveModelToFile(std::string filename) const
VectorFloat getProcessedData() const
virtual bool loadModelFromFile(std::fstream &file)
bool copyBaseVariables(const PreProcessing *preProcessingModule)
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:73
virtual bool clear()
Definition: MLBase.h:70
std::map< std::string, PreProcessing *(*)() > StringPreProcessingMap
bool getInitialized() const