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>
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 | |
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_ |
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.
Definition at line 59 of file nn_classification.h.
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.
typedef boost::shared_ptr<Result> pcl::NNClassification< PointT >::ResultPtr |
Definition at line 76 of file nn_classification.h.
pcl::NNClassification< PointT >::NNClassification | ( | ) | [inline] |
Definition at line 72 of file nn_classification.h.
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.
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 185 of file nn_classification.h.
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.
[in] | gaussian_param | influences the width of the Gaussian: score = exp(-distance/gaussioan_param) |
[out] | k_indices | the resultant indices of the neighboring points |
[out] | k_sqr_distances | the resultant squared distances to the neighboring points |
Definition at line 280 of file nn_classification.h.
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.
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 202 of file nn_classification.h.
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.
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
Definition at line 249 of file nn_classification.h.
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.
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 218 of file nn_classification.h.
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.
k_indices | the resultant indices of the neighboring points |
k_sqr_distances | the resultant squared distances to the neighboring points |
Definition at line 230 of file nn_classification.h.
bool pcl::NNClassification< PointT >::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 138 of file nn_classification.h.
bool pcl::NNClassification< PointT >::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 162 of file nn_classification.h.
void pcl::NNClassification< PointT >::setTrainingFeatures | ( | const typename pcl::PointCloud< PointT >::ConstPtr & | features | ) | [inline] |
Setting the training features.
[in] | features | the training features |
Definition at line 84 of file nn_classification.h.
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.
classes | the class labels |
labels_idx | the index in the class labels list for each training example |
Definition at line 98 of file nn_classification.h.
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.
labels | the class label for each training example |
Definition at line 112 of file nn_classification.h.
std::vector<std::string> pcl::NNClassification< PointT >::classes_ [private] |
List of class labels.
Definition at line 66 of file nn_classification.h.
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.
pcl::KdTree<PointT>::Ptr pcl::NNClassification< PointT >::tree_ [private] |
Definition at line 63 of file nn_classification.h.