Point Cloud Library (PCL)  1.3.1
Public Types | Public Member Functions
pcl::NNClassification Class Reference

Nearest neighbor search based classification of PCL point type features. More...

#include </builddir/build/BUILD/PCL-1.3.1-Source/apps/include/pcl/apps/nn_classification.h>

List of all members.

Public Types

typedef std::pair< std::vector
< std::string >, std::vector
< float > > 
Result
 Result is a list of class labels and scores.
typedef boost::shared_ptr< ResultResultPtr

Public Member Functions

void setTrainingFeatures (const typename pcl::PointCloud< PointT >::ConstPtr &features)
 Setting the training features.
void setTrainingLabelIndicesAndLUT (const std::vector< std::string > &classes, const std::vector< int > &labels_idx)
 Updating the labels for each training example.
void setTrainingLabels (const std::vector< std::string > &labels)
 Setting the labels for each training example.
bool loadTrainingFeatures (std::string file_name, std::string labels_file_name)
 Load the list of training examples and corresponding labels.
bool saveTrainingFeatures (std::string file_name, std::string labels_file_name)
 Save the list of training examples and corresponding labels.
ResultPtr classify (const PointT &p_q, double radius, float gaussian_param, int max_nn=INT_MAX)
 Utility function for the default classification process.
int getKNearestExemplars (const PointT &p_q, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances)
 Search for k-nearest neighbors for the given query point.
int getSimilarExemplars (const PointT &p_q, double radius, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances, int max_nn=INT_MAX)
 Search for all the nearest neighbors of the query point in a given radius.
boost::shared_ptr< std::vector
< float > > 
getSmallestSquaredDistances (std::vector< int > &k_indices, std::vector< float > &k_sqr_distances)
 Gets the smallest square distance to each class given a neighborhood.
ResultPtr getLinearBestScores (std::vector< int > &k_indices, std::vector< float > &k_sqr_distances)
 Computes a score that is inversely proportional to the distance to each class given a neighborhood.
ResultPtr getGaussianBestScores (float gaussian_param, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances)
 Computes a score exponentially decreasing with the distance for each class given a neighborhood.

Detailed Description

Nearest neighbor search based classification of PCL point type features.

FLANN is used to identify a neighborhood, based on which different scoring schemes can be employed to obtain likelihood values for a specified list of classes.

Author:
Zoltan Csaba Marton

Member Typedef Documentation

typedef std::pair<std::vector<std::string>, std::vector<float> > pcl::NNClassification::Result

Result is a list of class labels and scores.

Definition at line 71 of file nn_classification.h.

typedef boost::shared_ptr<Result> pcl::NNClassification::ResultPtr

Definition at line 72 of file nn_classification.h.


Member Function Documentation

ResultPtr pcl::NNClassification::classify ( const PointT &  p_q,
double  radius,
float  gaussian_param,
int  max_nn = INT_MAX 
) [inline]

Utility function for the default classification process.

Parameters:
p_qthe given query point
radiusthe radius of the sphere bounding all of p_q's neighbors
gaussian_paraminfluences the width of the Gaussian by specifying where the 36.78 score should be: score = exp(-distance/gaussian_param)
max_nnif given, bounds the maximum returned neighbors to this value
Returns:
pair of label and score for each training class from the neighborhood

Definition at line 175 of file nn_classification.h.

ResultPtr pcl::NNClassification::getGaussianBestScores ( float  gaussian_param,
std::vector< int > &  k_indices,
std::vector< float > &  k_sqr_distances 
) [inline]

Computes a score exponentially decreasing with the distance for each class given a neighborhood.

Parameters:
gaussian_paraminfluences the width of the Gaussian: score = exp(-distance/gaussioan_param)
k_indicesthe resultant indices of the neighboring points
k_sqr_distancesthe resultant squared distances to the neighboring points
Returns:
pair of label and score for each training class from the neighborhood

Definition at line 265 of file nn_classification.h.

int pcl::NNClassification::getKNearestExemplars ( const PointT &  p_q,
int  k,
std::vector< int > &  k_indices,
std::vector< float > &  k_sqr_distances 
) [inline]

Search for k-nearest neighbors for the given query point.

Parameters:
p_qthe given query point
kthe number of neighbors to search for
k_indicesthe resultant indices of the neighboring points (does not have to be resized to k a priori!)
k_sqr_distancesthe resultant squared distances to the neighboring points (does not have be resized to k a priori!)
Returns:
number of neighbors found

Definition at line 191 of file nn_classification.h.

ResultPtr pcl::NNClassification::getLinearBestScores ( std::vector< int > &  k_indices,
std::vector< float > &  k_sqr_distances 
) [inline]

Computes a score that is inversely proportional to the distance to each class given a neighborhood.

Note:
Scores will sum up to one.
Parameters:
k_indicesthe resultant indices of the neighboring points
k_sqr_distancesthe resultant squared distances to the neighboring points
Returns:
pair of label and score for each training class from the neighborhood

Definition at line 235 of file nn_classification.h.

int pcl::NNClassification::getSimilarExemplars ( const PointT &  p_q,
double  radius,
std::vector< int > &  k_indices,
std::vector< float > &  k_sqr_distances,
int  max_nn = INT_MAX 
) [inline]

Search for all the nearest neighbors of the query point in a given radius.

Parameters:
p_qthe given query point
radiusthe radius of the sphere bounding all of p_q's neighbors
k_indicesthe resultant indices of the neighboring points
k_sqr_distancesthe resultant squared distances to the neighboring points
max_nnif given, bounds the maximum returned neighbors to this value
Returns:
number of neighbors found in radius

Definition at line 206 of file nn_classification.h.

boost::shared_ptr<std::vector<float> > pcl::NNClassification::getSmallestSquaredDistances ( std::vector< int > &  k_indices,
std::vector< float > &  k_sqr_distances 
) [inline]

Gets the smallest square distance to each class given a neighborhood.

Parameters:
k_indicesthe resultant indices of the neighboring points
k_sqr_distancesthe resultant squared distances to the neighboring points
Returns:
a square distance to each training class

Definition at line 217 of file nn_classification.h.

bool pcl::NNClassification::loadTrainingFeatures ( std::string  file_name,
std::string  labels_file_name 
) [inline]

Load the list of training examples and corresponding labels.

Parameters:
file_namePCD file containing the training features
labels_file_namethe class label for each training example
Returns:
true on success, false on failure (read error or number of entries don't match)

Definition at line 130 of file nn_classification.h.

bool pcl::NNClassification::saveTrainingFeatures ( std::string  file_name,
std::string  labels_file_name 
) [inline]

Save the list of training examples and corresponding labels.

Parameters:
file_namefile name for writing the training features
labels_file_namefile name for writing the class label for each training example
Returns:
true on success, false on failure (write error or number of entries don't match)

Definition at line 153 of file nn_classification.h.

void pcl::NNClassification::setTrainingFeatures ( const typename pcl::PointCloud< PointT >::ConstPtr &  features) [inline]

Setting the training features.

Parameters:
featuresthe training features

Definition at line 79 of file nn_classification.h.

void pcl::NNClassification::setTrainingLabelIndicesAndLUT ( const std::vector< std::string > &  classes,
const std::vector< int > &  labels_idx 
) [inline]

Updating the labels for each training example.

Parameters:
classesthe class labels
labels_idxthe index in the class labels list for each training example

Definition at line 92 of file nn_classification.h.

void pcl::NNClassification::setTrainingLabels ( const std::vector< std::string > &  labels) [inline]

Setting the labels for each training example.

The unique labels from the list are stored as the class labels, and for each training example an index pointing to these labels is stored.

Note:
See the setTrainingLabelIndicesAndLUT method for easily re-labeling.
Parameters:
labelsthe class label for each training example

Definition at line 105 of file nn_classification.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines