knn_classifier.h
Go to the documentation of this file.
00001 
00063 #ifndef COB_3D_MAPPING_FEATURES_KNN_CLASSIFIER_H_
00064 #define COB_3D_MAPPING_FEATURES_KNN_CLASSIFIER_H_
00065 
00066 #include <pcl/point_cloud.h>
00067 #include <pcl/point_types.h>
00068 #include <pcl/kdtree/kdtree_flann.h>
00069 
00070 namespace cob_3d_features
00071 {
00073   template<typename PointT> class KNNClassifier
00074   {
00075   public:
00077     KNNClassifier();
00079     ~KNNClassifier();
00080 
00081     typedef pcl::PointCloud<PointT> PointCloud;
00082     typedef boost::shared_ptr<PointCloud> PointCloudPtr;
00083     typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr;
00084     typedef pcl::KdTree<PointT> KdTree;
00085     typedef boost::shared_ptr<KdTree> KdTreePtr;
00086 
00094     void setTrainingFeatures(const PointCloudPtr &features, 
00095                              std::string &distanceMetric = "L2");
00096 
00100     void setTrainingLabels(const std::vector<int> &labels);
00101 
00105     void setKNeighbors(int k);
00106 
00113     int saveTrainingData(std::string &features_file_name,
00114                          std::string &labels_file_name);
00115 
00122     int loadTrainingData(std::string &features_file_name,
00123                          std::string &labels_file_name);
00124 
00131     int classify(const PointT &p_q);
00132 
00133   protected:
00134     KdTreePtr tree_;
00135     std::vector<int> labels_;
00136     std::string distanceMetric_;
00137     int labels_max_;
00138     int k_;
00139 
00140 //    int getDominantLabel(std::vector<int> 
00141   };
00142 }
00143 
00144 #endif


cob_3d_features
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:02:26