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.
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:
45  PreProcessing( const std::string &id = "" );
46 
50  virtual ~PreProcessing(void);
51 
58  virtual bool deepCopyFrom(const PreProcessing *rhs){ return false; }
59 
66  bool copyBaseVariables(const PreProcessing *preProcessingModule);
67 
74  virtual bool process(const VectorFloat &inputVector){ return false; }
75 
81  virtual bool reset() override;
82 
89  virtual bool clear() override;
90 
96  bool getInitialized() const;
97 
101  VectorFloat getProcessedData() const;
102 
106  typedef std::map< std::string, PreProcessing*(*)() > StringPreProcessingMap;
107 
114  static PreProcessing* create(const std::string &id);
115 
119  PreProcessing* create() const;
120 
121  GRT_DEPRECATED_MSG( "createNewInstance is deprecated, use create() instead.", PreProcessing* createNewInstance() const );
122  GRT_DEPRECATED_MSG( "createInstanceFromString(id) is deprecated, use create(id) instead.", static PreProcessing* createInstanceFromString( const std::string &id ) );
123  GRT_DEPRECATED_MSG( "getPreProcessingType is deprecated, use getId() instead", std::string getPreProcessingType() const );
124 
125 protected:
132  bool init();
133 
139  bool savePreProcessingSettingsToFile(std::fstream &file) const;
140 
146  bool loadPreProcessingSettingsFromFile(std::fstream &file);
147 
148  std::string preProcessingType;
149  bool initialized;
150  VectorFloat processedData;
151 
152  static StringPreProcessingMap *getMap() {
153  if( !stringPreProcessingMap ){ stringPreProcessingMap = new StringPreProcessingMap; }
154  return stringPreProcessingMap;
155  }
156 
157 private:
158  static StringPreProcessingMap *stringPreProcessingMap;
159  static UINT numPreProcessingInstances;
160 };
161 
162 template< typename T >
164 
169 template< typename T >
171 public:
172  RegisterPreProcessingModule( const std::string &newModuleId ) {
173  getMap()->insert( std::pair< std::string, PreProcessing*(*)() >(newModuleId, &createNewPreProcessingModule< T > ) );
174  }
175 };
176 
177 GRT_END_NAMESPACE
178 
179 #endif // GRT_POST_PROCESSING_HEADER
180 
181 
virtual bool deepCopyFrom(const PreProcessing *rhs)
Definition: PreProcessing.h:58
virtual bool reset()
Definition: MLBase.cpp:147
PreProcessing * createNewPreProcessingModule()
Returns a pointer to a new instance of the template class, the caller is responsible for deleting the...
virtual bool clear()
Definition: MLBase.cpp:149
GRT_DEPRECATED_MSG("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
virtual bool process(const VectorFloat &inputVector)
Definition: PreProcessing.h:74
This class provides an interface for classes to register themselves with the preprocessing base class...
This is the main base class that all GRT machine learning algorithms should inherit from...
Definition: MLBase.h:72
std::map< std::string, PreProcessing *(*)() > StringPreProcessingMap