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.
WeakClassifier.cpp
Go to the documentation of this file.
1 
28 #define GRT_DLL_EXPORTS
29 #include "WeakClassifier.h"
30 
31 GRT_BEGIN_NAMESPACE
32 
33 WeakClassifier::StringWeakClassifierMap* WeakClassifier::stringWeakClassifierMap = NULL;
34 UINT WeakClassifier::numWeakClassifierInstances = 0;
35 
36 WeakClassifier* WeakClassifier::createInstanceFromString( std::string const &weakClassifierType ){
37 
38  StringWeakClassifierMap::iterator iter = getMap()->find( weakClassifierType );
39  if( iter == getMap()->end() ){
40  return NULL;
41  }
42  return iter->second();
43 }
44 
46  weakClassifierType = "";
47  trained = false;
49  numWeakClassifierInstances++;
50 }
51 
53  if( --numWeakClassifierInstances == 0 ){
54  delete stringWeakClassifierMap;
55  stringWeakClassifierMap = NULL;
56  }
57 }
58 
60  if( this != &rhs ){
62  this->trained = rhs.trained;
64  this->trainingLog = rhs.trainingLog;
65  this->errorLog = rhs.errorLog;
66  this->warningLog = rhs.warningLog;
67  }
68  return *this;
69 }
70 
72  if( weakClassifer == NULL ){
73  errorLog << "copyBaseVariables(const WeakClassifier *rhs) rhs is NULL!" << std::endl;
74  return false;
75  }
76  this->weakClassifierType = weakClassifer->weakClassifierType;
77  this->trained = weakClassifer->trained;
78  this->numInputDimensions = weakClassifer->numInputDimensions;
79  return true;
80 }
81 
84 }
85 
86 GRT_END_NAMESPACE
87 
std::string weakClassifierType
A string that represents the weak classifier type, e.g. DecisionStump.
UINT numInputDimensions
The number of input dimensions to the weak classifier.
This is the main base class for all GRT WeakClassifiers.
WeakClassifier * createNewInstance() const
WeakClassifier & operator=(const WeakClassifier &rhs)
bool copyBaseVariables(const WeakClassifier *weakClassifer)
std::map< std::string, WeakClassifier *(*)() > StringWeakClassifierMap
bool trained
A flag to show if the weak classifier model has been trained.
static WeakClassifier * createInstanceFromString(std::string const &weakClassifierType)
virtual ~WeakClassifier()