k-nearest-neighbor classifier More...
#include <knn_classifier.h>
Public Types | |
| typedef pcl::KdTree< PointT > | KdTree |
| typedef boost::shared_ptr< KdTree > | KdTreePtr |
| typedef pcl::PointCloud< PointT > | PointCloud |
| typedef boost::shared_ptr < const PointCloud > | PointCloudConstPtr |
| typedef boost::shared_ptr < PointCloud > | PointCloudPtr |
Public Member Functions | |
| int | classify (const PointT &p_q) |
| classify a single point using the loaded training data | |
| KNNClassifier () | |
| int | loadTrainingData (std::string &features_file_name, std::string &labels_file_name) |
| load the training data and labels | |
| int | saveTrainingData (std::string &features_file_name, std::string &labels_file_name) |
| save the loaded training data and labels | |
| void | setKNeighbors (int k) |
| set the k neighbors to search for | |
| void | setTrainingFeatures (const PointCloudPtr &features, std::string &distanceMetric="L2") |
| Set a point cloud containing the features samples. | |
| void | setTrainingLabels (const std::vector< int > &labels) |
| setTrainingLabels | |
| ~KNNClassifier () | |
Protected Attributes | |
| std::string | distanceMetric_ |
| int | k_ |
| std::vector< int > | labels_ |
| int | labels_max_ |
| KdTreePtr | tree_ |
k-nearest-neighbor classifier
Definition at line 73 of file knn_classifier.h.
| typedef pcl::KdTree<PointT> cob_3d_features::KNNClassifier< PointT >::KdTree |
Definition at line 84 of file knn_classifier.h.
| typedef boost::shared_ptr<KdTree> cob_3d_features::KNNClassifier< PointT >::KdTreePtr |
Definition at line 85 of file knn_classifier.h.
| typedef pcl::PointCloud<PointT> cob_3d_features::KNNClassifier< PointT >::PointCloud |
Definition at line 81 of file knn_classifier.h.
| typedef boost::shared_ptr<const PointCloud> cob_3d_features::KNNClassifier< PointT >::PointCloudConstPtr |
Definition at line 83 of file knn_classifier.h.
| typedef boost::shared_ptr<PointCloud> cob_3d_features::KNNClassifier< PointT >::PointCloudPtr |
Definition at line 82 of file knn_classifier.h.
| KNNClassifier::KNNClassifier | ( | ) |
Empty constructor
Definition at line 82 of file knn_classifier.cpp.
| KNNClassifier::~KNNClassifier | ( | ) |
Empty destructor
Definition at line 87 of file knn_classifier.cpp.
| int KNNClassifier::classify | ( | const PointT & | p_q | ) |
classify a single point using the loaded training data
| [in] | p_q | a feature point to be classified |
Definition at line 209 of file knn_classifier.cpp.
| int KNNClassifier::loadTrainingData | ( | std::string & | features_file_name, |
| std::string & | labels_file_name | ||
| ) |
load the training data and labels
| [in] | features_file_name | path to features file |
| [in] | labels_file_name | path to labels file |
Definition at line 186 of file knn_classifier.cpp.
| int KNNClassifier::saveTrainingData | ( | std::string & | features_file_name, |
| std::string & | labels_file_name | ||
| ) |
save the loaded training data and labels
| [in] | features_file_name | path where the features should be saved |
| [in] | labels_file_name | path where the labels should be saved |
Definition at line 169 of file knn_classifier.cpp.
| void KNNClassifier::setKNeighbors | ( | int | k | ) |
set the k neighbors to search for
Definition at line 163 of file knn_classifier.cpp.
| void KNNClassifier::setTrainingFeatures | ( | const PointCloudPtr & | features, |
| std::string & | distanceMetric = "L2" |
||
| ) |
Set a point cloud containing the features samples.
| [in] | features | input feature point cloud |
| [in] | distanceMetric | L2, L1, HIK, ChiSpuare, Hellinger at the moment only L2 works with the default PCL |
Definition at line 146 of file knn_classifier.cpp.
| void KNNClassifier::setTrainingLabels | ( | const std::vector< int > & | labels | ) |
setTrainingLabels
Definition at line 156 of file knn_classifier.cpp.
std::string cob_3d_features::KNNClassifier< PointT >::distanceMetric_ [protected] |
Definition at line 136 of file knn_classifier.h.
int cob_3d_features::KNNClassifier< PointT >::k_ [protected] |
Definition at line 138 of file knn_classifier.h.
std::vector<int> cob_3d_features::KNNClassifier< PointT >::labels_ [protected] |
Definition at line 135 of file knn_classifier.h.
int cob_3d_features::KNNClassifier< PointT >::labels_max_ [protected] |
Definition at line 137 of file knn_classifier.h.
KdTreePtr cob_3d_features::KNNClassifier< PointT >::tree_ [protected] |
Definition at line 134 of file knn_classifier.h.