Point Cloud Library (PCL)
1.10.1
|
44 #include <pcl/pcl_base.h>
45 #include <pcl/sample_consensus/eigen.h>
46 #include <pcl/sample_consensus/sac_model.h>
47 #include <pcl/sample_consensus/model_types.h>
48 #include <pcl/common/eigen.h>
58 template <
typename Po
intT>
98 const std::vector<int> &indices,
134 int target_size =
static_cast<int> (target->size ());
137 for (
int i = 0; i < target_size; ++i)
150 indices_tgt_.reset (
new std::vector<int> (indices_tgt));
160 Eigen::VectorXf &model_coefficients)
const override;
168 std::vector<double> &distances)
const override;
177 const double threshold,
178 std::vector<int> &inliers)
override;
188 const double threshold)
const override;
197 const Eigen::VectorXf &model_coefficients,
198 Eigen::VectorXf &optimized_coefficients)
const override;
202 const Eigen::VectorXf &,
209 const Eigen::VectorXf &,
210 const double)
const override
228 isSampleGood (
const std::vector<int> &samples)
const override;
238 Eigen::Vector4f xyz_centroid;
239 Eigen::Matrix3f covariance_matrix = Eigen::Matrix3f::Zero ();
244 for (
int i = 0; i < 3; ++i)
245 for (
int j = 0; j < 3; ++j)
246 if (!std::isfinite (covariance_matrix.coeffRef (i, j)))
247 PCL_ERROR (
"[pcl::SampleConsensusModelRegistration::computeSampleDistanceThreshold] Covariance matrix has NaN values! Is the input cloud finite?\n");
249 Eigen::Vector3f eigen_values;
255 PCL_DEBUG (
"[pcl::SampleConsensusModelRegistration::setInputCloud] Estimated a sample selection distance threshold of: %f\n",
sample_dist_thresh_);
265 const std::vector<int> &indices)
268 Eigen::Vector4f xyz_centroid;
269 Eigen::Matrix3f covariance_matrix;
273 for (
int i = 0; i < 3; ++i)
274 for (
int j = 0; j < 3; ++j)
275 if (!std::isfinite (covariance_matrix.coeffRef (i, j)))
276 PCL_ERROR (
"[pcl::SampleConsensusModelRegistration::computeSampleDistanceThreshold] Covariance matrix has NaN values! Is the input cloud finite?\n");
278 Eigen::Vector3f eigen_values;
284 PCL_DEBUG (
"[pcl::SampleConsensusModelRegistration::setInputCloud] Estimated a sample selection distance threshold of: %f\n",
sample_dist_thresh_);
300 const std::vector<int> &indices_src,
302 const std::vector<int> &indices_tgt,
303 Eigen::VectorXf &transform)
const;
311 for (std::size_t i = 0; i <
indices_->size (); ++i)
331 #include <pcl/sample_consensus/impl/sac_model_registration.hpp>
unsigned int computeMeanAndCovarianceMatrix(const pcl::PointCloud< PointT > &cloud, Eigen::Matrix< Scalar, 3, 3 > &covariance_matrix, Eigen::Matrix< Scalar, 4, 1 > ¢roid)
Compute the normalized 3x3 covariance matrix and the centroid of a given set of points in a single lo...
double sample_dist_thresh_
Internal distance threshold used for the sample selection step.
Defines all the PCL and non-PCL macros used.
This file defines compatibility wrappers for low level I/O functions.
shared_ptr< Indices > IndicesPtr
void setInputCloud(const PointCloudConstPtr &cloud) override
Provide a pointer to the input dataset.
pcl::SacModel getModelType() const override
Return a unique id for this model (SACMODEL_REGISTRATION).
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.
void computeSampleDistanceThreshold(const PointCloudConstPtr &cloud)
Computes an "optimal" sample distance threshold based on the principal directions of the input cloud.
bool isSampleGood(const std::vector< int > &samples) const override
Check if a sample of indices results in a good sample of points indices.
unsigned int sample_size_
The size of a sample from which the model is computed.
void optimizeModelCoefficients(const std::vector< int > &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients) const override
Recompute the 4x4 transformation using the given inlier set.
unsigned int model_size_
The number of coefficients in the model.
PointCloud represents the base class in PCL for storing collections of 3D points.
void eigen33(const Matrix &mat, typename Matrix::Scalar &eigenvalue, Vector &eigenvector)
determines the eigenvector and eigenvalue of the smallest eigenvalue of the symmetric positive semi d...
A point structure representing Euclidean xyz coordinates, and the RGB color.
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) const
Estimate a rigid transformation between a source and a target point cloud using an SVD closed-form so...
typename SampleConsensusModel< PointT >::PointCloudConstPtr PointCloudConstPtr
void getDistancesToModel(const Eigen::VectorXf &model_coefficients, std::vector< double > &distances) const override
Compute all distances from the transformed points to their correspondences.
IndicesPtr indices_tgt_
A pointer to the vector of target point indices to use.
IndicesPtr indices_
A pointer to the vector of point indices to use.
shared_ptr< const SampleConsensusModel< PointT > > ConstPtr
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
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.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
void computeOriginalIndexMapping()
Compute mappings between original indices of the input_/target_ clouds.
shared_ptr< SampleConsensusModel< PointT > > Ptr
std::string model_name_
The model name.
std::map< int, int > correspondences_
Given the index in the original point cloud, give the matching original index in the target cloud.
typename PointCloud::ConstPtr PointCloudConstPtr
SampleConsensusModelRegistration(const PointCloudConstPtr &cloud, const std::vector< int > &indices, bool random=false)
Constructor for base SampleConsensusModelRegistration.
bool doSamplesVerifyModel(const std::set< int > &, const Eigen::VectorXf &, const double) const override
Verify whether a subset of indices verifies a given set of model coefficients.
void setInputTarget(const PointCloudConstPtr &target)
Set the input point cloud target.
bool computeModelCoefficients(const std::vector< int > &samples, Eigen::VectorXf &model_coefficients) const override
Compute a 4x4 rigid transformation matrix from the samples given.
void projectPoints(const std::vector< int > &, const Eigen::VectorXf &, PointCloud &, bool=true) const override
Create a new point cloud with inliers projected onto the model.
PointCloudConstPtr target_
A boost shared pointer to the target point cloud data array.
typename PointCloud::Ptr PointCloudPtr
SampleConsensusModel represents the base model class.
void setInputTarget(const PointCloudConstPtr &target, const std::vector< int > &indices_tgt)
Set the input point cloud target.
SampleConsensusModelRegistration defines a model for Point-To-Point registration outlier rejection.
SampleConsensusModelRegistration(const PointCloudConstPtr &cloud, bool random=false)
Constructor for base SampleConsensusModelRegistration.
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
void selectWithinDistance(const Eigen::VectorXf &model_coefficients, const double threshold, std::vector< int > &inliers) override
Select all the points which respect the given model coefficients as inliers.
~SampleConsensusModelRegistration()
Empty destructor.