A random forest for RGB-D images.
More...
#include <random_forest_image.h>
Public Member Functions |
| RandomForestImage (const std::vector< std::string > &treeFiles, const std::vector< int > &deviceIds=std::vector< int >(1, 0), const AccelerationMode accelerationMode=GPU_ONLY, const double histogramBias=0.0) |
| Load the random forest from disk.
|
| RandomForestImage (unsigned int treeCount, const TrainingConfiguration &configuration) |
| Prepare a random forest with the given number of trees and the configuration.
|
| RandomForestImage (const std::vector< boost::shared_ptr< RandomTreeImage > > &ensemble, const TrainingConfiguration &configuration) |
| Construct a random forest from the given list of existing trees.
|
void | train (const std::vector< LabeledRGBDImage > &trainLabelImages, size_t numLabels=0, bool trainTreesSequentially=false) |
| Starts the training process of the random forest.
|
LabelImage | predict (const RGBDImage &image, cuv::ndarray< float, cuv::host_memory_space > *prediction=0, const bool onGPU=true, bool useDepthImages=true) const |
LabelImage | improveHistograms (const RGBDImage &trainingImage, const LabelImage &labelImage, const bool onGPU=true, bool useDepthImages=true) const |
| classifies all images at the end of training - used to improve leaf distributions
|
void | updateTreesHistograms () |
| uses the allPixelsHistograms to update the trees leaves histograms - used to improve leaf distributions
|
std::map< std::string, size_t > | countFeatures () const |
LabelType | getNumClasses () const |
const boost::shared_ptr
< RandomTreeImage > | getTree (size_t treeNr) const |
const std::vector
< boost::shared_ptr
< RandomTreeImage > > & | getTrees () const |
const TrainingConfiguration & | getConfiguration () const |
bool | shouldIgnoreLabel (const LabelType &label) const |
std::map< LabelType, RGBColor > | getLabelColorMap () const |
void | normalizeHistograms (const double histogramBias) |
| goes over all trees and normalizes the histograms
|
Detailed Description
A random forest for RGB-D images.
Definition at line 17 of file random_forest_image.h.
Constructor & Destructor Documentation
curfil::RandomForestImage::RandomForestImage |
( |
const std::vector< std::string > & |
treeFiles, |
|
|
const std::vector< int > & |
deviceIds = std::vector< int >(1, 0) , |
|
|
const AccelerationMode |
accelerationMode = GPU_ONLY , |
|
|
const double |
histogramBias = 0.0 |
|
) |
| |
|
explicit |
Load the random forest from disk.
- Parameters
-
treeFiles | paths of JSON tree files |
deviceIds | the GPU device IDs to use for prediction |
accelerationMode | the acceleration mode to use for prediction. CPU or GPU. |
histogramBias | if larger than 0.0, apply a histogram bias (see the Wiki) after loading the forest. |
curfil::RandomForestImage::RandomForestImage |
( |
unsigned int |
treeCount, |
|
|
const TrainingConfiguration & |
configuration |
|
) |
| |
|
explicit |
Prepare a random forest with the given number of trees and the configuration.
- Parameters
-
treeCount | the number of trees in the forest |
configuration | the configuration to use for training |
Construct a random forest from the given list of existing trees.
- Parameters
-
ensemble | list of trees that should be used to construct the random forest from |
configuration | the configuration the trees were trained with |
Member Function Documentation
std::map<std::string, size_t> curfil::RandomForestImage::countFeatures |
( |
| ) |
const |
- Returns
- a recursive sum of per-feature type count
std::map<LabelType, RGBColor> curfil::RandomForestImage::getLabelColorMap |
( |
| ) |
const |
- Returns
- a map where keys are the labels and the values are the colors associated with them
LabelType curfil::RandomForestImage::getNumClasses |
( |
| ) |
const |
- Returns
- the number of classes (labels) that random forest was trained from
const boost::shared_ptr<RandomTreeImage> curfil::RandomForestImage::getTree |
( |
size_t |
treeNr | ) |
const |
|
inline |
- Returns
- the n-th tree in the forest where 0 ≤ treeNr < numTrees
Definition at line 95 of file random_forest_image.h.
const std::vector<boost::shared_ptr<RandomTreeImage> >& curfil::RandomForestImage::getTrees |
( |
| ) |
const |
|
inline |
- Parameters
-
image | the image which should be classified |
prediction | if not null, probabilities per class in a C×H×W matrix for C classes and an image of size W×H |
onGPU | whether prediction is done using GPUs |
useDepthImages | whether depth images are used when classifying images |
- Returns
- prediction image which has the same size as 'image'
bool curfil::RandomForestImage::shouldIgnoreLabel |
( |
const LabelType & |
label | ) |
const |
- Returns
- whether the passed label is one of those specified by the user to be ignored
void curfil::RandomForestImage::train |
( |
const std::vector< LabeledRGBDImage > & |
trainLabelImages, |
|
|
size_t |
numLabels = 0 , |
|
|
bool |
trainTreesSequentially = false |
|
) |
| |
Starts the training process of the random forest.
- Parameters
-
trainLabelImages | the list of labeled images to train the random forest from |
trainTreesSequentially | whether to train the trees in the random forest in parallel or sequentially. |
numLabels | number of classes in the images |
The documentation for this class was generated from the following file: