43 #include <pcl/console/print.h>
44 #include <pcl/registration/correspondence_sorting.h>
45 #include <pcl/registration/correspondence_types.h>
46 #include <pcl/search/kdtree.h>
47 #include <pcl/point_cloud.h>
50 namespace registration {
56 using Ptr = shared_ptr<CorrespondenceRejector>;
57 using ConstPtr = shared_ptr<const CorrespondenceRejector>;
120 PCL_WARN(
"[pcl::registration::%s::getRejectedQueryIndices] Input correspondences "
121 "not set (lookup of rejected correspondences _not_ possible).\n",
130 inline const std::string&
147 PCL_WARN(
"[pcl::registration::%s::setSourcePoints] This class does not require an "
148 "input source cloud\n",
163 PCL_WARN(
"[pcl::registration::%s::setSourceNormals] This class does not require "
164 "input source normals\n",
178 PCL_WARN(
"[pcl::registration::%s::setTargetPoints] This class does not require an "
179 "input target cloud\n",
194 PCL_WARN(
"[pcl::registration::%s::setTargetNormals] This class does not require "
195 "input target normals\n",
217 using Ptr = shared_ptr<DataContainerInterface>;
218 using ConstPtr = shared_ptr<const DataContainerInterface>;
233 template <
typename Po
intT,
typename NormalT = pcl::Po
intNormal>
249 , input_transformed_()
252 , input_normals_transformed_()
255 , class_name_(
"DataContainer")
256 , needs_normals_(needs_normals)
273 inline PointCloudConstPtr
const
287 target_cloud_updated_ =
true;
291 inline PointCloudConstPtr
const
308 force_no_recompute_ = force_no_recompute;
309 target_cloud_updated_ =
true;
318 input_normals_ = normals;
322 inline NormalsConstPtr
325 return (input_normals_);
334 target_normals_ = normals;
338 inline NormalsConstPtr
341 return (target_normals_);
350 if (target_cloud_updated_ && !force_no_recompute_) {
351 tree_->setInputCloud(target_);
354 std::vector<float> distances(1);
355 if (tree_->nearestKSearch((*input_)[index], 1, indices, distances))
356 return (distances[0]);
357 return (std::numeric_limits<double>::max());
370 return ((src.getVector4fMap() - tgt.getVector4fMap()).squaredNorm());
382 assert(input_normals_ && target_normals_ &&
383 "Normals are not set for the input and target point clouds");
386 return (
static_cast<double>((src.normal[0] * tgt.normal[0]) +
387 (src.normal[1] * tgt.normal[1]) +
388 (src.normal[2] * tgt.normal[2])));
393 PointCloudConstPtr input_;
396 PointCloudPtr input_transformed_;
399 PointCloudConstPtr target_;
402 NormalsConstPtr input_normals_;
405 NormalsPtr input_normals_transformed_;
408 NormalsConstPtr target_normals_;
414 std::string class_name_;
421 bool target_cloud_updated_{
true};
425 bool force_no_recompute_{
false};
428 inline const std::string&
431 return (class_name_);
KdTree represents the base spatial locator class for kd-tree implementations.
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
CorrespondenceRejector represents the base class for correspondence rejection methods
virtual bool requiresSourceNormals() const
See if this rejector requires source normals.
CorrespondenceRejector()=default
Empty constructor.
virtual void setSourceNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source normals.
virtual void getRemainingCorrespondences(const pcl::Correspondences &original_correspondences, pcl::Correspondences &remaining_correspondences)=0
Get a list of valid correspondences after rejection from the original set of correspondences.
virtual void setSourcePoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source cloud.
virtual void setTargetNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target normals.
shared_ptr< const CorrespondenceRejector > ConstPtr
virtual void applyRejection(Correspondences &correspondences)=0
Abstract rejection method.
void getCorrespondences(pcl::Correspondences &correspondences)
Run correspondence rejection.
virtual bool requiresSourcePoints() const
See if this rejector requires source points.
CorrespondencesConstPtr input_correspondences_
The input correspondences.
void getRejectedQueryIndices(const pcl::Correspondences &correspondences, pcl::Indices &indices)
Determine the indices of query points of correspondences that have been rejected, i....
const std::string & getClassName() const
Get a string representation of the name of this class.
shared_ptr< CorrespondenceRejector > Ptr
virtual bool requiresTargetPoints() const
See if this rejector requires a target cloud.
virtual bool requiresTargetNormals() const
See if this rejector requires target normals.
std::string rejection_name_
The name of the rejection method.
virtual ~CorrespondenceRejector()=default
Empty destructor.
CorrespondencesConstPtr getInputCorrespondences()
Get a pointer to the vector of the input correspondences.
virtual void setTargetPoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target cloud.
virtual void setInputCorrespondences(const CorrespondencesConstPtr &correspondences)
Provide a pointer to the vector of the input correspondences.
DataContainer is a container for the input and target point clouds and implements the interface to co...
NormalsConstPtr getTargetNormals()
Get the normals computed on the target point cloud.
void setInputTarget(const PointCloudConstPtr &target)
Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
PointCloudConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
double getCorrespondenceScore(int index) override
Get the correspondence score for a point in the input cloud.
double getCorrespondenceScore(const pcl::Correspondence &corr) override
Get the correspondence score for a given pair of correspondent points.
NormalsConstPtr getInputNormals()
Get the normals computed on the input point cloud.
void setInputSource(const PointCloudConstPtr &cloud)
Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
void setTargetNormals(const NormalsConstPtr &normals)
Set the normals computed on the target point cloud.
double getCorrespondenceScoreFromNormals(const pcl::Correspondence &corr) override
Get the correspondence score for a given pair of correspondent points based on the angle between the ...
void setSearchMethodTarget(const KdTreePtr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the target cloud.
DataContainer(bool needs_normals=false)
Empty constructor.
void setInputNormals(const NormalsConstPtr &normals)
Set the normals computed on the input point cloud.
PointCloudConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.
~DataContainer() override=default
Empty destructor.
DataContainerInterface provides a generic interface for computing correspondence scores between corre...
virtual double getCorrespondenceScore(int index)=0
virtual ~DataContainerInterface()=default
shared_ptr< const DataContainerInterface > ConstPtr
shared_ptr< DataContainerInterface > Ptr
virtual double getCorrespondenceScore(const pcl::Correspondence &)=0
virtual double getCorrespondenceScoreFromNormals(const pcl::Correspondence &)=0
shared_ptr< KdTree< PointT, Tree > > Ptr
shared_ptr< const Correspondences > CorrespondencesConstPtr
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
void getRejectedQueryIndices(const pcl::Correspondences &correspondences_before, const pcl::Correspondences &correspondences_after, Indices &indices, bool presorting_required=true)
Get the query points of correspondences that are present in one correspondence vector but not in the ...
Correspondence represents a match between two entities (e.g., points, descriptors,...
index_t index_query
Index of the query (source) point.
index_t index_match
Index of the matching (target) point.
A point structure representing normal coordinates and the surface curvature estimate.
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
A point structure representing Euclidean xyz coordinates, and the RGB color.