Point Cloud Library (PCL)  1.11.0-dev
sac_model.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #pragma once
42 
43 #include <cfloat>
44 #include <ctime>
45 #include <climits>
46 #include <memory>
47 #include <set>
48 
49 #include <pcl/memory.h>
50 #include <pcl/pcl_macros.h>
51 #include <pcl/pcl_base.h>
52 #include <pcl/console/print.h>
53 #include <pcl/point_cloud.h>
54 #include <pcl/types.h> // for index_t, Indices
55 #include <pcl/sample_consensus/boost.h>
56 #include <pcl/sample_consensus/model_types.h>
57 
58 #include <pcl/search/search.h>
59 
60 namespace pcl
61 {
62  template<class T> class ProgressiveSampleConsensus;
63 
64  /** \brief @b SampleConsensusModel represents the base model class. All sample consensus models must inherit
65  * from this class.
66  * \author Radu B. Rusu
67  * \ingroup sample_consensus
68  */
69  template <typename PointT>
71  {
72  public:
75  using PointCloudPtr = typename PointCloud::Ptr;
77 
78  using Ptr = shared_ptr<SampleConsensusModel<PointT> >;
79  using ConstPtr = shared_ptr<const SampleConsensusModel<PointT> >;
80 
81  protected:
82  /** \brief Empty constructor for base SampleConsensusModel.
83  * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
84  */
85  SampleConsensusModel (bool random = false)
86  : input_ ()
87  , radius_min_ (-std::numeric_limits<double>::max ())
88  , radius_max_ (std::numeric_limits<double>::max ())
89  , samples_radius_ (0.)
91  , rng_dist_ (new boost::uniform_int<> (0, std::numeric_limits<int>::max ()))
92  {
93  // Create a random number generator object
94  if (random)
95  rng_alg_.seed (static_cast<unsigned> (std::time(nullptr)));
96  else
97  rng_alg_.seed (12345u);
98 
99  rng_gen_.reset (new boost::variate_generator<boost::mt19937&, boost::uniform_int<> > (rng_alg_, *rng_dist_));
100  }
101 
102  public:
103  /** \brief Constructor for base SampleConsensusModel.
104  * \param[in] cloud the input point cloud dataset
105  * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
106  */
107  SampleConsensusModel (const PointCloudConstPtr &cloud, bool random = false)
108  : input_ ()
109  , radius_min_ (-std::numeric_limits<double>::max ())
110  , radius_max_ (std::numeric_limits<double>::max ())
111  , samples_radius_ (0.)
113  , rng_dist_ (new boost::uniform_int<> (0, std::numeric_limits<int>::max ()))
114  {
115  if (random)
116  rng_alg_.seed (static_cast<unsigned> (std::time (nullptr)));
117  else
118  rng_alg_.seed (12345u);
119 
120  // Sets the input cloud and creates a vector of "fake" indices
121  setInputCloud (cloud);
122 
123  // Create a random number generator object
124  rng_gen_.reset (new boost::variate_generator<boost::mt19937&, boost::uniform_int<> > (rng_alg_, *rng_dist_));
125  }
126 
127  /** \brief Constructor for base SampleConsensusModel.
128  * \param[in] cloud the input point cloud dataset
129  * \param[in] indices a vector of point indices to be used from \a cloud
130  * \param[in] random if true set the random seed to the current time, else set to 12345 (default: false)
131  */
133  const Indices &indices,
134  bool random = false)
135  : input_ (cloud)
136  , indices_ (new Indices (indices))
137  , radius_min_ (-std::numeric_limits<double>::max ())
138  , radius_max_ (std::numeric_limits<double>::max ())
139  , samples_radius_ (0.)
141  , rng_dist_ (new boost::uniform_int<> (0, std::numeric_limits<int>::max ()))
142  {
143  if (random)
144  rng_alg_.seed (static_cast<unsigned> (std::time(nullptr)));
145  else
146  rng_alg_.seed (12345u);
147 
148  if (indices_->size () > input_->size ())
149  {
150  PCL_ERROR("[pcl::SampleConsensusModel] Invalid index vector given with size "
151  "%zu while the input PointCloud has size %zu!\n",
152  indices_->size(),
153  static_cast<std::size_t>(input_->size()));
154  indices_->clear ();
155  }
157 
158  // Create a random number generator object
159  rng_gen_.reset (new boost::variate_generator<boost::mt19937&, boost::uniform_int<> > (rng_alg_, *rng_dist_));
160  };
161 
162  /** \brief Destructor for base SampleConsensusModel. */
163  virtual ~SampleConsensusModel () {};
164 
165  /** \brief Get a set of random data samples and return them as point
166  * indices.
167  * \param[out] iterations the internal number of iterations used by SAC methods
168  * \param[out] samples the resultant model samples
169  */
170  virtual void
171  getSamples (int &iterations, Indices &samples)
172  {
173  // We're assuming that indices_ have already been set in the constructor
174  if (indices_->size () < getSampleSize ())
175  {
176  PCL_ERROR ("[pcl::SampleConsensusModel::getSamples] Can not select %lu unique points out of %lu!\n",
177  samples.size (), indices_->size ());
178  // one of these will make it stop :)
179  samples.clear ();
180  iterations = INT_MAX - 1;
181  return;
182  }
183 
184  // Get a second point which is different than the first
185  samples.resize (getSampleSize ());
186  for (unsigned int iter = 0; iter < max_sample_checks_; ++iter)
187  {
188  // Choose the random indices
189  if (samples_radius_ < std::numeric_limits<double>::epsilon ())
191  else
193 
194  // If it's a good sample, stop here
195  if (isSampleGood (samples))
196  {
197  PCL_DEBUG ("[pcl::SampleConsensusModel::getSamples] Selected %lu samples.\n", samples.size ());
198  return;
199  }
200  }
201  PCL_DEBUG ("[pcl::SampleConsensusModel::getSamples] WARNING: Could not select %d sample points in %d iterations!\n", getSampleSize (), max_sample_checks_);
202  samples.clear ();
203  }
204 
205  /** \brief Check whether the given index samples can form a valid model,
206  * compute the model coefficients from these samples and store them
207  * in model_coefficients. Pure virtual.
208  * Implementations of this function must be thread-safe.
209  * \param[in] samples the point indices found as possible good candidates
210  * for creating a valid model
211  * \param[out] model_coefficients the computed model coefficients
212  */
213  virtual bool
214  computeModelCoefficients (const Indices &samples,
215  Eigen::VectorXf &model_coefficients) const = 0;
216 
217  /** \brief Recompute the model coefficients using the given inlier set
218  * and return them to the user. Pure virtual.
219  *
220  * @note: these are the coefficients of the model after refinement
221  * (e.g., after a least-squares optimization)
222  *
223  * \param[in] inliers the data inliers supporting the model
224  * \param[in] model_coefficients the initial guess for the model coefficients
225  * \param[out] optimized_coefficients the resultant recomputed coefficients after non-linear optimization
226  */
227  virtual void
228  optimizeModelCoefficients (const Indices &inliers,
229  const Eigen::VectorXf &model_coefficients,
230  Eigen::VectorXf &optimized_coefficients) const = 0;
231 
232  /** \brief Compute all distances from the cloud data to a given model. Pure virtual.
233  *
234  * \param[in] model_coefficients the coefficients of a model that we need to compute distances to
235  * \param[out] distances the resultant estimated distances
236  */
237  virtual void
238  getDistancesToModel (const Eigen::VectorXf &model_coefficients,
239  std::vector<double> &distances) const = 0;
240 
241  /** \brief Select all the points which respect the given model
242  * coefficients as inliers. Pure virtual.
243  *
244  * \param[in] model_coefficients the coefficients of a model that we need to compute distances to
245  * \param[in] threshold a maximum admissible distance threshold for determining the inliers from
246  * the outliers
247  * \param[out] inliers the resultant model inliers
248  */
249  virtual void
250  selectWithinDistance (const Eigen::VectorXf &model_coefficients,
251  const double threshold,
252  Indices &inliers) = 0;
253 
254  /** \brief Count all the points which respect the given model
255  * coefficients as inliers. Pure virtual.
256  * Implementations of this function must be thread-safe.
257  * \param[in] model_coefficients the coefficients of a model that we need to
258  * compute distances to
259  * \param[in] threshold a maximum admissible distance threshold for
260  * determining the inliers from the outliers
261  * \return the resultant number of inliers
262  */
263  virtual std::size_t
264  countWithinDistance (const Eigen::VectorXf &model_coefficients,
265  const double threshold) const = 0;
266 
267  /** \brief Create a new point cloud with inliers projected onto the model. Pure virtual.
268  * \param[in] inliers the data inliers that we want to project on the model
269  * \param[in] model_coefficients the coefficients of a model
270  * \param[out] projected_points the resultant projected points
271  * \param[in] copy_data_fields set to true (default) if we want the \a
272  * projected_points cloud to be an exact copy of the input dataset minus
273  * the point projections on the plane model
274  */
275  virtual void
276  projectPoints (const Indices &inliers,
277  const Eigen::VectorXf &model_coefficients,
278  PointCloud &projected_points,
279  bool copy_data_fields = true) const = 0;
280 
281  /** \brief Verify whether a subset of indices verifies a given set of
282  * model coefficients. Pure virtual.
283  *
284  * \param[in] indices the data indices that need to be tested against the model
285  * \param[in] model_coefficients the set of model coefficients
286  * \param[in] threshold a maximum admissible distance threshold for
287  * determining the inliers from the outliers
288  */
289  virtual bool
290  doSamplesVerifyModel (const std::set<index_t> &indices,
291  const Eigen::VectorXf &model_coefficients,
292  const double threshold) const = 0;
293 
294  /** \brief Provide a pointer to the input dataset
295  * \param[in] cloud the const boost shared pointer to a PointCloud message
296  */
297  inline virtual void
299  {
300  input_ = cloud;
301  if (!indices_)
302  indices_.reset (new Indices ());
303  if (indices_->empty ())
304  {
305  // Prepare a set of indices to be used (entire cloud)
306  indices_->resize (cloud->size ());
307  for (std::size_t i = 0; i < cloud->size (); ++i)
308  (*indices_)[i] = static_cast<index_t> (i);
309  }
311  }
312 
313  /** \brief Get a pointer to the input point cloud dataset. */
314  inline PointCloudConstPtr
315  getInputCloud () const { return (input_); }
316 
317  /** \brief Provide a pointer to the vector of indices that represents the input data.
318  * \param[in] indices a pointer to the vector of indices that represents the input data.
319  */
320  inline void
321  setIndices (const IndicesPtr &indices)
322  {
323  indices_ = indices;
325  }
326 
327  /** \brief Provide the vector of indices that represents the input data.
328  * \param[out] indices the vector of indices that represents the input data.
329  */
330  inline void
331  setIndices (const Indices &indices)
332  {
333  indices_.reset (new Indices (indices));
334  shuffled_indices_ = indices;
335  }
336 
337  /** \brief Get a pointer to the vector of indices used. */
338  inline IndicesPtr
339  getIndices () const { return (indices_); }
340 
341  /** \brief Return a unique id for each type of model employed. */
342  virtual SacModel
343  getModelType () const = 0;
344 
345  /** \brief Get a string representation of the name of this class. */
346  inline const std::string&
347  getClassName () const
348  {
349  return (model_name_);
350  }
351 
352  /** \brief Return the size of a sample from which the model is computed. */
353  inline unsigned int
354  getSampleSize () const
355  {
356  return sample_size_;
357  }
358 
359  /** \brief Return the number of coefficients in the model. */
360  inline unsigned int
361  getModelSize () const
362  {
363  return model_size_;
364  }
365 
366  /** \brief Set the minimum and maximum allowable radius limits for the
367  * model (applicable to models that estimate a radius)
368  * \param[in] min_radius the minimum radius model
369  * \param[in] max_radius the maximum radius model
370  * \todo change this to set limits on the entire model
371  */
372  inline void
373  setRadiusLimits (const double &min_radius, const double &max_radius)
374  {
375  radius_min_ = min_radius;
376  radius_max_ = max_radius;
377  }
378 
379  /** \brief Get the minimum and maximum allowable radius limits for the
380  * model as set by the user.
381  *
382  * \param[out] min_radius the resultant minimum radius model
383  * \param[out] max_radius the resultant maximum radius model
384  */
385  inline void
386  getRadiusLimits (double &min_radius, double &max_radius) const
387  {
388  min_radius = radius_min_;
389  max_radius = radius_max_;
390  }
391 
392  /** \brief Set the maximum distance allowed when drawing random samples
393  * \param[in] radius the maximum distance (L2 norm)
394  * \param search
395  */
396  inline void
397  setSamplesMaxDist (const double &radius, SearchPtr search)
398  {
399  samples_radius_ = radius;
400  samples_radius_search_ = search;
401  }
402 
403  /** \brief Get maximum distance allowed when drawing random samples
404  *
405  * \param[out] radius the maximum distance (L2 norm)
406  */
407  inline void
408  getSamplesMaxDist (double &radius) const
409  {
410  radius = samples_radius_;
411  }
412 
414 
415  /** \brief Compute the variance of the errors to the model.
416  * \param[in] error_sqr_dists a vector holding the distances
417  */
418  inline double
419  computeVariance (const std::vector<double> &error_sqr_dists) const
420  {
421  std::vector<double> dists (error_sqr_dists);
422  const std::size_t medIdx = dists.size () >> 1;
423  std::nth_element (dists.begin (), dists.begin () + medIdx, dists.end ());
424  double median_error_sqr = dists[medIdx];
425  return (2.1981 * median_error_sqr);
426  }
427 
428  /** \brief Compute the variance of the errors to the model from the internally
429  * estimated vector of distances. The model must be computed first (or at least
430  * selectWithinDistance must be called).
431  */
432  inline double
434  {
435  if (error_sqr_dists_.empty ())
436  {
437  PCL_ERROR ("[pcl::SampleConsensusModel::computeVariance] The variance of the Sample Consensus model distances cannot be estimated, as the model has not been computed yet. Please compute the model first or at least run selectWithinDistance before continuing. Returning NAN!\n");
438  return (std::numeric_limits<double>::quiet_NaN ());
439  }
441  }
442 
443  protected:
444 
445  /** \brief Fills a sample array with random samples from the indices_ vector
446  * \param[out] sample the set of indices of target_ to analyze
447  */
448  inline void
450  {
451  std::size_t sample_size = sample.size ();
452  std::size_t index_size = shuffled_indices_.size ();
453  for (std::size_t i = 0; i < sample_size; ++i)
454  // The 1/(RAND_MAX+1.0) trick is when the random numbers are not uniformly distributed and for small modulo
455  // elements, that does not matter (and nowadays, random number generators are good)
456  //std::swap (shuffled_indices_[i], shuffled_indices_[i + (rand () % (index_size - i))]);
457  std::swap (shuffled_indices_[i], shuffled_indices_[i + (rnd () % (index_size - i))]);
458  std::copy (shuffled_indices_.begin (), shuffled_indices_.begin () + sample_size, sample.begin ());
459  }
460 
461  /** \brief Fills a sample array with one random sample from the indices_ vector
462  * and other random samples that are closer than samples_radius_
463  * \param[out] sample the set of indices of target_ to analyze
464  */
465  inline void
467  {
468  std::size_t sample_size = sample.size ();
469  std::size_t index_size = shuffled_indices_.size ();
470 
471  std::swap (shuffled_indices_[0], shuffled_indices_[0 + (rnd () % (index_size - 0))]);
472  //const PointT& pt0 = (*input_)[shuffled_indices_[0]];
473 
474  Indices indices;
475  std::vector<float> sqr_dists;
476 
477  // If indices have been set when the search object was constructed,
478  // radiusSearch() expects an index into the indices vector as its
479  // first parameter. This can't be determined efficiently, so we use
480  // the point instead of the index.
481  // Returned indices are converted automatically.
482  samples_radius_search_->radiusSearch (input_->at(shuffled_indices_[0]),
483  samples_radius_, indices, sqr_dists );
484 
485  if (indices.size () < sample_size - 1)
486  {
487  // radius search failed, make an invalid model
488  for(std::size_t i = 1; i < sample_size; ++i)
490  }
491  else
492  {
493  for (std::size_t i = 0; i < sample_size-1; ++i)
494  std::swap (indices[i], indices[i + (rnd () % (indices.size () - i))]);
495  for (std::size_t i = 1; i < sample_size; ++i)
496  shuffled_indices_[i] = indices[i-1];
497  }
498 
499  std::copy (shuffled_indices_.begin (), shuffled_indices_.begin () + sample_size, sample.begin ());
500  }
501 
502  /** \brief Check whether a model is valid given the user constraints.
503  *
504  * Default implementation verifies that the number of coefficients in the supplied model is as expected for this
505  * SAC model type. Specific SAC models should extend this function by checking the user constraints (if any).
506  *
507  * \param[in] model_coefficients the set of model coefficients
508  */
509  virtual bool
510  isModelValid (const Eigen::VectorXf &model_coefficients) const
511  {
512  if (model_coefficients.size () != model_size_)
513  {
514  PCL_ERROR ("[pcl::%s::isModelValid] Invalid number of model coefficients given (is %lu, should be %lu)!\n", getClassName ().c_str (), model_coefficients.size (), model_size_);
515  return (false);
516  }
517  return (true);
518  }
519 
520  /** \brief Check if a sample of indices results in a good sample of points
521  * indices. Pure virtual.
522  * \param[in] samples the resultant index samples
523  */
524  virtual bool
525  isSampleGood (const Indices &samples) const = 0;
526 
527  /** \brief The model name. */
528  std::string model_name_;
529 
530  /** \brief A boost shared pointer to the point cloud data array. */
532 
533  /** \brief A pointer to the vector of point indices to use. */
535 
536  /** The maximum number of samples to try until we get a good one */
537  static const unsigned int max_sample_checks_ = 1000;
538 
539  /** \brief The minimum and maximum radius limits for the model.
540  * Applicable to all models that estimate a radius.
541  */
543 
544  /** \brief The maximum distance of subsequent samples from the first (radius search) */
546 
547  /** \brief The search object for picking subsequent samples using radius search */
549 
550  /** Data containing a shuffled version of the indices. This is used and modified when drawing samples. */
552 
553  /** \brief Boost-based random number generator algorithm. */
554  boost::mt19937 rng_alg_;
555 
556  /** \brief Boost-based random number generator distribution. */
557  std::shared_ptr<boost::uniform_int<> > rng_dist_;
558 
559  /** \brief Boost-based random number generator. */
560  std::shared_ptr<boost::variate_generator< boost::mt19937&, boost::uniform_int<> > > rng_gen_;
561 
562  /** \brief A vector holding the distances to the computed model. Used internally. */
563  std::vector<double> error_sqr_dists_;
564 
565  /** \brief The size of a sample from which the model is computed. Every subclass should initialize this appropriately. */
566  unsigned int sample_size_;
567 
568  /** \brief The number of coefficients in the model. Every subclass should initialize this appropriately. */
569  unsigned int model_size_;
570 
571  /** \brief Boost-based random number generator. */
572  inline int
573  rnd ()
574  {
575  return ((*rng_gen_) ());
576  }
577  public:
579  };
580 
581  /** \brief @b SampleConsensusModelFromNormals represents the base model class
582  * for models that require the use of surface normals for estimation.
583  */
584  template <typename PointT, typename PointNT>
585  class SampleConsensusModelFromNormals //: public SampleConsensusModel<PointT>
586  {
587  public:
590 
591  using Ptr = shared_ptr<SampleConsensusModelFromNormals<PointT, PointNT> >;
592  using ConstPtr = shared_ptr<const SampleConsensusModelFromNormals<PointT, PointNT> >;
593 
594  /** \brief Empty constructor for base SampleConsensusModelFromNormals. */
596 
597  /** \brief Destructor. */
599 
600  /** \brief Set the normal angular distance weight.
601  * \param[in] w the relative weight (between 0 and 1) to give to the angular
602  * distance (0 to pi/2) between point normals and the plane normal.
603  * (The Euclidean distance will have weight 1-w.)
604  */
605  inline void
606  setNormalDistanceWeight (const double w)
607  {
609  }
610 
611  /** \brief Get the normal angular distance weight. */
612  inline double
614 
615  /** \brief Provide a pointer to the input dataset that contains the point
616  * normals of the XYZ dataset.
617  *
618  * \param[in] normals the const boost shared pointer to a PointCloud message
619  */
620  inline void
622  {
623  normals_ = normals;
624  }
625 
626  /** \brief Get a pointer to the normals of the input XYZ point cloud dataset. */
627  inline PointCloudNConstPtr
628  getInputNormals () const { return (normals_); }
629 
630  protected:
631  /** \brief The relative weight (between 0 and 1) to give to the angular
632  * distance (0 to pi/2) between point normals and the plane normal.
633  */
635 
636  /** \brief A pointer to the input dataset that contains the point normals
637  * of the XYZ dataset.
638  */
640  };
641 
642  /** Base functor all the models that need non linear optimization must
643  * define their own one and implement operator() (const Eigen::VectorXd& x, Eigen::VectorXd& fvec)
644  * or operator() (const Eigen::VectorXf& x, Eigen::VectorXf& fvec) depending on the chosen _Scalar
645  */
646  template<typename _Scalar, int NX=Eigen::Dynamic, int NY=Eigen::Dynamic>
647  struct Functor
648  {
649  using Scalar = _Scalar;
650  enum
651  {
654  };
655 
656  using ValueType = Eigen::Matrix<Scalar,ValuesAtCompileTime,1>;
657  using InputType = Eigen::Matrix<Scalar,InputsAtCompileTime,1>;
658  using JacobianType = Eigen::Matrix<Scalar,ValuesAtCompileTime,InputsAtCompileTime>;
659 
660  /** \brief Empty Constructor. */
661  Functor () : m_data_points_ (ValuesAtCompileTime) {}
662 
663  /** \brief Constructor
664  * \param[in] m_data_points number of data points to evaluate.
665  */
666  Functor (int m_data_points) : m_data_points_ (m_data_points) {}
667 
668  virtual ~Functor () {}
669 
670  /** \brief Get the number of values. */
671  int
672  values () const { return (m_data_points_); }
673 
674  private:
675  const int m_data_points_;
676  };
677 }
pcl::SampleConsensusModel::projectPoints
virtual void projectPoints(const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields=true) const =0
Create a new point cloud with inliers projected onto the model.
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::SampleConsensusModel::~SampleConsensusModel
virtual ~SampleConsensusModel()
Destructor for base SampleConsensusModel.
Definition: sac_model.h:163
pcl
Definition: convolution.h:46
pcl::SampleConsensusModel::SampleConsensusModel
SampleConsensusModel(const PointCloudConstPtr &cloud, const Indices &indices, bool random=false)
Constructor for base SampleConsensusModel.
Definition: sac_model.h:132
pcl::Functor< float >::JacobianType
Eigen::Matrix< Scalar, ValuesAtCompileTime, InputsAtCompileTime > JacobianType
Definition: sac_model.h:658
pcl::IndicesPtr
shared_ptr< Indices > IndicesPtr
Definition: pcl_base.h:61
pcl::SampleConsensusModel::rng_gen_
std::shared_ptr< boost::variate_generator< boost::mt19937 &, boost::uniform_int<> > > rng_gen_
Boost-based random number generator.
Definition: sac_model.h:560
pcl::SampleConsensusModel::samples_radius_search_
SearchPtr samples_radius_search_
The search object for picking subsequent samples using radius search.
Definition: sac_model.h:548
pcl::SampleConsensusModel::isSampleGood
virtual bool isSampleGood(const Indices &samples) const =0
Check if a sample of indices results in a good sample of points indices.
pcl::SampleConsensusModel::setSamplesMaxDist
void setSamplesMaxDist(const double &radius, SearchPtr search)
Set the maximum distance allowed when drawing random samples.
Definition: sac_model.h:397
pcl::SampleConsensusModel::getClassName
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition: sac_model.h:347
types.h
Defines basic non-point types used by PCL.
pcl::SampleConsensusModel::rng_dist_
std::shared_ptr< boost::uniform_int<> > rng_dist_
Boost-based random number generator distribution.
Definition: sac_model.h:557
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:621
pcl::SampleConsensusModelFromNormals
SampleConsensusModelFromNormals represents the base model class for models that require the use of su...
Definition: sac_model.h:585
pcl::SampleConsensusModel::getSamples
virtual void getSamples(int &iterations, Indices &samples)
Get a set of random data samples and return them as point indices.
Definition: sac_model.h:171
pcl::SampleConsensusModelFromNormals::getInputNormals
PointCloudNConstPtr getInputNormals() const
Get a pointer to the normals of the input XYZ point cloud dataset.
Definition: sac_model.h:628
pcl::SampleConsensusModel::getInputCloud
PointCloudConstPtr getInputCloud() const
Get a pointer to the input point cloud dataset.
Definition: sac_model.h:315
pcl::Functor< float >::InputType
Eigen::Matrix< Scalar, InputsAtCompileTime, 1 > InputType
Definition: sac_model.h:657
pcl::SampleConsensusModelFromNormals::getNormalDistanceWeight
double getNormalDistanceWeight() const
Get the normal angular distance weight.
Definition: sac_model.h:613
pcl::SampleConsensusModel::selectWithinDistance
virtual void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, Indices &inliers)=0
Select all the points which respect the given model coefficients as inliers.
pcl::SampleConsensusModel::sample_size_
unsigned int sample_size_
The size of a sample from which the model is computed.
Definition: sac_model.h:566
boost
Definition: boost_graph.h:46
pcl::SampleConsensusModel::getRadiusLimits
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.
Definition: sac_model.h:386
pcl::SampleConsensusModel::model_size_
unsigned int model_size_
The number of coefficients in the model.
Definition: sac_model.h:569
pcl::ProgressiveSampleConsensus
RandomSampleConsensus represents an implementation of the RANSAC (RAndom SAmple Consensus) algorithm,...
Definition: prosac.h:55
pcl::SampleConsensusModel::getSamplesMaxDist
void getSamplesMaxDist(double &radius) const
Get maximum distance allowed when drawing random samples.
Definition: sac_model.h:408
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:53
pcl::SampleConsensusModel::setIndices
void setIndices(const Indices &indices)
Provide the vector of indices that represents the input data.
Definition: sac_model.h:331
pcl::index_t
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
Definition: types.h:120
pcl::SampleConsensusModel< WeightSACPointType >::SearchPtr
typename pcl::search::Search< WeightSACPointType >::Ptr SearchPtr
Definition: sac_model.h:76
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:628
pcl::SampleConsensusModelFromNormals::~SampleConsensusModelFromNormals
virtual ~SampleConsensusModelFromNormals()
Destructor.
Definition: sac_model.h:598
pcl::SampleConsensusModel::countWithinDistance
virtual std::size_t countWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold) const =0
Count all the points which respect the given model coefficients as inliers.
pcl::Functor::values
int values() const
Get the number of values.
Definition: sac_model.h:672
pcl::SampleConsensusModel::optimizeModelCoefficients
virtual void optimizeModelCoefficients(const Indices &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const =0
Recompute the model coefficients using the given inlier set and return them to the user.
pcl::SampleConsensusModelFromNormals::normals_
PointCloudNConstPtr normals_
A pointer to the input dataset that contains the point normals of the XYZ dataset.
Definition: sac_model.h:639
pcl::Functor::Functor
Functor(int m_data_points)
Constructor.
Definition: sac_model.h:666
pcl::SampleConsensusModel::getModelType
virtual SacModel getModelType() const =0
Return a unique id for each type of model employed.
pcl::SampleConsensusModel::max_sample_checks_
static const unsigned int max_sample_checks_
The maximum number of samples to try until we get a good one.
Definition: sac_model.h:537
pcl::Functor::InputsAtCompileTime
@ InputsAtCompileTime
Definition: sac_model.h:652
pcl::SampleConsensusModel::getDistancesToModel
virtual void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const =0
Compute all distances from the cloud data to a given model.
pcl::Functor
Base functor all the models that need non linear optimization must define their own one and implement...
Definition: sac_model.h:647
pcl::SampleConsensusModel::getModelSize
unsigned int getModelSize() const
Return the number of coefficients in the model.
Definition: sac_model.h:361
pcl::SampleConsensusModel::isModelValid
virtual bool isModelValid(const Eigen::VectorXf &model_coefficients) const
Check whether a model is valid given the user constraints.
Definition: sac_model.h:510
pcl::SampleConsensusModelFromNormals::setNormalDistanceWeight
void setNormalDistanceWeight(const double w)
Set the normal angular distance weight.
Definition: sac_model.h:606
pcl::SampleConsensusModel::samples_radius_
double samples_radius_
The maximum distance of subsequent samples from the first (radius search)
Definition: sac_model.h:545
pcl::SacModel
SacModel
Definition: model_types.h:45
pcl::Functor::~Functor
virtual ~Functor()
Definition: sac_model.h:668
pcl::SampleConsensusModel::setIndices
void setIndices(const IndicesPtr &indices)
Provide a pointer to the vector of indices that represents the input data.
Definition: sac_model.h:321
pcl::SampleConsensusModel::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition: sac_model.h:534
pcl::SampleConsensusModel< WeightSACPointType >::ConstPtr
shared_ptr< const SampleConsensusModel< WeightSACPointType > > ConstPtr
Definition: sac_model.h:79
pcl::SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT >::PointCloudNPtr
typename pcl::PointCloud< PointNT >::Ptr PointCloudNPtr
Definition: sac_model.h:589
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:373
pcl::SampleConsensusModelFromNormals::SampleConsensusModelFromNormals
SampleConsensusModelFromNormals()
Empty constructor for base SampleConsensusModelFromNormals.
Definition: sac_model.h:595
pcl::SampleConsensusModel::setInputCloud
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: sac_model.h:298
pcl::SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT >::PointCloudNConstPtr
typename pcl::PointCloud< PointNT >::ConstPtr PointCloudNConstPtr
Definition: sac_model.h:588
pcl::SampleConsensusModel::radius_min_
double radius_min_
The minimum and maximum radius limits for the model.
Definition: sac_model.h:542
pcl::search::Search::Ptr
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
pcl::Functor< float >::ValueType
Eigen::Matrix< Scalar, ValuesAtCompileTime, 1 > ValueType
Definition: sac_model.h:656
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:63
pcl::SampleConsensusModel::drawIndexSample
void drawIndexSample(Indices &sample)
Fills a sample array with random samples from the indices_ vector.
Definition: sac_model.h:449
pcl::SampleConsensusModel::rnd
int rnd()
Boost-based random number generator.
Definition: sac_model.h:573
pcl::SampleConsensusModel< WeightSACPointType >::Ptr
shared_ptr< SampleConsensusModel< WeightSACPointType > > Ptr
Definition: sac_model.h:78
pcl::SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT >::ConstPtr
shared_ptr< const SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT > > ConstPtr
Definition: sac_model.h:592
pcl::SampleConsensusModel::computeModelCoefficients
virtual bool computeModelCoefficients(const Indices &samples, Eigen::VectorXf &model_coefficients) const =0
Check whether the given index samples can form a valid model, compute the model coefficients from the...
pcl::SampleConsensusModel::model_name_
std::string model_name_
The model name.
Definition: sac_model.h:528
pcl::SampleConsensusModel::radius_max_
double radius_max_
Definition: sac_model.h:542
pcl::SampleConsensusModel::getSampleSize
unsigned int getSampleSize() const
Return the size of a sample from which the model is computed.
Definition: sac_model.h:354
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:141
pcl::SampleConsensusModel< WeightSACPointType >::PointCloudConstPtr
typename PointCloud::ConstPtr PointCloudConstPtr
Definition: sac_model.h:74
pcl::SampleConsensusModel::doSamplesVerifyModel
virtual bool doSamplesVerifyModel(const std::set< index_t > &indices, const Eigen::VectorXf &model_coefficients, const double threshold) const =0
Verify whether a subset of indices verifies a given set of model coefficients.
pcl::SampleConsensusModel::SampleConsensusModel
SampleConsensusModel(bool random=false)
Empty constructor for base SampleConsensusModel.
Definition: sac_model.h:85
pcl::SampleConsensusModel::error_sqr_dists_
std::vector< double > error_sqr_dists_
A vector holding the distances to the computed model.
Definition: sac_model.h:563
pcl::PointCloud::Ptr
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:429
pcl::SampleConsensusModel::shuffled_indices_
Indices shuffled_indices_
Data containing a shuffled version of the indices.
Definition: sac_model.h:551
pcl::PointCloud::ConstPtr
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:430
pcl::SampleConsensusModel::drawIndexSampleRadius
void drawIndexSampleRadius(Indices &sample)
Fills a sample array with one random sample from the indices_ vector and other random samples that ar...
Definition: sac_model.h:466
pcl::Functor::Functor
Functor()
Empty Constructor.
Definition: sac_model.h:661
pcl::SampleConsensusModel::computeVariance
double computeVariance(const std::vector< double > &error_sqr_dists) const
Compute the variance of the errors to the model.
Definition: sac_model.h:419
pcl::SampleConsensusModel< WeightSACPointType >::PointCloudPtr
typename PointCloud::Ptr PointCloudPtr
Definition: sac_model.h:75
pcl::SampleConsensusModel::computeVariance
double computeVariance() const
Compute the variance of the errors to the model from the internally estimated vector of distances.
Definition: sac_model.h:433
pcl::SampleConsensusModel
SampleConsensusModel represents the base model class.
Definition: sac_model.h:70
pcl::Functor< float >::Scalar
float Scalar
Definition: sac_model.h:649
pcl::SampleConsensusModel::SampleConsensusModel
SampleConsensusModel(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModel.
Definition: sac_model.h:107
pcl::SampleConsensusModel::input_
PointCloudConstPtr input_
A boost shared pointer to the point cloud data array.
Definition: sac_model.h:531
pcl::Functor::ValuesAtCompileTime
@ ValuesAtCompileTime
Definition: sac_model.h:653
pcl::SampleConsensusModelFromNormals::normal_distance_weight_
double normal_distance_weight_
The relative weight (between 0 and 1) to give to the angular distance (0 to pi/2) between point norma...
Definition: sac_model.h:634
pcl::SampleConsensusModel::rng_alg_
boost::mt19937 rng_alg_
Boost-based random number generator algorithm.
Definition: sac_model.h:554
memory.h
Defines functions, macros and traits for allocating and using memory.
pcl::SampleConsensusModel::getIndices
IndicesPtr getIndices() const
Get a pointer to the vector of indices used.
Definition: sac_model.h:339
pcl::SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT >::Ptr
shared_ptr< SampleConsensusModelFromNormals< pcl::PointXYZRGB, PointNT > > Ptr
Definition: sac_model.h:591