cluster_classifier.h
Go to the documentation of this file.
00001 
00063 #ifndef __CLUSTER_CLASSIFIER_H__
00064 #define __CLUSTER_CLASSIFIER_H__
00065 
00066 #include "cob_3d_segmentation/cluster_handler.h"
00067 
00068 #include "cob_3d_mapping_common/label_defines.h"
00069 
00070 namespace cob_3d_segmentation
00071 {
00072   template <typename ClusterHandlerT, typename PointT, typename NormalT, typename LabelT>
00073   class ClusterClassifier
00074   {
00075   public:
00076     typedef pcl::PointCloud<PointT> PointCloud;
00077     typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00078     typedef pcl::PointCloud<NormalT> NormalCloud;
00079     typedef typename NormalCloud::Ptr NormalCloudPtr;
00080     typedef pcl::PointCloud<LabelT> LabelCloud;
00081     typedef typename LabelCloud::ConstPtr LabelCloudConstPtr;
00082 
00083     typedef typename ClusterHandlerT::Ptr ClusterHdlPtr;
00084     typedef typename ClusterHandlerT::ClusterPtr ClusterPtr;
00085     typedef typename ClusterHandlerT::ClusterType ClusterType;
00086 
00087   public:
00088     ClusterClassifier()
00089     { }
00090 
00091     ~ClusterClassifier()
00092     { }
00093 
00094     inline void setClusterHandler(ClusterHdlPtr clusters) { clusters_ = clusters; }
00095     inline void setPointCloudIn(PointCloudConstPtr points) { surface_ = points; }
00096     inline void setNormalCloudInOut(NormalCloudPtr normals) { normals_ = normals; }
00097     inline void setLabelCloudIn(LabelCloudConstPtr labels) { labels_ = labels; }
00098 
00099     void classify();
00100     void classifyOld();
00101 
00102     void mapUnusedPoints(pcl::PointCloud<pcl::PointXYZRGB>::Ptr points)
00103     {
00104       uint32_t color = LBL_COR;
00105       for (std::vector<int>::iterator it = test.begin(); it != test.end(); ++it)
00106         points->points[*it].rgb = *reinterpret_cast<float*>(&color);
00107     }
00108 
00109     void mapPointClasses(pcl::PointCloud<pcl::PointXYZRGB>::Ptr points)
00110     {
00111       uint32_t color = LBL_COR;
00112       for (std::vector<int>::iterator it = test.begin(); it != test.end(); ++it)
00113         points->points[*it].rgb = *reinterpret_cast<float*>(&color);
00114 
00115       color = LBL_PLANE;
00116       for (std::vector<int>::iterator it = test_plane.begin(); it != test_plane.end(); ++it)
00117         points->points[*it].rgb = *reinterpret_cast<float*>(&color);
00118 
00119       color = LBL_CYL;
00120       for (std::vector<int>::iterator it = test_cyl.begin(); it != test_cyl.end(); ++it)
00121         points->points[*it].rgb = *reinterpret_cast<float*>(&color);
00122 
00123       color = LBL_SPH;
00124       for (std::vector<int>::iterator it = test_sph.begin(); it != test_sph.end(); ++it)
00125         points->points[*it].rgb = *reinterpret_cast<float*>(&color);
00126     }
00127 
00128   private:
00129     void recomputeClusterNormals(ClusterPtr c);
00130     void recomputeClusterNormals(ClusterPtr c, int w_size, int steps);
00131     bool computeClusterPointCurvature(int index, int r, int steps,
00132                                       float& pc_min, float& pc_max, Eigen::Vector3f& pc_min_direction);
00133 
00134 
00135     ClusterHdlPtr clusters_;
00136     LabelCloudConstPtr labels_;
00137     PointCloudConstPtr surface_;
00138     NormalCloudPtr normals_;
00139     std::vector<int> test;
00140     std::vector<int> test_cyl;
00141     std::vector<int> test_plane;
00142     std::vector<int> test_sph;
00143   };
00144 
00145 }
00146 
00147 #endif


cob_3d_segmentation
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:03:03