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

RandomSampleConsensus represents an implementation of the RANSAC (RANdom SAmple Consensus) algorithm, as described in: "Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography", Martin A. More...

#include <pcl/sample_consensus/ransac.h>

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

Public Types

using Ptr = shared_ptr< RandomSampleConsensus< PointT > >
 
using ConstPtr = shared_ptr< const RandomSampleConsensus< PointT > >
 
- Public Types inherited from pcl::SampleConsensus< PointT >
using Ptr = shared_ptr< SampleConsensus< PointT > >
 
using ConstPtr = shared_ptr< const SampleConsensus< PointT > >
 

Public Member Functions

 RandomSampleConsensus (const SampleConsensusModelPtr &model)
 RANSAC (RANdom SAmple Consensus) main constructor. More...
 
 RandomSampleConsensus (const SampleConsensusModelPtr &model, double threshold)
 RANSAC (RANdom SAmple Consensus) main constructor. More...
 
bool computeModel (int debug_verbosity_level=0) override
 Compute the actual model and find the inliers. More...
 
- Public Member Functions inherited from pcl::SampleConsensus< PointT >
 SampleConsensus (const SampleConsensusModelPtr &model, bool random=false)
 Constructor for base SAC. More...
 
 SampleConsensus (const SampleConsensusModelPtr &model, double threshold, bool random=false)
 Constructor for base SAC. More...
 
void setSampleConsensusModel (const SampleConsensusModelPtr &model)
 Set the Sample Consensus model to use. More...
 
SampleConsensusModelPtr getSampleConsensusModel () const
 Get the Sample Consensus model used. More...
 
virtual ~SampleConsensus ()=default
 Destructor for base SAC. More...
 
void setDistanceThreshold (double threshold)
 Set the distance to model threshold. More...
 
double getDistanceThreshold () const
 Get the distance to model threshold, as set by the user. More...
 
void setMaxIterations (int max_iterations)
 Set the maximum number of iterations. More...
 
int getMaxIterations () const
 Get the maximum number of iterations, as set by the user. More...
 
void setProbability (double probability)
 Set the desired probability of choosing at least one sample free from outliers. More...
 
double getProbability () const
 Obtain the probability of choosing at least one sample free from outliers, as set by the user. More...
 
void setNumberOfThreads (const int nr_threads=-1)
 Set the number of threads to use or turn off parallelization. More...
 
int getNumberOfThreads () const
 Get the number of threads, as set by the user. More...
 
virtual bool refineModel (const double sigma=3.0, const unsigned int max_iterations=1000)
 Refine the model found. More...
 
void getRandomSamples (const IndicesPtr &indices, std::size_t nr_samples, std::set< index_t > &indices_subset)
 Get a set of randomly selected indices. More...
 
void getModel (Indices &model) const
 Return the best model found so far. More...
 
void getInliers (Indices &inliers) const
 Return the best set of inliers found so far for this model. More...
 
void getModelCoefficients (Eigen::VectorXf &model_coefficients) const
 Return the model coefficients of the best model found so far. More...
 

Additional Inherited Members

- Protected Member Functions inherited from pcl::SampleConsensus< PointT >
double rnd ()
 Boost-based random number generator. More...
 
- Protected Attributes inherited from pcl::SampleConsensus< PointT >
SampleConsensusModelPtr sac_model_
 The underlying data model used (i.e. More...
 
Indices model_
 The model found after the last computeModel () as point cloud indices. More...
 
Indices inliers_
 The indices of the points that were chosen as inliers after the last computeModel () call. More...
 
Eigen::VectorXf model_coefficients_
 The coefficients of our model computed directly from the model found. More...
 
double probability_
 Desired probability of choosing at least one sample free from outliers. More...
 
int iterations_
 Total number of internal loop iterations that we've done so far. More...
 
double threshold_
 Distance to model threshold. More...
 
int max_iterations_
 Maximum number of iterations before giving up. More...
 
int threads_
 The number of threads the scheduler should use, or a negative number if no parallelization is wanted. More...
 
boost::mt19937 rng_alg_
 Boost-based random number generator algorithm. More...
 
std::shared_ptr< boost::uniform_01< boost::mt19937 > > rng_
 Boost-based random number generator distribution. More...
 

Detailed Description

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

RandomSampleConsensus represents an implementation of the RANSAC (RANdom SAmple Consensus) algorithm, as described in: "Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography", Martin A.

Fischler and Robert C. Bolles, Comm. Of the ACM 24: 381–395, June 1981. A parallel variant is available, enable with setNumberOfThreads. Default is non-parallel.

The algorithm works as follows:

  1. randomly select samples from the cloud, just as many as needed to determine a model
  2. compute the coefficients of the model from the samples
  3. count how many points of the cloud belong to the model, given a threshold. These are called inliers
  4. repeat until a good model has been found or a max number of iterations has been reached
  5. return the model with the most inliers
Author
Radu B. Rusu

Definition at line 65 of file ransac.h.

Member Typedef Documentation

◆ ConstPtr

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

Definition at line 71 of file ransac.h.

◆ Ptr

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

Definition at line 70 of file ransac.h.

Constructor & Destructor Documentation

◆ RandomSampleConsensus() [1/2]

template<typename PointT >
pcl::RandomSampleConsensus< PointT >::RandomSampleConsensus ( const SampleConsensusModelPtr &  model)
inline

RANSAC (RANdom SAmple Consensus) main constructor.

Parameters
[in]modela Sample Consensus model

Definition at line 86 of file ransac.h.

References pcl::SampleConsensus< PointT >::max_iterations_.

◆ RandomSampleConsensus() [2/2]

template<typename PointT >
pcl::RandomSampleConsensus< PointT >::RandomSampleConsensus ( const SampleConsensusModelPtr &  model,
double  threshold 
)
inline

RANSAC (RANdom SAmple Consensus) main constructor.

Parameters
[in]modela Sample Consensus model
[in]thresholddistance to model threshold

Definition at line 97 of file ransac.h.

References pcl::SampleConsensus< PointT >::max_iterations_.

Member Function Documentation

◆ computeModel()

template<typename PointT >
bool pcl::RandomSampleConsensus< PointT >::computeModel ( int  debug_verbosity_level = 0)
overridevirtual

Compute the actual model and find the inliers.

Parameters
[in]debug_verbosity_levelenable/disable on-screen debug information and set the verbosity level

Implements pcl::SampleConsensus< PointT >.

Definition at line 57 of file ransac.hpp.

Referenced by pcl::registration::CorrespondenceRejectorSampleConsensus2D< PointT >::getRemainingCorrespondences(), and pcl::registration::CorrespondenceRejectorSampleConsensus< PointT >::getRemainingCorrespondences().


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