43 #include <pcl/memory.h>
44 #include <pcl/pcl_macros.h>
45 #include <pcl/registration/registration.h>
46 #include <pcl/registration/transformation_estimation_svd.h>
55 template <
typename Po
intSource,
typename Po
intTarget,
typename FeatureT>
86 using Ptr = shared_ptr<SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT> >;
87 using ConstPtr = shared_ptr<const SampleConsensusInitialAlignment<PointSource, PointTarget, FeatureT> >;
93 using Ptr = shared_ptr<ErrorFunctor>;
94 using ConstPtr = shared_ptr<const ErrorFunctor>;
144 reg_name_ =
"SampleConsensusInitialAlignment";
221 getRandomIndex (
int n) {
return (static_cast<int> (n * (rand () / (RAND_MAX + 1.0)))); };
232 std::vector<int> &sample_indices);
243 std::vector<int> &corresponding_indices);
283 #include <pcl/registration/impl/ia_ransac.hpp>
KdTreeFLANN is a generic type of 3D spatial locator using kD-tree structures.
void setCorrespondenceRandomness(int k)
Set the number of neighbors to use when selecting a random feature correspondence.
int nr_samples_
The number of samples to use during each iteration.
shared_ptr< PointCloud< FeatureT > > Ptr
typename KdTreeFLANN< FeatureT >::Ptr FeatureKdTreePtr
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
virtual float operator()(float d) const =0
PointIndices::ConstPtr PointIndicesConstPtr
FeatureKdTreePtr feature_tree_
The KdTree used to compare feature descriptors.
void setNumberOfSamples(int nr_samples)
Set the number of samples to use during each iteration.
pcl::PointCloud< FeatureT > FeatureCloud
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
HuberPenalty(float threshold)
virtual float operator()(float e) const
void setTargetFeatures(const FeatureCloudConstPtr &features)
Provide a shared pointer to the target point cloud's feature descriptors.
void setSourceFeatures(const FeatureCloudConstPtr &features)
Provide a shared pointer to the source point cloud's feature descriptors.
float computeErrorMetric(const PointCloudSource &cloud, float threshold)
An error metric for that computes the quality of the alignment between the given cloud and the target...
shared_ptr< ::pcl::PointIndices > Ptr
SampleConsensusInitialAlignment()
Constructor.
FeatureCloudConstPtr target_features_
The target point cloud's feature descriptors.
int k_correspondences_
The number of neighbors to use when selecting a random feature correspondence.
int max_iterations_
The maximum number of iterations the internal optimization should run for.
typename ErrorFunctor::Ptr ErrorFunctorPtr
FeatureCloudConstPtr const getTargetFeatures()
Get a pointer to the target point cloud's features.
ErrorFunctorPtr getErrorFunction()
Get a shared pointer to the ErrorFunctor that is to be minimized.
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
int getCorrespondenceRandomness()
Get the number of neighbors used when selecting a random feature correspondence, as set by the user...
shared_ptr< const ErrorFunctor > ConstPtr
typename FeatureCloud::Ptr FeatureCloudPtr
Registration represents the base registration class for general purpose, ICP-like methods...
shared_ptr< SampleConsensusInitialAlignment< PointSource, PointTarget, FeatureT > > Ptr
ErrorFunctorPtr error_functor_
typename PointCloudSource::Ptr PointCloudSourcePtr
void selectSamples(const PointCloudSource &cloud, int nr_samples, float min_sample_distance, std::vector< int > &sample_indices)
Select nr_samples sample points from cloud while making sure that their pairwise distances are greate...
SampleConsensusInitialAlignment is an implementation of the initial alignment algorithm described in ...
shared_ptr< ErrorFunctor > Ptr
void setErrorFunction(const ErrorFunctorPtr &error_functor)
Specify the error function to minimize.
typename Registration< PointSource, PointTarget >::PointCloudSource PointCloudSource
FeatureCloudConstPtr const getSourceFeatures()
Get a pointer to the source point cloud's features.
shared_ptr< const ::pcl::PointIndices > ConstPtr
typename Registration< PointSource, PointTarget >::PointCloudTarget PointCloudTarget
FeatureCloudConstPtr input_features_
The source point cloud's feature descriptors.
void findSimilarFeatures(const FeatureCloud &input_features, const std::vector< int > &sample_indices, std::vector< int > &corresponding_indices)
For each of the sample points, find a list of points in the target cloud whose features are similar t...
shared_ptr< const PointCloud< FeatureT > > ConstPtr
int getNumberOfSamples()
Get the number of samples to use during each iteration, as set by the user.
std::string reg_name_
The registration method name.
PointIndices::Ptr PointIndicesPtr
float min_sample_distance_
The minimum distances between samples.
double corr_dist_threshold_
The maximum distance threshold between two correspondent points in source <-> target.
virtual ~ErrorFunctor()=default
void computeTransformation(PointCloudSource &output, const Eigen::Matrix4f &guess) override
Rigid transformation computation method.
float getMinSampleDistance()
Get the minimum distances between samples, as set by the user.
typename FeatureCloud::ConstPtr FeatureCloudConstPtr
shared_ptr< const SampleConsensusInitialAlignment< PointSource, PointTarget, FeatureT > > ConstPtr
TruncatedError(float threshold)
void setMinSampleDistance(float min_sample_distance)
Set the minimum distances between samples.
float operator()(float e) const override
int getRandomIndex(int n)
Choose a random index between 0 and n-1.