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.
PostProcessing.h
Go to the documentation of this file.
1 
31 #ifndef GRT_POST_PROCESSING_HEADER
32 #define GRT_POST_PROCESSING_HEADER
33 
34 #include "MLBase.h"
35 
36 GRT_BEGIN_NAMESPACE
37 
38 class GRT_API PostProcessing : public MLBase
39 {
40 public:
44  PostProcessing(void);
45 
49  virtual ~PostProcessing(void);
50 
57  virtual bool deepCopyFrom(const PostProcessing *postProcessing){ return false; }
58 
65  bool copyBaseVariables(const PostProcessing *postProcessingModule);
66 
73  virtual bool process(const VectorFloat &inputVector){ return false; }
74 
81  virtual bool reset(){ return true; }
82 
90  virtual bool saveModelToFile(std::string filename) const;
91 
99  virtual bool loadModelFromFile(std::string filename);
100 
108  virtual bool saveModelToFile(std::fstream &file) const{ return false; }
109 
117  virtual bool loadModelFromFile(std::fstream &file){ return false; }
118 
122  std::string getPostProcessingType() const;
123 
127  UINT getPostProcessingInputMode() const;
128 
132  UINT getPostProcessingOutputMode() const;
133 
139  UINT getNumInputDimensions() const;
140 
146  UINT getNumOutputDimensions() const;
147 
153  bool getInitialized() const;
154 
158  bool getIsPostProcessingInputModePredictedClassLabel() const;
159 
163  bool getIsPostProcessingInputModeClassLikelihoods() const;
164 
168  bool getIsPostProcessingOutputModePredictedClassLabel() const;
169 
173  bool getIsPostProcessingOutputModeClassLikelihoods() const;
174 
178  VectorFloat getProcessedData() const;
179 
183  typedef std::map< std::string, PostProcessing*(*)() > StringPostProcessingMap;
184 
191  static PostProcessing* createInstanceFromString(std::string const &postProcessingType);
192 
196  PostProcessing* createNewInstance() const;
197 
198  enum PostprocessingInputModes{INPUT_MODE_NOT_SET=0,INPUT_MODE_PREDICTED_CLASS_LABEL,INPUT_MODE_CLASS_LIKELIHOODS};
199  enum PostprocessingOutputModes{OUTPUT_MODE_NOT_SET=0,OUTPUT_MODE_PREDICTED_CLASS_LABEL,OUTPUT_MODE_CLASS_LIKELIHOODS};
200 
201 protected:
208  bool init();
209 
215  bool savePostProcessingSettingsToFile(std::fstream &file) const;
216 
222  bool loadPostProcessingSettingsFromFile(std::fstream &file);
223 
224  std::string postProcessingType;
225  bool initialized;
226  UINT postProcessingInputMode;
227  UINT postProcessingOutputMode;
228  VectorFloat processedData;
229 
230  static StringPostProcessingMap *getMap() {
231  if( !stringPostProcessingMap ){ stringPostProcessingMap = new StringPostProcessingMap; }
232  return stringPostProcessingMap;
233  }
234 
235 private:
236  static StringPostProcessingMap *stringPostProcessingMap;
237  static UINT numPostProcessingInstances;
238 };
239 
240 //These two functions/classes are used to register any new PostProcessing Module with the PostProcessing base class
241 template< typename T > PostProcessing *newPostProcessingModuleInstance() { return new T; }
242 
243 template< typename T >
245 public:
246  RegisterPostProcessingModule( std::string const &newPostProcessingModuleName ) {
247  getMap()->insert( std::pair< std::string, PostProcessing*(*)() >(newPostProcessingModuleName, &newPostProcessingModuleInstance< T > ) );
248  }
249 };
250 
251 GRT_END_NAMESPACE
252 
253 #endif //GRT_POST_PROCESSING_HEADER
254 
virtual bool deepCopyFrom(const PostProcessing *postProcessing)
virtual bool saveModelToFile(std::fstream &file) const
virtual bool process(const VectorFloat &inputVector)
UINT getNumOutputDimensions() const
Definition: MLBase.cpp:214
This is the main base class that all GRT machine learning algorithms should inherit from...
virtual bool loadModelFromFile(std::fstream &file)
virtual bool reset()
UINT getNumInputDimensions() const
Definition: MLBase.cpp:212
Definition: MLBase.h:70
std::map< std::string, PostProcessing *(*)() > StringPostProcessingMap