GestureRecognitionToolkit  Version: 0.1.0
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 GRT_BEGIN_NAMESPACE
31 
32 WeakClassifier::StringWeakClassifierMap* WeakClassifier::stringWeakClassifierMap = NULL;
33 UINT WeakClassifier::numWeakClassifierInstances = 0;
34 
35 WeakClassifier* WeakClassifier::createInstanceFromString( std::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!" << std::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 GRT_END_NAMESPACE
86 
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()