sac_segmentation.hpp
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_SEGMENTATION_IMPL_SAC_SEGMENTATION_H_
#define PCL_SEGMENTATION_IMPL_SAC_SEGMENTATION_H_
#include <pcl/segmentation/sac_segmentation.h>
// Sample Consensus methods
#include <pcl/sample_consensus/sac.h>
#include <pcl/sample_consensus/lmeds.h>
#include <pcl/sample_consensus/mlesac.h>
#include <pcl/sample_consensus/msac.h>
#include <pcl/sample_consensus/ransac.h>
#include <pcl/sample_consensus/rmsac.h>
#include <pcl/sample_consensus/rransac.h>
#include <pcl/sample_consensus/prosac.h>
// Sample Consensus models
#include <pcl/sample_consensus/sac_model.h>
#include <pcl/sample_consensus/sac_model_circle.h>
#include <pcl/sample_consensus/sac_model_circle3d.h>
#include <pcl/sample_consensus/sac_model_cone.h>
#include <pcl/sample_consensus/sac_model_cylinder.h>
#include <pcl/sample_consensus/sac_model_line.h>
#include <pcl/sample_consensus/sac_model_normal_plane.h>
#include <pcl/sample_consensus/sac_model_parallel_plane.h>
#include <pcl/sample_consensus/sac_model_normal_parallel_plane.h>
#include <pcl/sample_consensus/sac_model_parallel_line.h>
#include <pcl/sample_consensus/sac_model_perpendicular_plane.h>
#include <pcl/sample_consensus/sac_model_plane.h>
#include <pcl/sample_consensus/sac_model_sphere.h>
#include <pcl/sample_consensus/sac_model_normal_sphere.h>
#include <pcl/sample_consensus/sac_model_stick.h>
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::SACSegmentation<PointT>::segment (PointIndices &inliers, ModelCoefficients &model_coefficients)
{
// Copy the header information
inliers.header = model_coefficients.header = input_->header;
if (!initCompute ())
{
inliers.indices.clear (); model_coefficients.values.clear ();
return;
}
// Initialize the Sample Consensus model and set its parameters
if (!initSACModel (model_type_))
{
PCL_ERROR ("[pcl::%s::segment] Error initializing the SAC model!\n", getClassName ().c_str ());
deinitCompute ();
inliers.indices.clear (); model_coefficients.values.clear ();
return;
}
// Initialize the Sample Consensus method and set its parameters
initSAC (method_type_);
if (!sac_->computeModel (0))
{
PCL_ERROR ("[pcl::%s::segment] Error segmenting the model! No solution found.\n", getClassName ().c_str ());
deinitCompute ();
inliers.indices.clear (); model_coefficients.values.clear ();
return;
}
// Get the model inliers
sac_->getInliers (inliers.indices);
// Get the model coefficients
Eigen::VectorXf coeff;
sac_->getModelCoefficients (coeff);
// If the user needs optimized coefficients
if (optimize_coefficients_)
{
Eigen::VectorXf coeff_refined;
model_->optimizeModelCoefficients (inliers.indices, coeff, coeff_refined);
model_coefficients.values.resize (coeff_refined.size ());
memcpy (&model_coefficients.values[0], &coeff_refined[0], coeff_refined.size () * sizeof (float));
// Refine inliers
model_->selectWithinDistance (coeff_refined, threshold_, inliers.indices);
}
else
{
model_coefficients.values.resize (coeff.size ());
memcpy (&model_coefficients.values[0], &coeff[0], coeff.size () * sizeof (float));
}
deinitCompute ();
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> bool
pcl::SACSegmentation<PointT>::initSACModel (const int model_type)
{
if (model_)
model_.reset ();
// Build the model
switch (model_type)
{
case SACMODEL_PLANE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PLANE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelPlane<PointT> (input_, *indices_, random_));
break;
}
case SACMODEL_LINE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_LINE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelLine<PointT> (input_, *indices_, random_));
break;
}
case SACMODEL_STICK:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_STICK\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelStick<PointT> (input_, *indices_));
double min_radius, max_radius;
model_->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_->setRadiusLimits (radius_min_, radius_max_);
}
break;
}
case SACMODEL_CIRCLE2D:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CIRCLE2D\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelCircle2D<PointT> (input_, *indices_, random_));
typename SampleConsensusModelCircle2D<PointT>::Ptr model_circle = boost::static_pointer_cast<SampleConsensusModelCircle2D<PointT> > (model_);
double min_radius, max_radius;
model_circle->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_circle->setRadiusLimits (radius_min_, radius_max_);
}
break;
}
case SACMODEL_CIRCLE3D:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CIRCLE3D\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelCircle3D<PointT> (input_, *indices_));
typename SampleConsensusModelCircle3D<PointT>::Ptr model_circle3d = boost::static_pointer_cast<SampleConsensusModelCircle3D<PointT> > (model_);
double min_radius, max_radius;
model_circle3d->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_circle3d->setRadiusLimits (radius_min_, radius_max_);
}
break;
}
case SACMODEL_SPHERE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_SPHERE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelSphere<PointT> (input_, *indices_, random_));
typename SampleConsensusModelSphere<PointT>::Ptr model_sphere = boost::static_pointer_cast<SampleConsensusModelSphere<PointT> > (model_);
double min_radius, max_radius;
model_sphere->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_sphere->setRadiusLimits (radius_min_, radius_max_);
}
break;
}
case SACMODEL_PARALLEL_LINE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PARALLEL_LINE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelParallelLine<PointT> (input_, *indices_, random_));
typename SampleConsensusModelParallelLine<PointT>::Ptr model_parallel = boost::static_pointer_cast<SampleConsensusModelParallelLine<PointT> > (model_);
if (axis_ != Eigen::Vector3f::Zero () && model_parallel->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_parallel->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_parallel->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_parallel->setEpsAngle (eps_angle_);
}
break;
}
case SACMODEL_PERPENDICULAR_PLANE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PERPENDICULAR_PLANE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelPerpendicularPlane<PointT> (input_, *indices_, random_));
typename SampleConsensusModelPerpendicularPlane<PointT>::Ptr model_perpendicular = boost::static_pointer_cast<SampleConsensusModelPerpendicularPlane<PointT> > (model_);
if (axis_ != Eigen::Vector3f::Zero () && model_perpendicular->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_perpendicular->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_perpendicular->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_perpendicular->setEpsAngle (eps_angle_);
}
break;
}
case SACMODEL_PARALLEL_PLANE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_PARALLEL_PLANE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelParallelPlane<PointT> (input_, *indices_, random_));
typename SampleConsensusModelParallelPlane<PointT>::Ptr model_parallel = boost::static_pointer_cast<SampleConsensusModelParallelPlane<PointT> > (model_);
if (axis_ != Eigen::Vector3f::Zero () && model_parallel->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_parallel->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_parallel->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_parallel->setEpsAngle (eps_angle_);
}
break;
}
default:
{
PCL_ERROR ("[pcl::%s::initSACModel] No valid model given!\n", getClassName ().c_str ());
return (false);
}
}
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::SACSegmentation<PointT>::initSAC (const int method_type)
{
if (sac_)
sac_.reset ();
// Build the sample consensus method
switch (method_type)
{
case SAC_RANSAC:
default:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_RANSAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new RandomSampleConsensus<PointT> (model_, threshold_));
break;
}
case SAC_LMEDS:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_LMEDS with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new LeastMedianSquares<PointT> (model_, threshold_));
break;
}
case SAC_MSAC:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_MSAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new MEstimatorSampleConsensus<PointT> (model_, threshold_));
break;
}
case SAC_RRANSAC:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_RRANSAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new RandomizedRandomSampleConsensus<PointT> (model_, threshold_));
break;
}
case SAC_RMSAC:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_RMSAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new RandomizedMEstimatorSampleConsensus<PointT> (model_, threshold_));
break;
}
case SAC_MLESAC:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_MLESAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new MaximumLikelihoodSampleConsensus<PointT> (model_, threshold_));
break;
}
case SAC_PROSAC:
{
PCL_DEBUG ("[pcl::%s::initSAC] Using a method of type: SAC_PROSAC with a model threshold of %f\n", getClassName ().c_str (), threshold_);
sac_.reset (new ProgressiveSampleConsensus<PointT> (model_, threshold_));
break;
}
}
// Set the Sample Consensus parameters if they are given/changed
if (sac_->getProbability () != probability_)
{
PCL_DEBUG ("[pcl::%s::initSAC] Setting the desired probability to %f\n", getClassName ().c_str (), probability_);
sac_->setProbability (probability_);
}
if (max_iterations_ != -1 && sac_->getMaxIterations () != max_iterations_)
{
PCL_DEBUG ("[pcl::%s::initSAC] Setting the maximum number of iterations to %d\n", getClassName ().c_str (), max_iterations_);
sac_->setMaxIterations (max_iterations_);
}
if (samples_radius_ > 0.)
{
PCL_DEBUG ("[pcl::%s::initSAC] Setting the maximum sample radius to %f\n", getClassName ().c_str (), samples_radius_);
// Set maximum distance for radius search during random sampling
model_->setSamplesMaxDist (samples_radius_, samples_radius_search_);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT, typename PointNT> bool
pcl::SACSegmentationFromNormals<PointT, PointNT>::initSACModel (const int model_type)
{
if (!input_ || !normals_)
{
PCL_ERROR ("[pcl::%s::initSACModel] Input data (XYZ or normals) not given! Cannot continue.\n", getClassName ().c_str ());
return (false);
}
// Check if input is synced with the normals
if (input_->points.size () != normals_->points.size ())
{
PCL_ERROR ("[pcl::%s::initSACModel] The number of points inthe input point cloud differs than the number of points in the normals!\n", getClassName ().c_str ());
return (false);
}
if (model_)
model_.reset ();
// Build the model
switch (model_type)
{
case SACMODEL_CYLINDER:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CYLINDER\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelCylinder<PointT, PointNT > (input_, *indices_, random_));
typename SampleConsensusModelCylinder<PointT, PointNT>::Ptr model_cylinder = boost::static_pointer_cast<SampleConsensusModelCylinder<PointT, PointNT> > (model_);
// Set the input normals
model_cylinder->setInputNormals (normals_);
double min_radius, max_radius;
model_cylinder->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_cylinder->setRadiusLimits (radius_min_, radius_max_);
}
if (distance_weight_ != model_cylinder->getNormalDistanceWeight ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting normal distance weight to %f\n", getClassName ().c_str (), distance_weight_);
model_cylinder->setNormalDistanceWeight (distance_weight_);
}
if (axis_ != Eigen::Vector3f::Zero () && model_cylinder->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_cylinder->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_cylinder->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_cylinder->setEpsAngle (eps_angle_);
}
break;
}
case SACMODEL_NORMAL_PLANE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_PLANE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelNormalPlane<PointT, PointNT> (input_, *indices_, random_));
typename SampleConsensusModelNormalPlane<PointT, PointNT>::Ptr model_normals = boost::static_pointer_cast<SampleConsensusModelNormalPlane<PointT, PointNT> > (model_);
// Set the input normals
model_normals->setInputNormals (normals_);
if (distance_weight_ != model_normals->getNormalDistanceWeight ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting normal distance weight to %f\n", getClassName ().c_str (), distance_weight_);
model_normals->setNormalDistanceWeight (distance_weight_);
}
break;
}
case SACMODEL_NORMAL_PARALLEL_PLANE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_PARALLEL_PLANE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelNormalParallelPlane<PointT, PointNT> (input_, *indices_, random_));
typename SampleConsensusModelNormalParallelPlane<PointT, PointNT>::Ptr model_normals = boost::static_pointer_cast<SampleConsensusModelNormalParallelPlane<PointT, PointNT> > (model_);
// Set the input normals
model_normals->setInputNormals (normals_);
if (distance_weight_ != model_normals->getNormalDistanceWeight ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting normal distance weight to %f\n", getClassName ().c_str (), distance_weight_);
model_normals->setNormalDistanceWeight (distance_weight_);
}
if (distance_from_origin_ != model_normals->getDistanceFromOrigin ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the distance to origin to %f\n", getClassName ().c_str (), distance_from_origin_);
model_normals->setDistanceFromOrigin (distance_from_origin_);
}
if (axis_ != Eigen::Vector3f::Zero () && model_normals->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_normals->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_normals->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_normals->setEpsAngle (eps_angle_);
}
break;
}
case SACMODEL_CONE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_CONE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelCone<PointT, PointNT> (input_, *indices_, random_));
typename SampleConsensusModelCone<PointT, PointNT>::Ptr model_cone = boost::static_pointer_cast<SampleConsensusModelCone<PointT, PointNT> > (model_);
// Set the input normals
model_cone->setInputNormals (normals_);
double min_angle, max_angle;
model_cone->getMinMaxOpeningAngle(min_angle, max_angle);
if (min_angle_ != min_angle && max_angle_ != max_angle)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting minimum and maximum opening angle to %f and %f \n", getClassName ().c_str (), min_angle_, max_angle_);
model_cone->setMinMaxOpeningAngle (min_angle_, max_angle_);
}
if (distance_weight_ != model_cone->getNormalDistanceWeight ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting normal distance weight to %f\n", getClassName ().c_str (), distance_weight_);
model_cone->setNormalDistanceWeight (distance_weight_);
}
if (axis_ != Eigen::Vector3f::Zero () && model_cone->getAxis () != axis_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the axis to %f, %f, %f\n", getClassName ().c_str (), axis_[0], axis_[1], axis_[2]);
model_cone->setAxis (axis_);
}
if (eps_angle_ != 0.0 && model_cone->getEpsAngle () != eps_angle_)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting the epsilon angle to %f (%f degrees)\n", getClassName ().c_str (), eps_angle_, eps_angle_ * 180.0 / M_PI);
model_cone->setEpsAngle (eps_angle_);
}
break;
}
case SACMODEL_NORMAL_SPHERE:
{
PCL_DEBUG ("[pcl::%s::initSACModel] Using a model of type: SACMODEL_NORMAL_SPHERE\n", getClassName ().c_str ());
model_.reset (new SampleConsensusModelNormalSphere<PointT, PointNT> (input_, *indices_, random_));
typename SampleConsensusModelNormalSphere<PointT, PointNT>::Ptr model_normals_sphere = boost::static_pointer_cast<SampleConsensusModelNormalSphere<PointT, PointNT> > (model_);
// Set the input normals
model_normals_sphere->setInputNormals (normals_);
double min_radius, max_radius;
model_normals_sphere->getRadiusLimits (min_radius, max_radius);
if (radius_min_ != min_radius && radius_max_ != max_radius)
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting radius limits to %f/%f\n", getClassName ().c_str (), radius_min_, radius_max_);
model_normals_sphere->setRadiusLimits (radius_min_, radius_max_);
}
if (distance_weight_ != model_normals_sphere->getNormalDistanceWeight ())
{
PCL_DEBUG ("[pcl::%s::initSACModel] Setting normal distance weight to %f\n", getClassName ().c_str (), distance_weight_);
model_normals_sphere->setNormalDistanceWeight (distance_weight_);
}
break;
}
// If nothing else, try SACSegmentation
default:
{
return (pcl::SACSegmentation<PointT>::initSACModel (model_type));
}
}
return (true);
}
#define PCL_INSTANTIATE_SACSegmentation(T) template class PCL_EXPORTS pcl::SACSegmentation<T>;
#define PCL_INSTANTIATE_SACSegmentationFromNormals(T,NT) template class PCL_EXPORTS pcl::SACSegmentationFromNormals<T,NT>;
#endif // PCL_SEGMENTATION_IMPL_SAC_SEGMENTATION_H_
pcl::SampleConsensusModelPerpendicularPlane::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_perpendicular_plane.h:113
pcl::SACMODEL_LINE
Definition: model_types.h:51
pcl::SampleConsensusModelNormalParallelPlane::getEpsAngle
double getEpsAngle()
Get the angle epsilon (delta) threshold.
Definition: sac_model_normal_parallel_plane.h:156
pcl::SampleConsensusModelCircle2D::Ptr
boost::shared_ptr< SampleConsensusModelCircle2D > Ptr
Definition: sac_model_circle.h:73
pcl::SampleConsensusModelParallelLine::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_parallel_line.h:115
pcl::SACMODEL_CIRCLE2D
Definition: model_types.h:52
pcl::SampleConsensusModelCylinder
SampleConsensusModelCylinder defines a model for 3D cylinder segmentation.
Definition: sac_model_cylinder.h:65
pcl::RandomizedMEstimatorSampleConsensus
RandomizedMEstimatorSampleConsensus represents an implementation of the RMSAC (Randomized M-estimator...
Definition: rmsac.h:58
pcl::SampleConsensusModelLine
SampleConsensusModelLine defines a model for 3D line segmentation.
Definition: sac_model_line.h:63
pcl::SACMODEL_SPHERE
Definition: model_types.h:54
pcl::SampleConsensusModelCircle3D::Ptr
boost::shared_ptr< SampleConsensusModelCircle3D< PointT > > Ptr
Definition: sac_model_circle3d.h:73
pcl::SampleConsensusModelCylinder::getAxis
Eigen::Vector3f getAxis()
Get the axis along which we need to search for a cylinder direction.
Definition: sac_model_cylinder.h:158
pcl::SampleConsensusModelCone::getMinMaxOpeningAngle
void getMinMaxOpeningAngle(double &min_angle, double &max_angle) const
Get the opening angle which we need minumum to validate a cone model.
Definition: sac_model_cone.h:181
pcl::SampleConsensusModelCylinder::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_cylinder.h:144
pcl::SampleConsensusModelParallelPlane
SampleConsensusModelParallelPlane defines a model for 3D plane segmentation using additional angular ...
Definition: sac_model_parallel_plane.h:66
pcl::SACMODEL_PARALLEL_LINE
Definition: model_types.h:58
pcl::SACMODEL_NORMAL_SPHERE
Definition: model_types.h:62
pcl::SACSegmentation
SACSegmentation represents the Nodelet segmentation class for Sample Consensus methods and models...
Definition: sac_segmentation.h:65
pcl::ModelCoefficients::values
std::vector< float > values
Definition: ModelCoefficients.h:20
pcl::SampleConsensusModelSphere::Ptr
boost::shared_ptr< SampleConsensusModelSphere > Ptr
Definition: sac_model_sphere.h:73
pcl::ProgressiveSampleConsensus
RandomSampleConsensus represents an implementation of the RANSAC (RAndom SAmple Consensus) algorithm...
Definition: prosac.h:56
pcl::SampleConsensusModelPerpendicularPlane::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_perpendicular_plane.h:124
pcl::SampleConsensusModelParallelPlane::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_parallel_plane.h:121
pcl::PointIndices::indices
std::vector< int > indices
Definition: PointIndices.h:19
pcl::SampleConsensusModelCone::getEpsAngle
double getEpsAngle() const
Get the angle epsilon (delta) threshold.
Definition: sac_model_cone.h:152
pcl::MEstimatorSampleConsensus
MEstimatorSampleConsensus represents an implementation of the MSAC (M-estimator SAmple Consensus) alg...
Definition: msac.h:57
pcl::SampleConsensusModelCone::setEpsAngle
void setEpsAngle(double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_cone.h:148
pcl::SampleConsensusModelNormalSphere
SampleConsensusModelNormalSphere defines a model for 3D sphere segmentation using additional surface ...
Definition: sac_model_normal_sphere.h:69
pcl::SampleConsensusModelNormalParallelPlane::getAxis
Eigen::Vector3f getAxis()
Get the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_normal_parallel_plane.h:145
pcl::SampleConsensusModelNormalParallelPlane::getDistanceFromOrigin
double getDistanceFromOrigin()
Get the distance of the plane from the origin.
Definition: sac_model_normal_parallel_plane.h:166
pcl::SampleConsensusModelCylinder::Ptr
boost::shared_ptr< SampleConsensusModelCylinder > Ptr
Definition: sac_model_cylinder.h:80
pcl::SampleConsensusModelParallelLine::getEpsAngle
double getEpsAngle()
Get the angle epsilon (delta) threshold.
Definition: sac_model_parallel_line.h:118
pcl::ModelCoefficients
Definition: ModelCoefficients.h:12
pcl::SampleConsensusModelNormalParallelPlane::setEpsAngle
void setEpsAngle(const double ea)
Set the angle epsilon (delta) threshold.
Definition: sac_model_normal_parallel_plane.h:152
pcl::SACMODEL_CONE
Definition: model_types.h:56
pcl::SampleConsensusModelPerpendicularPlane::getAxis
Eigen::Vector3f getAxis()
Get the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_perpendicular_plane.h:117
pcl::SampleConsensusModelCircle3D
SampleConsensusModelCircle3D defines a model for 3D circle segmentation.
Definition: sac_model_circle3d.h:61
pcl::RandomizedRandomSampleConsensus
RandomizedRandomSampleConsensus represents an implementation of the RRANSAC (Randomized RAndom SAmple...
Definition: rransac.h:57
pcl::SampleConsensusModelCircle2D
SampleConsensusModelCircle2D defines a model for 2D circle segmentation on the X-Y plane...
Definition: sac_model_circle.h:60
pcl::LeastMedianSquares
LeastMedianSquares represents an implementation of the LMedS (Least Median of Squares) algorithm...
Definition: lmeds.h:57
pcl::SACMODEL_PLANE
Definition: model_types.h:50
pcl::SampleConsensusModelParallelPlane::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_parallel_plane.h:110
pcl::SACSegmentation::initSACModel
virtual bool initSACModel(const int model_type)
Initialize the Sample Consensus model and set its parameters.
Definition: sac_segmentation.hpp:133
pcl::SampleConsensusModelNormalPlane::Ptr
boost::shared_ptr< SampleConsensusModelNormalPlane > Ptr
Definition: sac_model_normal_plane.h:93
pcl::SampleConsensusModelCylinder::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a cylinder direction.
Definition: sac_model_cylinder.h:154
pcl::SampleConsensusModelNormalParallelPlane::Ptr
boost::shared_ptr< SampleConsensusModelNormalParallelPlane > Ptr
Definition: sac_model_normal_parallel_plane.h:100
pcl::PointIndices
Definition: PointIndices.h:12
pcl::SampleConsensusModelNormalParallelPlane::setDistanceFromOrigin
void setDistanceFromOrigin(const double d)
Set the distance we expect the plane to be from the origin.
Definition: sac_model_normal_parallel_plane.h:162
pcl::SampleConsensusModelNormalParallelPlane::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_normal_parallel_plane.h:141
pcl::SampleConsensusModelParallelLine
SampleConsensusModelParallelLine defines a model for 3D line segmentation using additional angular co...
Definition: sac_model_parallel_line.h:63
pcl::MaximumLikelihoodSampleConsensus
MaximumLikelihoodSampleConsensus represents an implementation of the MLESAC (Maximum Likelihood Estim...
Definition: mlesac.h:57
pcl::SACMODEL_STICK
Definition: model_types.h:67
pcl::SACMODEL_PERPENDICULAR_PLANE
Definition: model_types.h:59
pcl::SACMODEL_CYLINDER
Definition: model_types.h:55
pcl::SampleConsensusModelFromNormals::setNormalDistanceWeight
void setNormalDistanceWeight(const double w)
Set the normal angular distance weight.
Definition: sac_model.h:578
pcl::SampleConsensusModelParallelPlane::getEpsAngle
double getEpsAngle()
Get the angle epsilon (delta) threshold.
Definition: sac_model_parallel_plane.h:125
pcl::SampleConsensusModelPerpendicularPlane::getEpsAngle
double getEpsAngle()
Get the angle epsilon (delta) threshold.
Definition: sac_model_perpendicular_plane.h:128
pcl::SampleConsensusModelFromNormals::setInputNormals
void setInputNormals(const PointCloudNConstPtr &normals)
Provide a pointer to the input dataset that contains the point normals of the XYZ dataset...
Definition: sac_model.h:593
pcl::SampleConsensusModelCone
SampleConsensusModelCone defines a model for 3D cone segmentation.
Definition: sac_model_cone.h:65
pcl::SampleConsensusModelParallelLine::getAxis
Eigen::Vector3f getAxis()
Get the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_parallel_line.h:109
pcl::SampleConsensusModel::getRadiusLimits
void getRadiusLimits(double &min_radius, double &max_radius)
Get the minimum and maximum allowable radius limits for the model as set by the user.
Definition: sac_model.h:381
pcl::PointIndices::header
::pcl::PCLHeader header
Definition: PointIndices.h:17
pcl::SampleConsensusModelParallelPlane::getAxis
Eigen::Vector3f getAxis()
Get the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_parallel_plane.h:114
pcl::SampleConsensusModelStick
SampleConsensusModelStick defines a model for 3D stick segmentation.
Definition: sac_model_stick.h:64
pcl::SampleConsensusModelCone::getAxis
Eigen::Vector3f getAxis() const
Get the axis along which we need to search for a cone direction.
Definition: sac_model_cone.h:162
pcl::SampleConsensusModelPerpendicularPlane::Ptr
boost::shared_ptr< SampleConsensusModelPerpendicularPlane > Ptr
Definition: sac_model_perpendicular_plane.h:78
pcl::SampleConsensusModelNormalPlane
SampleConsensusModelNormalPlane defines a model for 3D plane segmentation using additional surface no...
Definition: sac_model_normal_plane.h:76
pcl::SACMODEL_PARALLEL_PLANE
Definition: model_types.h:65
pcl::SACMODEL_CIRCLE3D
Definition: model_types.h:53
pcl::SampleConsensusModelParallelLine::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a plane perpendicular to.
Definition: sac_model_parallel_line.h:105
pcl::SampleConsensusModelNormalSphere::Ptr
boost::shared_ptr< SampleConsensusModelNormalSphere > Ptr
Definition: sac_model_normal_sphere.h:87
pcl::SACSegmentation::segment
virtual void segment(PointIndices &inliers, ModelCoefficients &model_coefficients)
Base method for segmentation of a model in a PointCloud given by <setInputCloud (), setIndices ()>
Definition: sac_segmentation.hpp:75
pcl::ModelCoefficients::header
::pcl::PCLHeader header
Definition: ModelCoefficients.h:18
pcl::SampleConsensusModel::setRadiusLimits
void setRadiusLimits(const double &min_radius, const double &max_radius)
Set the minimum and maximum allowable radius limits for the model (applicable to models that estimate...
Definition: sac_model.h:368
pcl::SACMODEL_NORMAL_PARALLEL_PLANE
Definition: model_types.h:66
pcl::SampleConsensusModelFromNormals::getNormalDistanceWeight
double getNormalDistanceWeight()
Get the normal angular distance weight.
Definition: sac_model.h:585
pcl::SampleConsensusModelCone::setAxis
void setAxis(const Eigen::Vector3f &ax)
Set the axis along which we need to search for a cone direction.
Definition: sac_model_cone.h:158
pcl::SACSegmentation::initSAC
virtual void initSAC(const int method_type)
Initialize the Sample Consensus method and set its parameters.
Definition: sac_segmentation.hpp:270
pcl::RandomSampleConsensus
RandomSampleConsensus represents an implementation of the RANSAC (RAndom SAmple Consensus) algorithm...
Definition: ransac.h:56
pcl::SampleConsensusModelCylinder::getEpsAngle
double getEpsAngle()
Get the angle epsilon (delta) threshold.
Definition: sac_model_cylinder.h:148
pcl::SACMODEL_NORMAL_PLANE
Definition: model_types.h:61
pcl::SampleConsensusModelCone::setMinMaxOpeningAngle
void setMinMaxOpeningAngle(const double &min_angle, const double &max_angle)
Set the minimum and maximum allowable opening angle for a cone model given from a user...
Definition: sac_model_cone.h:170
pcl::SampleConsensusModelPlane
SampleConsensusModelPlane defines a model for 3D plane segmentation.
Definition: sac_model_plane.h:136
pcl::SampleConsensusModelParallelLine::Ptr
boost::shared_ptr< SampleConsensusModelParallelLine > Ptr
Definition: sac_model_parallel_line.h:70
pcl::SampleConsensusModelSphere
SampleConsensusModelSphere defines a model for 3D sphere segmentation.
Definition: sac_model_sphere.h:60
pcl::SampleConsensusModelParallelPlane::Ptr
boost::shared_ptr< SampleConsensusModelParallelPlane > Ptr
Definition: sac_model_parallel_plane.h:73
pcl::SampleConsensusModelNormalParallelPlane
SampleConsensusModelNormalParallelPlane defines a model for 3D plane segmentation using additional su...
Definition: sac_model_normal_parallel_plane.h:84
pcl::SampleConsensusModelCone::Ptr
boost::shared_ptr< SampleConsensusModelCone > Ptr
Definition: sac_model_cone.h:80
pcl::SACSegmentationFromNormals::initSACModel
virtual bool initSACModel(const int model_type)
Initialize the Sample Consensus model and set its parameters.
Definition: sac_segmentation.hpp:342
pcl::SampleConsensusModelPerpendicularPlane
SampleConsensusModelPerpendicularPlane defines a model for 3D plane segmentation using additional ang...
Definition: sac_model_perpendicular_plane.h:71