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

SampleConsensusModelRegistration defines a model for Point-To-Point registration outlier rejection. More...

#include <pcl/sample_consensus/sac_model_registration.h>

+ Inheritance diagram for pcl::SampleConsensusModelRegistration< PointT >:

Public Types

typedef SampleConsensusModel
< PointT >::PointCloud 
PointCloud
 
typedef SampleConsensusModel
< PointT >::PointCloudPtr 
PointCloudPtr
 
typedef SampleConsensusModel
< PointT >::PointCloudConstPtr 
PointCloudConstPtr
 
typedef boost::shared_ptr
< SampleConsensusModelRegistration
Ptr
 
- Public Types inherited from pcl::SampleConsensusModel< PointT >
typedef pcl::PointCloud< PointTPointCloud
 
typedef pcl::PointCloud
< PointT >::ConstPtr 
PointCloudConstPtr
 
typedef pcl::PointCloud
< PointT >::Ptr 
PointCloudPtr
 
typedef pcl::search::Search
< PointT >::Ptr 
SearchPtr
 
typedef boost::shared_ptr
< SampleConsensusModel
Ptr
 
typedef boost::shared_ptr
< const SampleConsensusModel
ConstPtr
 

Public Member Functions

 SampleConsensusModelRegistration (const PointCloudConstPtr &cloud, bool random=false)
 Constructor for base SampleConsensusModelRegistration. More...
 
 SampleConsensusModelRegistration (const PointCloudConstPtr &cloud, const std::vector< int > &indices, bool random=false)
 Constructor for base SampleConsensusModelRegistration. More...
 
virtual ~SampleConsensusModelRegistration ()
 Empty destructor. More...
 
virtual void setInputCloud (const PointCloudConstPtr &cloud)
 Provide a pointer to the input dataset. More...
 
void setInputTarget (const PointCloudConstPtr &target)
 Set the input point cloud target. More...
 
void setInputTarget (const PointCloudConstPtr &target, const std::vector< int > &indices_tgt)
 Set the input point cloud target. More...
 
bool computeModelCoefficients (const std::vector< int > &samples, Eigen::VectorXf &model_coefficients)
 Compute a 4x4 rigid transformation matrix from the samples given. More...
 
void getDistancesToModel (const Eigen::VectorXf &model_coefficients, std::vector< double > &distances)
 Compute all distances from the transformed points to their correspondences. More...
 
void selectWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold, std::vector< int > &inliers)
 Select all the points which respect the given model coefficients as inliers. More...
 
virtual int countWithinDistance (const Eigen::VectorXf &model_coefficients, const double threshold)
 Count all the points which respect the given model coefficients as inliers. More...
 
void optimizeModelCoefficients (const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients)
 Recompute the 4x4 transformation using the given inlier set. More...
 
void projectPoints (const std::vector< int > &, const Eigen::VectorXf &, PointCloud &, bool=true)
 Create a new point cloud with inliers projected onto the model. More...
 
bool doSamplesVerifyModel (const std::set< int > &, const Eigen::VectorXf &, const double)
 Verify whether a subset of indices verifies a given set of model coefficients. More...
 
pcl::SacModel getModelType () const
 Return an unique id for this model (SACMODEL_REGISTRATION). 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 std::vector< int > &indices, bool random=false)
 Constructor for base SampleConsensusModel. More...
 
virtual ~SampleConsensusModel ()
 Destructor for base SampleConsensusModel. More...
 
virtual void getSamples (int &iterations, std::vector< int > &samples)
 Get a set of random data samples and return them as point indices. More...
 
PointCloudConstPtr getInputCloud () const
 Get a pointer to the input point cloud dataset. More...
 
void setIndices (const boost::shared_ptr< std::vector< int > > &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
void setIndices (const std::vector< int > &indices)
 Provide the vector of indices that represents the input data. More...
 
boost::shared_ptr< std::vector
< int > > 
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)
 Get the minimum and maximum allowable radius limits for the model as set by the user. More...
 
void setSamplesMaxDist (const double &radius, SearchPtr search)
 Set the maximum distance allowed when drawing random samples. More...
 
void getSamplesMaxDist (double &radius)
 Get maximum distance allowed when drawing random samples. More...
 
double computeVariance (const std::vector< double > &error_sqr_dists)
 Compute the variance of the errors to the model. More...
 
double computeVariance ()
 Compute the variance of the errors to the model from the internally estimated vector of distances. More...
 

Protected Member Functions

virtual bool isSampleGood (const std::vector< int > &samples) const
 Check if a sample of indices results in a good sample of points indices. More...
 
void computeSampleDistanceThreshold (const PointCloudConstPtr &cloud)
 Computes an "optimal" sample distance threshold based on the principal directions of the input cloud. More...
 
void computeSampleDistanceThreshold (const PointCloudConstPtr &cloud, const std::vector< int > &indices)
 Computes an "optimal" sample distance threshold based on the principal directions of the input cloud. More...
 
void estimateRigidTransformationSVD (const pcl::PointCloud< PointT > &cloud_src, const std::vector< int > &indices_src, const pcl::PointCloud< PointT > &cloud_tgt, const std::vector< int > &indices_tgt, Eigen::VectorXf &transform)
 Estimate a rigid transformation between a source and a target point cloud using an SVD closed-form solution of absolute orientation using unit quaternions. More...
 
void computeOriginalIndexMapping ()
 Compute mappings between original indices of the input_/target_ clouds. More...
 
- Protected Member Functions inherited from pcl::SampleConsensusModel< PointT >
 SampleConsensusModel (bool random=false)
 Empty constructor for base SampleConsensusModel. More...
 
void drawIndexSample (std::vector< int > &sample)
 Fills a sample array with random samples from the indices_ vector. More...
 
void drawIndexSampleRadius (std::vector< int > &sample)
 Fills a sample array with one random sample from the indices_ vector and other random samples that are closer than samples_radius_. More...
 
virtual bool isModelValid (const Eigen::VectorXf &model_coefficients)
 Check whether a model is valid given the user constraints. More...
 
int rnd ()
 Boost-based random number generator. More...
 

Protected Attributes

PointCloudConstPtr target_
 A boost shared pointer to the target point cloud data array. More...
 
boost::shared_ptr< std::vector
< int > > 
indices_tgt_
 A pointer to the vector of target point indices to use. More...
 
std::map< int, int > correspondences_
 Given the index in the original point cloud, give the matching original index in the target cloud. More...
 
double sample_dist_thresh_
 Internal distance threshold used for the sample selection step. More...
 
- 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...
 
boost::shared_ptr< std::vector
< int > > 
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...
 
std::vector< int > shuffled_indices_
 Data containing a shuffled version of the indices. More...
 
boost::mt19937 rng_alg_
 Boost-based random number generator algorithm. More...
 
boost::shared_ptr
< boost::uniform_int<> > 
rng_dist_
 Boost-based random number generator distribution. More...
 
boost::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...
 

Additional Inherited Members

- 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::SampleConsensusModelRegistration< PointT >

SampleConsensusModelRegistration defines a model for Point-To-Point registration outlier rejection.

Author
Radu Bogdan Rusu

Definition at line 58 of file sac_model_registration.h.

Member Typedef Documentation

Definition at line 67 of file sac_model_registration.h.

Definition at line 69 of file sac_model_registration.h.

Definition at line 68 of file sac_model_registration.h.

template<typename PointT>
typedef boost::shared_ptr<SampleConsensusModelRegistration> pcl::SampleConsensusModelRegistration< PointT >::Ptr

Definition at line 71 of file sac_model_registration.h.

Constructor & Destructor Documentation

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

Constructor for base SampleConsensusModelRegistration.

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 77 of file sac_model_registration.h.

References pcl::SampleConsensusModel< PointT >::model_name_, pcl::SampleConsensusModel< PointT >::model_size_, pcl::SampleConsensusModel< PointT >::sample_size_, and pcl::SampleConsensusModelRegistration< PointT >::setInputCloud().

template<typename PointT>
pcl::SampleConsensusModelRegistration< PointT >::SampleConsensusModelRegistration ( const PointCloudConstPtr cloud,
const std::vector< int > &  indices,
bool  random = false 
)
inline

Constructor for base SampleConsensusModelRegistration.

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 97 of file sac_model_registration.h.

References pcl::SampleConsensusModelRegistration< PointT >::computeOriginalIndexMapping(), pcl::SampleConsensusModelRegistration< PointT >::computeSampleDistanceThreshold(), pcl::SampleConsensusModel< PointT >::model_name_, pcl::SampleConsensusModel< PointT >::model_size_, and pcl::SampleConsensusModel< PointT >::sample_size_.

template<typename PointT>
virtual pcl::SampleConsensusModelRegistration< PointT >::~SampleConsensusModelRegistration ( )
inlinevirtual

Empty destructor.

Definition at line 114 of file sac_model_registration.h.

Member Function Documentation

template<typename PointT >
bool pcl::SampleConsensusModelRegistration< PointT >::computeModelCoefficients ( const std::vector< int > &  samples,
Eigen::VectorXf &  model_coefficients 
)
virtual

Compute a 4x4 rigid transformation matrix from the samples given.

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

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 67 of file sac_model_registration.hpp.

template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::computeOriginalIndexMapping ( )
inlineprotected
template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::computeSampleDistanceThreshold ( const PointCloudConstPtr cloud)
inlineprotected

Computes an "optimal" sample distance threshold based on the principal directions of the input cloud.

Parameters
[in]cloudthe const boost shared pointer to a PointCloud message

Definition at line 237 of file sac_model_registration.h.

References pcl::computeMeanAndCovarianceMatrix(), pcl::eigen33(), and pcl::SampleConsensusModelRegistration< PointT >::sample_dist_thresh_.

Referenced by pcl::SampleConsensusModelRegistration< PointT >::SampleConsensusModelRegistration(), and pcl::SampleConsensusModelRegistration< PointT >::setInputCloud().

template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::computeSampleDistanceThreshold ( const PointCloudConstPtr cloud,
const std::vector< int > &  indices 
)
inlineprotected

Computes an "optimal" sample distance threshold based on the principal directions of the input cloud.

Parameters
[in]cloudthe const boost shared pointer to a PointCloud message
indices

Definition at line 266 of file sac_model_registration.h.

References pcl::computeMeanAndCovarianceMatrix(), pcl::eigen33(), and pcl::SampleConsensusModelRegistration< PointT >::sample_dist_thresh_.

template<typename PointT >
int pcl::SampleConsensusModelRegistration< PointT >::countWithinDistance ( const Eigen::VectorXf &  model_coefficients,
const double  threshold 
)
virtual

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 >.

Reimplemented in pcl::SampleConsensusModelRegistration2D< PointT >.

Definition at line 193 of file sac_model_registration.hpp.

template<typename PointT>
bool pcl::SampleConsensusModelRegistration< PointT >::doSamplesVerifyModel ( const std::set< int > &  indices,
const Eigen::VectorXf &  model_coefficients,
const double  threshold 
)
inlinevirtual

Verify whether a subset of indices verifies a given set of model coefficients.

Pure virtual.

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

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 210 of file sac_model_registration.h.

template<typename PointT >
void pcl::SampleConsensusModelRegistration< PointT >::estimateRigidTransformationSVD ( const pcl::PointCloud< PointT > &  cloud_src,
const std::vector< int > &  indices_src,
const pcl::PointCloud< PointT > &  cloud_tgt,
const std::vector< int > &  indices_tgt,
Eigen::VectorXf &  transform 
)
protected

Estimate a rigid transformation between a source and a target point cloud using an SVD closed-form solution of absolute orientation using unit quaternions.

Parameters
[in]cloud_srcthe source point cloud dataset
[in]indices_srcthe vector of indices describing the points of interest in cloud_src
[in]cloud_tgtthe target point cloud dataset
[in]indices_tgtthe vector of indices describing the correspondences of the interest points from indices_src
[out]transformthe resultant transformation matrix (as model coefficients)

This method is an implementation of: Horn, B. “Closed-Form Solution of Absolute Orientation Using Unit Quaternions,” JOSA A, Vol. 4, No. 4, 1987

Definition at line 268 of file sac_model_registration.hpp.

References pcl::umeyama().

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

Compute all distances from the transformed points to their correspondences.

Parameters
[in]model_coefficientsthe 4x4 transformation matrix
[out]distancesthe resultant estimated distances

Implements pcl::SampleConsensusModel< PointT >.

Reimplemented in pcl::SampleConsensusModelRegistration2D< PointT >.

Definition at line 88 of file sac_model_registration.hpp.

template<typename PointT>
pcl::SacModel pcl::SampleConsensusModelRegistration< PointT >::getModelType ( ) const
inlinevirtual

Return an unique id for this model (SACMODEL_REGISTRATION).

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 219 of file sac_model_registration.h.

References pcl::SACMODEL_REGISTRATION.

template<typename PointT >
bool pcl::SampleConsensusModelRegistration< PointT >::isSampleGood ( const std::vector< int > &  samples) const
protectedvirtual

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

Parameters
[in]samplesthe resultant index samples

Implements pcl::SampleConsensusModel< PointT >.

Reimplemented in pcl::SampleConsensusModelRegistration2D< PointT >.

Definition at line 51 of file sac_model_registration.hpp.

template<typename PointT >
void pcl::SampleConsensusModelRegistration< PointT >::optimizeModelCoefficients ( const std::vector< int > &  inliers,
const Eigen::VectorXf &  model_coefficients,
Eigen::VectorXf &  optimized_coefficients 
)
virtual

Recompute the 4x4 transformation using the given inlier set.

Parameters
[in]inliersthe data inliers found as supporting the model
[in]model_coefficientsthe initial guess for the optimization
[out]optimized_coefficientsthe resultant recomputed transformation

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 239 of file sac_model_registration.hpp.

template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::projectPoints ( const std::vector< int > &  inliers,
const Eigen::VectorXf &  model_coefficients,
PointCloud projected_points,
bool  copy_data_fields = true 
)
inlinevirtual

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

Pure virtual.

Parameters
[in]inliersthe data inliers that we want to project on the model
[in]model_coefficientsthe coefficients of a model
[out]projected_pointsthe resultant projected points
[in]copy_data_fieldsset to true (default) if we want the projected_points cloud to be an exact copy of the input dataset minus the point projections on the plane model

Implements pcl::SampleConsensusModel< PointT >.

Definition at line 203 of file sac_model_registration.h.

template<typename PointT >
void pcl::SampleConsensusModelRegistration< PointT >::selectWithinDistance ( const Eigen::VectorXf &  model_coefficients,
const double  threshold,
std::vector< int > &  inliers 
)
virtual

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

Parameters
[in]model_coefficientsthe 4x4 transformation matrix
[in]thresholda maximum admissible distance threshold for determining the inliers from the outliers
[out]inliersthe resultant model inliers

Implements pcl::SampleConsensusModel< PointT >.

Reimplemented in pcl::SampleConsensusModelRegistration2D< PointT >.

Definition at line 134 of file sac_model_registration.hpp.

template<typename PointT>
virtual void pcl::SampleConsensusModelRegistration< PointT >::setInputCloud ( const PointCloudConstPtr cloud)
inlinevirtual
template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::setInputTarget ( const PointCloudConstPtr target)
inline
template<typename PointT>
void pcl::SampleConsensusModelRegistration< PointT >::setInputTarget ( const PointCloudConstPtr target,
const std::vector< int > &  indices_tgt 
)
inline

Set the input point cloud target.

Parameters
[in]targetthe input point cloud target
[in]indices_tgta vector of point indices to be used from target

Definition at line 149 of file sac_model_registration.h.

References pcl::SampleConsensusModelRegistration< PointT >::computeOriginalIndexMapping(), pcl::SampleConsensusModelRegistration< PointT >::indices_tgt_, and pcl::SampleConsensusModelRegistration< PointT >::target_.

Member Data Documentation

template<typename PointT>
std::map<int, int> pcl::SampleConsensusModelRegistration< PointT >::correspondences_
protected

Given the index in the original point cloud, give the matching original index in the target cloud.

Definition at line 324 of file sac_model_registration.h.

Referenced by pcl::SampleConsensusModelRegistration< PointT >::computeOriginalIndexMapping().

template<typename PointT>
boost::shared_ptr<std::vector<int> > pcl::SampleConsensusModelRegistration< PointT >::indices_tgt_
protected
template<typename PointT>
double pcl::SampleConsensusModelRegistration< PointT >::sample_dist_thresh_
protected

Internal distance threshold used for the sample selection step.

Definition at line 327 of file sac_model_registration.h.

Referenced by pcl::SampleConsensusModelRegistration< PointT >::computeSampleDistanceThreshold().

template<typename PointT>
PointCloudConstPtr pcl::SampleConsensusModelRegistration< PointT >::target_
protected

A boost shared pointer to the target point cloud data array.

Definition at line 318 of file sac_model_registration.h.

Referenced by pcl::SampleConsensusModelRegistration< PointT >::setInputTarget().


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