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.
PostProcessing.h
Go to the documentation of this file.
1 
26 #ifndef GRT_POST_PROCESSING_HEADER
27 #define GRT_POST_PROCESSING_HEADER
28 
29 #include "MLBase.h"
30 
31 GRT_BEGIN_NAMESPACE
32 
37 class GRT_API PostProcessing : public MLBase
38 {
39 public:
43  PostProcessing( const std::string &id = "" );
44 
48  virtual ~PostProcessing(void);
49 
56  virtual bool deepCopyFrom(const PostProcessing *postProcessing){ return false; }
57 
64  bool copyBaseVariables(const PostProcessing *postProcessingModule);
65 
72  virtual bool process(const VectorFloat &inputVector){ return false; }
73 
77  UINT getPostProcessingInputMode() const;
78 
82  UINT getPostProcessingOutputMode() const;
83 
89  bool getInitialized() const;
90 
94  bool getIsPostProcessingInputModePredictedClassLabel() const;
95 
99  bool getIsPostProcessingInputModeClassLikelihoods() const;
100 
104  bool getIsPostProcessingOutputModePredictedClassLabel() const;
105 
109  bool getIsPostProcessingOutputModeClassLikelihoods() const;
110 
114  VectorFloat getProcessedData() const;
115 
119  typedef std::map< std::string, PostProcessing*(*)() > StringPostProcessingMap;
120 
127  static PostProcessing* create(const std::string &postProcessingType);
128 
132  PostProcessing* create() const;
133 
134  enum PostprocessingInputModes{INPUT_MODE_NOT_SET=0,INPUT_MODE_PREDICTED_CLASS_LABEL,INPUT_MODE_CLASS_LIKELIHOODS};
135  enum PostprocessingOutputModes{OUTPUT_MODE_NOT_SET=0,OUTPUT_MODE_PREDICTED_CLASS_LABEL,OUTPUT_MODE_CLASS_LIKELIHOODS};
136 
137  GRT_DEPRECATED_MSG( "createNewInstance is deprecated, use create instead.", PostProcessing* createNewInstance() const );
138  GRT_DEPRECATED_MSG( "createInstanceFromString is deprecated, use create instead.", static PostProcessing* createInstanceFromString( const std::string &id ) );
139  GRT_DEPRECATED_MSG( "getPostProcessingType is deprecated, use getId() instead", std::string getPostProcessingType() const );
140 
141 protected:
148  bool init();
149 
155  bool savePostProcessingSettingsToFile(std::fstream &file) const;
156 
162  bool loadPostProcessingSettingsFromFile(std::fstream &file);
163 
164  std::string postProcessingType;
165  bool initialized;
166  UINT postProcessingInputMode;
167  UINT postProcessingOutputMode;
168  VectorFloat processedData;
169 
170  static StringPostProcessingMap *getMap() {
171  if( !stringPostProcessingMap ){ stringPostProcessingMap = new StringPostProcessingMap; }
172  return stringPostProcessingMap;
173  }
174 
175 private:
176  static StringPostProcessingMap *stringPostProcessingMap;
177  static UINT numPostProcessingInstances;
178 };
179 
180 template< typename T > PostProcessing *createNewPostProcessingModule() { return new T; }
181 
182 template< typename T >
184 public:
185  RegisterPostProcessingModule( std::string const &newModuleId ) {
186  getMap()->insert( std::pair< std::string, PostProcessing*(*)() >(newModuleId, &createNewPostProcessingModule< T > ) );
187  }
188 };
189 
190 GRT_END_NAMESPACE
191 
192 #endif //GRT_POST_PROCESSING_HEADER
193 
virtual bool deepCopyFrom(const PostProcessing *postProcessing)
virtual bool process(const VectorFloat &inputVector)
This is the main base class that all GRT PostProcessing algorithms should inherit from...
PostProcessing * createNewPostProcessingModule()
Returns a pointer to a new instance of the template class, the caller is responsible for deleting the...
GRT_DEPRECATED_MSG("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
This is the main base class that all GRT machine learning algorithms should inherit from...
Definition: MLBase.h:72
std::map< std::string, PostProcessing *(*)() > StringPostProcessingMap