Point Cloud Library (PCL)
1.3.1
|
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>
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< Result > | ResultPtr |
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. |
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.
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.
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.
p_q | the given query point |
radius | the radius of the sphere bounding all of p_q's neighbors |
gaussian_param | influences the width of the Gaussian by specifying where the 36.78 score should be: score = exp(-distance/gaussian_param) |
max_nn | if given, bounds the maximum returned neighbors to this value |
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.
gaussian_param | influences the width of the Gaussian: score = exp(-distance/gaussioan_param) |
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
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.
p_q | the given query point |
k | the number of neighbors to search for |
k_indices | the resultant indices of the neighboring points (does not have to be resized to k a priori!) |
k_sqr_distances | the resultant squared distances to the neighboring points (does not have be resized to k a priori!) |
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.
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
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.
p_q | the given query point |
radius | the radius of the sphere bounding all of p_q's neighbors |
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
max_nn | if given, bounds the maximum returned neighbors to this value |
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.
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
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.
file_name | PCD file containing the training features |
labels_file_name | the class label for each training example |
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.
file_name | file name for writing the training features |
labels_file_name | file name for writing the class label for each training example |
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.
features | the 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.
classes | the class labels |
labels_idx | the 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.
labels | the class label for each training example |
Definition at line 105 of file nn_classification.h.