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.
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 namespace GRT{
37 
38 class 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 VectorDouble &inputVector){ return false; }
74 
81  virtual bool reset(){ return true; }
82 
90  virtual bool saveModelToFile(string filename) const;
91 
99  virtual bool loadModelFromFile(string filename);
100 
108  virtual bool saveModelToFile(fstream &file) const{ return false; }
109 
117  virtual bool loadModelFromFile(fstream &file){ return false; }
118 
122  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 
159 
164 
169 
174 
178  VectorDouble getProcessedData() const;
179 
183  typedef std::map< string, PostProcessing*(*)() > StringPostProcessingMap;
184 
191  static PostProcessing* createInstanceFromString(string const &postProcessingType);
192 
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(fstream &file) const;
216 
222  bool loadPostProcessingSettingsFromFile(fstream &file);
223 
224  string postProcessingType;
225  bool initialized;
226  UINT postProcessingInputMode;
227  UINT postProcessingOutputMode;
228  VectorDouble 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 
241 //These two functions/classes are used to register any new PostProcessing Module with the PostProcessing base class
242 template< typename T > PostProcessing *newPostProcessingModuleInstance() { return new T; }
243 
244 template< typename T >
246 public:
247  RegisterPostProcessingModule(string const &newPostProcessingModuleName) {
248  getMap()->insert( std::pair<string, PostProcessing*(*)()>(newPostProcessingModuleName, &newPostProcessingModuleInstance< T > ) );
249  }
250 };
251 
252 } //End of namespace GRT
253 
254 #endif //GRT_POST_PROCESSING_HEADER
255 
bool getInitialized() const
UINT getPostProcessingOutputMode() const
virtual bool loadModelFromFile(string filename)
string getPostProcessingType() const
bool savePostProcessingSettingsToFile(fstream &file) const
Definition: AdaBoost.cpp:25
virtual ~PostProcessing(void)
bool getIsPostProcessingOutputModePredictedClassLabel() const
VectorDouble getProcessedData() const
virtual bool process(const VectorDouble &inputVector)
bool getIsPostProcessingInputModePredictedClassLabel() const
bool getIsPostProcessingOutputModeClassLikelihoods() const
bool init()
This is the main base class that all GRT machine learning algorithms should inherit from...
bool getIsPostProcessingInputModeClassLikelihoods() const
virtual bool saveModelToFile(fstream &file) const
bool loadPostProcessingSettingsFromFile(fstream &file)
virtual bool loadModelFromFile(fstream &file)
static PostProcessing * createInstanceFromString(string const &postProcessingType)
UINT getNumOutputDimensions() const
UINT getNumInputDimensions() const
PostProcessing * createNewInstance() const
virtual bool saveModelToFile(string filename) const
virtual bool reset()
bool copyBaseVariables(const PostProcessing *postProcessingModule)
UINT getPostProcessingInputMode() const
std::map< string, PostProcessing *(*)() > StringPostProcessingMap
virtual bool deepCopyFrom(const PostProcessing *postProcessing)
PostProcessing(void)