43#include <pcl/sample_consensus/sac_model.h>
44#include <pcl/pcl_base.h>
46#include <boost/random/mersenne_twister.hpp>
47#include <boost/random/uniform_01.hpp>
88 rng_->base ().seed (
static_cast<unsigned> (std::time (
nullptr)));
90 rng_->base ().seed (12345u);
111 rng_->base ().seed (
static_cast<unsigned> (std::time (
nullptr)));
113 rng_->base ().seed (12345u);
126 SampleConsensusModelPtr
193 PCL_ERROR (
"[pcl::SampleConsensus::refineModel] Critical error: NULL model!\n");
225 double variance =
sac_model_->computeVariance ();
264 PCL_ERROR (
"[pcl::SampleConsensus::refineModel] Refinement failed: got an empty set of inliers!\n");
270 PCL_DEBUG (
"[pcl::SampleConsensus::refineModel] Detected oscillations in the model refinement.\n");
350 std::shared_ptr<boost::uniform_01<boost::mt19937> >
rng_;
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
SampleConsensus represents the base class.
double probability_
Desired probability of choosing at least one sample free from outliers.
std::shared_ptr< boost::uniform_01< boost::mt19937 > > rng_
Boost-based random number generator distribution.
virtual ~SampleConsensus()
Destructor for base SAC.
SampleConsensusModelPtr getSampleConsensusModel() const
Get the Sample Consensus model used.
shared_ptr< SampleConsensus< T > > Ptr
double getDistanceThreshold() const
Get the distance to model threshold, as set by the user.
boost::mt19937 rng_alg_
Boost-based random number generator algorithm.
int getNumberOfThreads() const
Get the number of threads, as set by the user.
Indices inliers_
The indices of the points that were chosen as inliers after the last computeModel () call.
int getMaxIterations() const
Get the maximum number of iterations, as set by the user.
void getInliers(Indices &inliers) const
Return the best set of inliers found so far for this model.
int iterations_
Total number of internal loop iterations that we've done so far.
void getRandomSamples(const IndicesPtr &indices, std::size_t nr_samples, std::set< index_t > &indices_subset)
Get a set of randomly selected indices.
virtual bool computeModel(int debug_verbosity_level=0)=0
Compute the actual model.
Indices model_
The model found after the last computeModel () as point cloud indices.
double rnd()
Boost-based random number generator.
void setNumberOfThreads(const int nr_threads=-1)
Set the number of threads to use or turn off parallelization.
void getModel(Indices &model) const
Return the best model found so far.
void getModelCoefficients(Eigen::VectorXf &model_coefficients) const
Return the model coefficients of the best model found so far.
Eigen::VectorXf model_coefficients_
The coefficients of our model computed directly from the model found.
double threshold_
Distance to model threshold.
SampleConsensusModelPtr sac_model_
The underlying data model used (i.e.
int threads_
The number of threads the scheduler should use, or a negative number if no parallelization is wanted.
SampleConsensus(const SampleConsensusModelPtr &model, double threshold, bool random=false)
Constructor for base SAC.
double getProbability() const
Obtain the probability of choosing at least one sample free from outliers, as set by the user.
int max_iterations_
Maximum number of iterations before giving up.
void setSampleConsensusModel(const SampleConsensusModelPtr &model)
Set the Sample Consensus model to use.
void setProbability(double probability)
Set the desired probability of choosing at least one sample free from outliers.
void setDistanceThreshold(double threshold)
Set the distance to model threshold.
SampleConsensus(const SampleConsensusModelPtr &model, bool random=false)
Constructor for base SAC.
virtual bool refineModel(const double sigma=3.0, const unsigned int max_iterations=1000)
Refine the model found.
void setMaxIterations(int max_iterations)
Set the maximum number of iterations.
shared_ptr< SampleConsensusModel< PointT > > Ptr
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
shared_ptr< Indices > IndicesPtr