nurbs.hpp
Go to the documentation of this file.
00001 /*
00002  * nurbs.hpp
00003  *
00004  *  Created on: 14.01.2013
00005  *      Author: josh
00006  */
00007 
00008 #include <cob_3d_segmentation/eval.h>
00009 
00010 
00011 template <typename Point, typename PointLabel>
00012 bool Segmentation_NURBS<Point, PointLabel>::compute() {
00013   shapes_.clear();
00014 
00015   pcl::on_nurbs::SequentialFitter sf;
00016 
00017   sf.setInputCloud(input_);
00018   fs.setCamera(Eigen::Matrix3f::Identity());
00019 
00020 
00021   sf.compute();
00022 
00023   SHAPE_S shape;
00024   shape.nurbs_ = sf.getNurbs();
00025 
00026   shapes_.push_back( shape );
00027 
00028   return true;
00029 }
00030 
00031 template <typename Point, typename PointLabel>
00032 boost::shared_ptr<const pcl::PointCloud<PointLabel> > Segmentation_NURBS<Point, PointLabel>::getReconstructedOutputCloud() {
00033   boost::shared_ptr<pcl::PointCloud<PointLabel> > cloud (new pcl::PointCloud<PointLabel>);
00034   cloud->header = input_->header;
00035 
00036   /*for(size_t i=0; i<shapes_.size(); i++) {
00037     boost::shared_ptr<pcl::SampleConsensusModel<Point> >
00038     model;
00039     pcl::PointCloud<PointLabel> temp;
00040 
00041     if(shapes_[i].type_==SHAPE_S::PLANE)
00042       model.reset(new pcl::SampleConsensusModelPlane<Point> (input_));
00043     //else if(shapes_[i].type_==SHAPE_S::CYLINDER)
00044     //  model.reset(new pcl::SampleConsensusModelCylinder<Point,Point> (input_));
00045     else if(shapes_[i].type_==SHAPE_S::SPHERE)
00046       model.reset(new pcl::SampleConsensusModelSphere<Point> (input_));
00047     else
00048       ROS_ASSERT(0);
00049 
00050     model->projectPoints(shapes_[i].inliers_, shapes_[i].coeff_, temp, false);
00051 
00052     *cloud += temp;
00053   }*/
00054 
00055   return cloud;
00056 }
00057 
00058 template <typename Point, typename PointLabel>
00059 void Segmentation_NURBS<Point, PointLabel>::compute_accuracy(float &mean, float &var, size_t &used, size_t &mem, size_t &points, float &avg_dist) {
00060   RunningStat rstat;
00061   points = 0;
00062   avg_dist = 0;
00063   mem = 0;
00064 
00065   pcl::on_nurbs::SequentialFitter sf;
00066 
00067   for(size_t i=0; i<input_.size(); i++) {
00068     Eigen::Vector3d pt, pta;
00069     pt(0) = (*input)[i].x;
00070     pt(1) = (*input)[i].y;
00071     pt(2) = (*input)[i].z;
00072     if(!pcl_isfinite(pt.sum())) continue;
00073 
00074     Eigen::Vector2d pt2;
00075     sf.getClosestPointOnNurbs(shapes_[0].nurbs_, pt, pt2);
00076 
00077     double p[3];
00078     surf.Evaluate (pt2(0), pt2(1), 0, 3, p);
00079     for(int j=0; j<3; j++) pta(j) = p[j];
00080 
00081     mem+=shapes_[i].inliers_.size()*4;
00082     mem+=shapes_[i].coeff_.rows()*shapes_[i].coeff_.cols()*4+8;
00083 
00084     const float d = (pt-pta).norm();
00085 
00086     if(!pcl_isfinite(d)) continue;
00087 
00088     rstat.Push(d);
00089     avg_dist += z;
00090     ++points;
00091   }
00092 
00093   //points = levels_[0].w*levels_[0].h;
00094   used = rstat.NumDataValues();
00095 
00096   mean = rstat.Mean();
00097   var = rstat.Variance();
00098   avg_dist /= points;
00099 }


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