nurbs.h
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2011
00004  *
00005  * Fraunhofer Institute for Manufacturing Engineering
00006  * and Automation (IPA)
00007  *
00008  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00009  *
00010  * Project name: care-o-bot
00011  * ROS stack name: cob_vision
00012  * ROS package name: dynamic_tutorials
00013  * Description:
00014  *
00015  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00016  *
00017  * Author: josh
00018  *
00019  * Date of creation: Oct 26, 2011
00020  * ToDo:
00021  *
00022  *
00023  *
00024  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00025  *
00026  * Redistribution and use in source and binary forms, with or without
00027  * modification, are permitted provided that the following conditions are met:
00028  *
00029  *     * Redistributions of source code must retain the above copyright
00030  *       notice, this list of conditions and the following disclaimer.
00031  *     * Redistributions in binary form must reproduce the above copyright
00032  *       notice, this list of conditions and the following disclaimer in the
00033  *       documentation and/or other materials provided with the distribution.
00034  *     * Neither the name of the Fraunhofer Institute for Manufacturing
00035  *       Engineering and Automation (IPA) nor the names of its
00036  *       contributors may be used to endorse or promote products derived from
00037  *       this software without specific prior written permission.
00038  *
00039  * This program is free software: you can redistribute it and/or modify
00040  * it under the terms of the GNU Lesser General Public License LGPL as
00041  * published by the Free Software Foundation, either version 3 of the
00042  * License, or (at your option) any later version.
00043  *
00044  * This program is distributed in the hope that it will be useful,
00045  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00046  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00047  * GNU Lesser General Public License LGPL for more details.
00048  *
00049  * You should have received a copy of the GNU Lesser General Public
00050  * License LGPL along with this program.
00051  * If not, see <http://www.gnu.org/licenses/>.
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     /*** evaluation purposes ***/
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 /* NURBS_H_ */


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