Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef NURBS_H_
00056 #define NURBS_H_
00057
00058 #include <visualization_msgs/MarkerArray.h>
00059
00060 #include <pcl/surface/on_nurbs/sequential_fitter.h>
00061 #include "../general_segmentation.h"
00062
00063 namespace Segmentation
00064 {
00065
00069 template <typename Point, typename PointLabel>
00070 class Segmentation_NURBS : public GeneralSegmentation<Point, PointLabel>
00071 {
00072
00073 struct SHAPE_S {
00074 ON_NurbsSurface nurbs_;
00075 std::vector<int> inliers_;
00076 };
00077
00078 boost::shared_ptr<const pcl::PointCloud<Point> > input_;
00079 std::vector<SHAPE_S> shapes_;
00080
00081 int nurbs_order_;
00082 double dump_;
00083
00084 public:
00086 Segmentation_NURBS():nurbs_order_(2), dump_(0.5)
00087 {}
00088
00090 virtual ~Segmentation_NURBS() {
00091 }
00092
00094 virtual void setInputCloud (const boost::shared_ptr<const pcl::PointCloud<Point> > &cloud)
00095 {
00096 pcl::PointCloud<Point> *pc = new pcl::PointCloud<Point>;
00097 pc->header = cloud->header;
00098 pc->width = cloud->width /2;
00099 pc->height = cloud->height/2;
00100 pc->resize(pc->width*pc->height);
00101
00102 for(size_t x=0; x<pc->width; x++) {
00103 for(size_t y=0; y<pc->height; y++) {
00104 (*pc)(x,y) = (*cloud)(2*x,2*y);
00105 (*pc)(x,y).x = ((*cloud)(2*x,2*y).x+(*cloud)(2*x+1,2*y).x+(*cloud)(2*x,2*y+1).x+(*cloud)(2*x+1,2*y+1).x)/4;
00106 (*pc)(x,y).y = ((*cloud)(2*x,2*y).y+(*cloud)(2*x+1,2*y).y+(*cloud)(2*x,2*y+1).y+(*cloud)(2*x+1,2*y+1).y)/4;
00107 (*pc)(x,y).z = ((*cloud)(2*x,2*y).z+(*cloud)(2*x+1,2*y).z+(*cloud)(2*x,2*y+1).z+(*cloud)(2*x+1,2*y+1).z)/4;
00108 }
00109 }
00110
00111 input_.reset(pc);
00112 }
00113
00114 virtual bool compute();
00115
00117 operator visualization_msgs::Marker() const;
00118
00119
00120 void compute_accuracy(float &mean, float &var, size_t &used, size_t &mem, size_t &points, float &avg_dist);
00121
00122 void enablePlanes(const bool b) {planes_=b;}
00123 void enableSpheres(const bool b) {spheres_=b;}
00124 void enableCylinders(const bool b) {cylinders_=b;}
00125
00127 virtual boost::shared_ptr<const pcl::PointCloud<PointLabel> > getReconstructedOutputCloud();
00128
00130 virtual boost::shared_ptr<const pcl::PointCloud<PointLabel> > getOutputCloud () {return getReconstructedOutputCloud();}
00131
00133 virtual operator cob_3d_mapping_msgs::ShapeArray() const {return cob_3d_mapping_msgs::ShapeArray();}
00134 };
00135
00136 #include "impl/nurbs.hpp"
00137
00138 }
00139
00140
00141 #endif