Public Member Functions | Friends

GentleBoostClassifier Class Reference
[Machine Perception Primitives]

Machine Perception Primitive: An implementation of a GentleBoost classifier for image patch classification. More...

#include <GentleBoostClassifier.h>

Inheritance diagram for GentleBoostClassifier:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GentleBoostClassifier ()
 Constructor.
virtual ~GentleBoostClassifier ()
 Destructor.
virtual IplImage * getProbabilityMap (PatchList *patches)
 Evaluate every pixel in an image for its probability that an object is located there.
void searchPatches (const std::vector< ImagePatch * > &patches, const CvMat *labels, CvMat *&featureSum, CvMat *&posterior, CvMat *&predictions, std::vector< CvMat * > &featureOutputs, double &perf, CvMat *&weights)
 Apply the GentleBoostClasssifier to a classify collection of image patches.
virtual void setTrainingSet (const std::vector< ImagePatch * > &trainingPatches, const CvMat *trainingLabels)
 Set ImagePatch data and labels used for training the classifier.
virtual void setTestingSet (const std::vector< ImagePatch * > &testingPatches, const CvMat *testingLabels)
 Set ImagePatch data and labels used for evaluating the classifier.
virtual void addFeature (Feature *nextFeature)
 Add a feature to the classifier.
void getPerformanceMeasures (Feature *candidate, double &chiSq)
 Compute perfomance measures for this classifier, depending on the Feature* passed in. This is primarily used for finding the best feature to add to the classifier, using addFeature().
int getNumFeaturesUsed ()
 How many of its total features is the classifier currently using? To improve speed or avoid generalization errors, it may be useful to only use the first few features of the classifier.
int getNumFeaturesTotal ()
 How many total available, trained features does the classifier have?
void setNumFeaturesUsed (int num)
 Number of trained and available features to use. To improve speed or avoid generalization errors, it may be useful to only use the first few features of the classifier.
FeatureRegressorgetFeatureAndTuningCurveNumber (int num)
 Examine the features used by this GentleBoostClassifier.
cv::Size getBasePatchSize ()
 Size of patches used for training. All features added must have a size equal to getBasePatchSize().

Friends

std::ostream & operator<< (std::ostream &ofs, GentleBoostClassifier *feat)
 Write to a file.
std::istream & operator>> (std::istream &ifs, GentleBoostClassifier *&feat)
 Read from a file.

Detailed Description

Machine Perception Primitive: An implementation of a GentleBoost classifier for image patch classification.

The GentleBoost approach is described in Fasel's "Learning Real-Time Object Detectors: Probabilistic Generative Approaches", 2006 (see Related Publications).

GentleBoostClassifier is only suitable for whole patch classification. It is not meant to be used to search for objects in scenes. For that application, see GentleBoostCascadedClassifier.

Author:
Nicholas Butko
Date:
2010
Version:
0.4

Member Function Documentation

void GentleBoostClassifier::addFeature ( Feature nextFeature ) [virtual]

Add a feature to the classifier.

This will create a FeatureRegressor and compute its tuning curve based on the current weighting of the training examples, and then reweight the training examples according to the GentleBoost algorithm.

Parameters:
nextFeatureThe feature to add.

Reimplemented in GentleBoostCascadedClassifier.

cv::Size GentleBoostClassifier::getBasePatchSize (  )

Size of patches used for training. All features added must have a size equal to getBasePatchSize().

getBasePatchSize() is set implicitly by the first feature added.

Returns:
Size of the features used by this this classifier.
FeatureRegressor * GentleBoostClassifier::getFeatureAndTuningCurveNumber ( int  num )

Examine the features used by this GentleBoostClassifier.

Parameters:
numIndex of the feature to query, numbered 0 to getNumFeaturesTotal()-1.
Returns:
A FeatureRegressor, which has the tuning curve as well as the feature.
int GentleBoostClassifier::getNumFeaturesTotal (  )

How many total available, trained features does the classifier have?

Returns:
Number of features trained and available for use.
int GentleBoostClassifier::getNumFeaturesUsed (  )

How many of its total features is the classifier currently using? To improve speed or avoid generalization errors, it may be useful to only use the first few features of the classifier.

Returns:
Number of features currently being used.
void GentleBoostClassifier::getPerformanceMeasures ( Feature candidate,
double &  chiSq 
)

Compute perfomance measures for this classifier, depending on the Feature* passed in. This is primarily used for finding the best feature to add to the classifier, using addFeature().

getPerformanceMeasures has three modes depending on the candidate feature:

  • If the feature is NULL, calculates the current chi-squared error
  • If the feature is currently in the classifier, calculates the error if we remove the feature
  • Otherwise, calculates the error if we were to add this feature.
Parameters:
candidateCan be NULL, one of the features in the classifier, or a candidate feature to add to the classifier.
chiSqThe computed error measure.
IplImage * GentleBoostClassifier::getProbabilityMap ( PatchList patches ) [virtual]

Evaluate every pixel in an image for its probability that an object is located there.

Since GentleBoostClassifier is not a cascade, this process is somewhat slow. Also, GentleBoostClassifier has no notion of "rejection," so it cannot "find" patches containing the object. It can only give a patch-by-patch estimate of the likelihood that that patch is the object.

Parameters:
patchesA PatchList that has had setImage() called, and also resetListToScale(). Only the current search scale is evaluated.
Returns:
An image with size patches->getImageSizeAtScale(), containing probability estimates. Each pixel represents the probability that the image patch with its top-left pixel at that probability map location contains an object.
void GentleBoostClassifier::searchPatches ( const std::vector< ImagePatch * > &  patches,
const CvMat *  labels,
CvMat *&  featureSum,
CvMat *&  posterior,
CvMat *&  predictions,
std::vector< CvMat * > &  featureOutputs,
double &  perf,
CvMat *&  weights 
)

Apply the GentleBoostClasssifier to a classify collection of image patches.

This classification requires a lot of scratch memory, which you can provide. The behavior of this function depends on which provided pointers are NULL. For example, perf and weights are only computed if labels is not NULL, whereas featureSum, posterior, and predictions are always computed. If any matrices that are required are NULL or incorrectly sized, they will be (re)allocated, and the caller of the function is responsible for managing that memory.

Parameters:
patchesA list of patches to classify.
labelsOptional labels for the patches, to evaluate classifier performance.
featureSumThe accumulated feature output that is used to predict the label of the patch.
posteriorThe probability estimate that the patch was generated by the trained class.
predictionsBinary (+1/-1) classification labels applied by the classifier.
featureOutputsThe output of each individual FeatureRegressor applied to each patch.
perfChi-Squared error in predicting labels (only set if labels are provided).
weightsWeights based on boosting that can be used for training the next feature.
void GentleBoostClassifier::setNumFeaturesUsed ( int  num )

Number of trained and available features to use. To improve speed or avoid generalization errors, it may be useful to only use the first few features of the classifier.

Parameters:
numNumber of features to use. Should be less than or equal to getNumFeaturesTotal().
virtual void GentleBoostClassifier::setTestingSet ( const std::vector< ImagePatch * > &  testingPatches,
const CvMat *  testingLabels 
) [virtual]

Set ImagePatch data and labels used for evaluating the classifier.

Parameters:
testingPatchesA collection of positive and negative examples that the classifier's discrimination will be evaluated on.
testingLabelsBinary (+1/-1) indicating the label of each patch. This should be a matrix of type CV_64FC1 with size numPatches x 1.
virtual void GentleBoostClassifier::setTrainingSet ( const std::vector< ImagePatch * > &  trainingPatches,
const CvMat *  trainingLabels 
) [virtual]

Set ImagePatch data and labels used for training the classifier.

Parameters:
trainingPatchesA collection of positive and negative examples that the classifier should learn to discriminate.
trainingLabelsBinary (+1/-1) indicating the label of each patch. This should be a matrix of type CV_64FC1 with size numPatches x 1.

The documentation for this class was generated from the following files: