Public Types | Public Member Functions | Private Attributes
pcl::NNClassification< PointT > Class Template Reference

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. More...

#include <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

ResultPtr classify (const PointT &p_q, double radius, float gaussian_param, int max_nn=INT_MAX)
 Utility function for the default classification process.
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.
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.
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.
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.
bool loadTrainingFeatures (std::string file_name, std::string labels_file_name)
 Load the list of training examples and corresponding labels.
 NNClassification ()
bool saveTrainingFeatures (std::string file_name, std::string labels_file_name)
 Save the list of training examples and corresponding labels.
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. 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.

Private Attributes

std::vector< std::string > classes_
 List of class labels.
std::vector< int > labels_idx_
 The index in the class labels list for all the training examples.
pcl::KdTree< PointT >::Ptr tree_

Detailed Description

template<typename PointT>
class pcl::NNClassification< PointT >

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

Definition at line 59 of file nn_classification.h.


Member Typedef Documentation

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

Result is a list of class labels and scores.

Definition at line 75 of file nn_classification.h.

template<typename PointT>
typedef boost::shared_ptr<Result> pcl::NNClassification< PointT >::ResultPtr

Definition at line 76 of file nn_classification.h.


Constructor & Destructor Documentation

template<typename PointT>
pcl::NNClassification< PointT >::NNClassification ( ) [inline]

Definition at line 72 of file nn_classification.h.


Member Function Documentation

template<typename PointT>
ResultPtr pcl::NNClassification< PointT >::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 185 of file nn_classification.h.

template<typename PointT>
ResultPtr pcl::NNClassification< PointT >::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:
[in]gaussian_paraminfluences the width of the Gaussian: score = exp(-distance/gaussioan_param)
[out]k_indicesthe resultant indices of the neighboring points
[out]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 280 of file nn_classification.h.

template<typename PointT>
int pcl::NNClassification< PointT >::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 202 of file nn_classification.h.

template<typename PointT>
ResultPtr pcl::NNClassification< PointT >::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 249 of file nn_classification.h.

template<typename PointT>
int pcl::NNClassification< PointT >::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 218 of file nn_classification.h.

template<typename PointT>
boost::shared_ptr<std::vector<float> > pcl::NNClassification< PointT >::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 230 of file nn_classification.h.

template<typename PointT>
bool pcl::NNClassification< PointT >::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 138 of file nn_classification.h.

template<typename PointT>
bool pcl::NNClassification< PointT >::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 162 of file nn_classification.h.

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

Setting the training features.

Parameters:
[in]featuresthe training features

Definition at line 84 of file nn_classification.h.

template<typename PointT>
void pcl::NNClassification< PointT >::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 98 of file nn_classification.h.

template<typename PointT>
void pcl::NNClassification< PointT >::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 112 of file nn_classification.h.


Member Data Documentation

template<typename PointT>
std::vector<std::string> pcl::NNClassification< PointT >::classes_ [private]

List of class labels.

Definition at line 66 of file nn_classification.h.

template<typename PointT>
std::vector<int> pcl::NNClassification< PointT >::labels_idx_ [private]

The index in the class labels list for all the training examples.

Definition at line 68 of file nn_classification.h.

template<typename PointT>
pcl::KdTree<PointT>::Ptr pcl::NNClassification< PointT >::tree_ [private]

Definition at line 63 of file nn_classification.h.


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


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:19:40