Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Types | Public Member Functions | Protected Member Functions
pcl::SampleConsensusModelSphere< PointT > Class Template Reference

SampleConsensusModelSphere defines a model for 3D sphere segmentation. More...

#include <pcl/sample_consensus/sac_model_sphere.h>

+ Inheritance diagram for pcl::SampleConsensusModelSphere< PointT >:
+ Collaboration diagram for pcl::SampleConsensusModelSphere< PointT >:

Public Types

using PointCloud = typename SampleConsensusModel< PointT >::PointCloud
 
using PointCloudPtr = typename SampleConsensusModel< PointT >::PointCloudPtr
 
using PointCloudConstPtr = typename SampleConsensusModel< PointT >::PointCloudConstPtr
 
using Ptr = shared_ptr< SampleConsensusModelSphere< PointT > >
 
using ConstPtr = shared_ptr< const SampleConsensusModelSphere< PointT > >
 
- Public Types inherited from pcl::SampleConsensusModel< PointT >
using PointCloud = pcl::PointCloud< PointT >
 
using PointCloudConstPtr = typename PointCloud::ConstPtr
 
using PointCloudPtr = typename PointCloud::Ptr
 
using SearchPtr = typename pcl::search::Search< PointT >::Ptr
 
using Ptr = shared_ptr< SampleConsensusModel< PointT > >
 
using ConstPtr = shared_ptr< const SampleConsensusModel< PointT > >
 

Public Member Functions

 SampleConsensusModelSphere (const PointCloudConstPtr &cloud, bool random=false)
 Constructor for base SampleConsensusModelSphere. More...
 
 SampleConsensusModelSphere (const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
 Constructor for base SampleConsensusModelSphere. More...
 
 ~SampleConsensusModelSphere () override=default
 Empty destructor. More...
 
 SampleConsensusModelSphere (const SampleConsensusModelSphere &source)
 Copy constructor. More...
 
SampleConsensusModelSphereoperator= (const SampleConsensusModelSphere &source)
 Copy constructor. More...
 
bool computeModelCoefficients (const Indices &samples, Eigen::VectorXf &model_coefficients) const override
 Check whether the given index samples can form a valid sphere model, compute the model coefficients from these samples and store them internally in model_coefficients. More...
 
void getDistancesToModel (const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
 Compute all distances from the cloud data to a given sphere model. More...
 
void selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers) override
 Select all the points which respect the given model coefficients as inliers. More...
 
std::size_t countWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold) const override
 Count all the points which respect the given model coefficients as inliers. More...
 
void optimizeModelCoefficients (const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
 Recompute the sphere coefficients using the given inlier set and return them to the user. More...
 
void projectPoints (const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true) const override
 Create a new point cloud with inliers projected onto the sphere model. More...
 
bool doSamplesVerifyModel (const std::set< index_t > &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const override
 Verify whether a subset of indices verifies the given sphere model coefficients. More...
 
pcl::SacModel getModelType () const override
 Return a unique id for this model (SACMODEL_SPHERE). More...
 
- Public Member Functions inherited from pcl::SampleConsensusModel< PointT >
 SampleConsensusModel (const PointCloudConstPtr &cloud, bool random=false)
 Constructor for base SampleConsensusModel. More...
 
 SampleConsensusModel (const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
 Constructor for base SampleConsensusModel. More...
 
virtual ~SampleConsensusModel ()=default
 Destructor for base SampleConsensusModel. More...
 
virtual void getSamples (int &iterations, Indices &samples)
 Get a set of random data samples and return them as point indices. More...
 
virtual void setInputCloud (const PointCloudConstPtr &cloud)
 Provide a pointer to the input dataset. More...
 
PointCloudConstPtr getInputCloud () const
 Get a pointer to the input point cloud dataset. More...
 
void setIndices (const IndicesPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
void setIndices (const Indices &indices)
 Provide the vector of indices that represents the input data. More...
 
IndicesPtr getIndices () const
 Get a pointer to the vector of indices used. More...
 
const std::string & getClassName () const
 Get a string representation of the name of this class. More...
 
unsigned int getSampleSize () const
 Return the size of a sample from which the model is computed. More...
 
unsigned int getModelSize () const
 Return the number of coefficients in the model. More...
 
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 a radius) More...
 
void getRadiusLimits (double &min_radius, double &max_radius) const
 Get the minimum and maximum allowable radius limits for the model as set by the user. More...
 
void setModelConstraints (std::function< bool(const Eigen::VectorXf &)> function)
 This can be used to impose any kind of constraint on the model, e.g. More...
 
void setSamplesMaxDist (const double &radius, SearchPtr search)
 Set the maximum distance allowed when drawing random samples. More...
 
void getSamplesMaxDist (double &radius) const
 Get maximum distance allowed when drawing random samples. More...
 
double computeVariance (const std::vector< double > &error_sqr_dists) const
 Compute the variance of the errors to the model. More...
 
double computeVariance () const
 Compute the variance of the errors to the model from the internally estimated vector of distances. More...
 

Protected Member Functions

bool isModelValid (const Eigen::VectorXf &model_coefficients) const override
 Check whether a model is valid given the user constraints. More...
 
bool isSampleGood (const Indices &samples) const override
 Check if a sample of indices results in a good sample of points indices. More...
 
std::size_t countWithinDistanceStandard (const Eigen::VectorXf &model_coefficients, const double threshold, std::size_t i=0) const
 This implementation uses no SIMD instructions. More...
 
- Protected Member Functions inherited from pcl::SampleConsensusModel< PointT >
 SampleConsensusModel (bool random=false)
 Empty constructor for base SampleConsensusModel. More...
 
void drawIndexSample (Indices &sample)
 Fills a sample array with random samples from the indices_ vector. More...
 
void drawIndexSampleRadius (Indices &sample)
 Fills a sample array with one random sample from the indices_ vector and other random samples that are closer than samples_radius_. More...
 
int rnd ()
 Boost-based random number generator. More...
 

Additional Inherited Members

- Protected Attributes inherited from pcl::SampleConsensusModel< PointT >
std::string model_name_
 The model name. More...
 
PointCloudConstPtr input_
 A boost shared pointer to the point cloud data array. More...
 
IndicesPtr indices_
 A pointer to the vector of point indices to use. More...
 
double radius_min_
 The minimum and maximum radius limits for the model. More...
 
double radius_max_
 
double samples_radius_
 The maximum distance of subsequent samples from the first (radius search) More...
 
SearchPtr samples_radius_search_
 The search object for picking subsequent samples using radius search. More...
 
Indices shuffled_indices_
 Data containing a shuffled version of the indices. More...
 
boost::mt19937 rng_alg_
 Boost-based random number generator algorithm. More...
 
std::shared_ptr< boost::uniform_int<> > rng_dist_
 Boost-based random number generator distribution. More...
 
std::shared_ptr< boost::variate_generator< boost::mt19937 &, boost::uniform_int<> > > rng_gen_
 Boost-based random number generator. More...
 
std::vector< double > error_sqr_dists_
 A vector holding the distances to the computed model. More...
 
unsigned int sample_size_
 The size of a sample from which the model is computed. More...
 
unsigned int model_size_
 The number of coefficients in the model. More...
 
std::function< bool(const Eigen::VectorXf &)> custom_model_constraints_
 A user defined function that takes model coefficients and returns whether the model is acceptable or not. More...
 
- Static Protected Attributes inherited from pcl::SampleConsensusModel< PointT >
static const unsigned int max_sample_checks_ = 1000
 The maximum number of samples to try until we get a good one. More...
 

Detailed Description

template<typename PointT>
class pcl::SampleConsensusModelSphere< PointT >

SampleConsensusModelSphere defines a model for 3D sphere segmentation.

The model coefficients are defined as:

Author
Radu B. Rusu

Definition at line 71 of file sac_model_sphere.h.

Member Typedef Documentation

◆ ConstPtr

template<typename PointT >
using pcl::SampleConsensusModelSphere< PointT >::ConstPtr = shared_ptr<const SampleConsensusModelSphere<PointT> >

Definition at line 86 of file sac_model_sphere.h.

◆ PointCloud

template<typename PointT >
using pcl::SampleConsensusModelSphere< PointT >::PointCloud = typename SampleConsensusModel<PointT>::PointCloud

Definition at line 81 of file sac_model_sphere.h.

◆ PointCloudConstPtr

Definition at line 83 of file sac_model_sphere.h.

◆ PointCloudPtr

Definition at line 82 of file sac_model_sphere.h.

◆ Ptr

template<typename PointT >
using pcl::SampleConsensusModelSphere< PointT >::Ptr = shared_ptr<SampleConsensusModelSphere<PointT> >

Definition at line 85 of file sac_model_sphere.h.

Constructor & Destructor Documentation

◆ SampleConsensusModelSphere() [1/3]

template<typename PointT >
pcl::SampleConsensusModelSphere< PointT >::SampleConsensusModelSphere ( const PointCloudConstPtr cloud,
bool  random = false 
)
inline

Constructor for base SampleConsensusModelSphere.

Parameters
[in]cloudthe input point cloud dataset
[in]randomif true set the random seed to the current time, else set to 12345 (default: false)

Definition at line 92 of file sac_model_sphere.h.

References pcl::SampleConsensusModel< PointT >::model_name_, pcl::SampleConsensusModel< PointT >::model_size_, and pcl::SampleConsensusModel< PointT >::sample_size_.

◆ SampleConsensusModelSphere() [2/3]

template<typename PointT >
pcl::SampleConsensusModelSphere< PointT >::SampleConsensusModelSphere ( const PointCloudConstPtr cloud,
const Indices indices,
bool  random = false 
)
inline

Constructor for base SampleConsensusModelSphere.

Parameters
[in]cloudthe input point cloud dataset
[in]indicesa vector of point indices to be used from cloud
[in]randomif true set the random seed to the current time, else set to 12345 (default: false)

Definition at line 106 of file sac_model_sphere.h.

References pcl::SampleConsensusModel< PointT >::model_name_, pcl::SampleConsensusModel< PointT >::model_size_, and pcl::SampleConsensusModel< PointT >::sample_size_.

◆ ~SampleConsensusModelSphere()

template<typename PointT >
pcl::SampleConsensusModelSphere< PointT >::~SampleConsensusModelSphere ( )
overridedefault

Empty destructor.

◆ SampleConsensusModelSphere() [3/3]

template<typename PointT >
pcl::SampleConsensusModelSphere< PointT >::SampleConsensusModelSphere ( const SampleConsensusModelSphere< PointT > &  source)
inline

Copy constructor.

Parameters
[in]sourcethe model to copy into this

Definition at line 122 of file sac_model_sphere.h.

References pcl::SampleConsensusModel< PointT >::model_name_.

Member Function Documentation

◆ computeModelCoefficients()

template<typename PointT >
bool pcl::SampleConsensusModelSphere< PointT >::computeModelCoefficients ( const Indices samples,
Eigen::VectorXf &  model_coefficients 
) const
overridevirtual

Check whether the given index samples can form a valid sphere model, compute the model coefficients from these samples and store them internally in model_coefficients.

The sphere coefficients are: x, y, z, R.

Parameters
[in]samplesthe point indices found as possible good candidates for creating a valid model
[out]model_coefficientsthe resultant model coefficients

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 60 of file sac_model_sphere.hpp.

◆ countWithinDistance()

template<typename PointT >
std::size_t pcl::SampleConsensusModelSphere< PointT >::countWithinDistance ( const Eigen::VectorXf &  model_coefficients,
const double  threshold 
) const
overridevirtual

Count all the points which respect the given model coefficients as inliers.

Parameters
[in]model_coefficientsthe coefficients of a model that we need to compute distances to
[in]thresholdmaximum admissible distance threshold for determining the inliers from the outliers
Returns
the resultant number of inliers

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 218 of file sac_model_sphere.hpp.

◆ countWithinDistanceStandard()

template<typename PointT >
std::size_t pcl::SampleConsensusModelSphere< PointT >::countWithinDistanceStandard ( const Eigen::VectorXf &  model_coefficients,
const double  threshold,
std::size_t  i = 0 
) const
protected

This implementation uses no SIMD instructions.

It is not intended for normal use. See countWithinDistance which automatically uses the fastest implementation.

Definition at line 236 of file sac_model_sphere.hpp.

◆ doSamplesVerifyModel()

template<typename PointT >
bool pcl::SampleConsensusModelSphere< PointT >::doSamplesVerifyModel ( const std::set< index_t > &  indices,
const Eigen::VectorXf &  model_coefficients,
const double  threshold 
) const
overridevirtual

Verify whether a subset of indices verifies the given sphere model coefficients.

Parameters
[in]indicesthe data indices that need to be tested against the sphere model
[in]model_coefficientsthe sphere model coefficients
[in]thresholda maximum admissible distance threshold for determining the inliers from the outliers

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 457 of file sac_model_sphere.hpp.

◆ getDistancesToModel()

template<typename PointT >
void pcl::SampleConsensusModelSphere< PointT >::getDistancesToModel ( const Eigen::VectorXf &  model_coefficients,
std::vector< double > &  distances 
) const
overridevirtual

Compute all distances from the cloud data to a given sphere model.

Parameters
[in]model_coefficientsthe coefficients of a sphere model that we need to compute distances to
[out]distancesthe resultant estimated distances

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 159 of file sac_model_sphere.hpp.

◆ getModelType()

template<typename PointT >
pcl::SacModel pcl::SampleConsensusModelSphere< PointT >::getModelType ( ) const
inlineoverridevirtual

Return a unique id for this model (SACMODEL_SPHERE).

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 212 of file sac_model_sphere.h.

References pcl::SACMODEL_SPHERE.

◆ isModelValid()

template<typename PointT >
bool pcl::SampleConsensusModelSphere< PointT >::isModelValid ( const Eigen::VectorXf &  model_coefficients) const
inlineoverrideprotectedvirtual

Check whether a model is valid given the user constraints.

Parameters
[in]model_coefficientsthe set of model coefficients

Reimplemented from pcl::SampleConsensusModel< PointT >.

Definition at line 222 of file sac_model_sphere.h.

References pcl::SampleConsensusModel< PointT >::radius_max_, and pcl::SampleConsensusModel< PointT >::radius_min_.

◆ isSampleGood()

template<typename PointT >
bool pcl::SampleConsensusModelSphere< PointT >::isSampleGood ( const Indices samples) const
overrideprotectedvirtual

Check if a sample of indices results in a good sample of points indices.

Parameters
[in]samplesthe resultant index samples

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 48 of file sac_model_sphere.hpp.

◆ operator=()

template<typename PointT >
SampleConsensusModelSphere& pcl::SampleConsensusModelSphere< PointT >::operator= ( const SampleConsensusModelSphere< PointT > &  source)
inline

Copy constructor.

Parameters
[in]sourcethe model to copy into this

Definition at line 133 of file sac_model_sphere.h.

◆ optimizeModelCoefficients()

template<typename PointT >
void pcl::SampleConsensusModelSphere< PointT >::optimizeModelCoefficients ( const Indices inliers,
const Eigen::VectorXf &  model_coefficients,
Eigen::VectorXf &  optimized_coefficients 
) const
overridevirtual

Recompute the sphere coefficients using the given inlier set and return them to the user.

Note
: these are the coefficients of the sphere model after refinement (e.g. after SVD)
Parameters
[in]inliersthe data inliers found as supporting the model
[in]model_coefficientsthe initial guess for the optimization
[out]optimized_coefficientsthe resultant recomputed coefficients after non-linear optimization

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 337 of file sac_model_sphere.hpp.

References pcl::internal::optimizeModelCoefficientsSphere().

◆ projectPoints()

template<typename PointT >
void pcl::SampleConsensusModelSphere< PointT >::projectPoints ( const Indices inliers,
const Eigen::VectorXf &  model_coefficients,
PointCloud projected_points,
bool  copy_data_fields = true 
) const
overridevirtual

Create a new point cloud with inliers projected onto the sphere model.

Parameters
[in]inliersthe data inliers that we want to project on the sphere model
[in]model_coefficientsthe coefficients of a sphere model
[out]projected_pointsthe resultant projected points
[in]copy_data_fieldsset to true if we need to copy the other data fields
Todo:
implement this.

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 374 of file sac_model_sphere.hpp.

References pcl::PointCloud< PointT >::header, pcl::PointCloud< PointT >::height, pcl::PointCloud< PointT >::is_dense, pcl::K, pcl::PointCloud< PointT >::points, pcl::PointCloud< PointT >::resize(), and pcl::PointCloud< PointT >::width.

◆ selectWithinDistance()

template<typename PointT >
void pcl::SampleConsensusModelSphere< PointT >::selectWithinDistance ( const Eigen::VectorXf &  model_coefficients,
const double  threshold,
Indices inliers 
)
overridevirtual

Select all the points which respect the given model coefficients as inliers.

Parameters
[in]model_coefficientsthe coefficients of a sphere model that we need to compute distances to
[in]thresholda maximum admissible distance threshold for determining the inliers from the outliers
[out]inliersthe resultant model inliers

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 182 of file sac_model_sphere.hpp.


The documentation for this class was generated from the following files: