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