Point Cloud Library (PCL)
1.11.1-dev
|
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>;
117 std::vector<int>& indices)
120 PCL_WARN(
"[pcl::registration::%s::getRejectedQueryIndices] Input correspondences "
121 "not set (lookup of rejected correspondences _not_ possible).\n",
130 inline const std::string&
146 PCL_WARN(
"[pcl::registration::%s::setSourcePoints] This class does not require an "
147 "input source cloud\n",
161 PCL_WARN(
"[pcl::registration::%s::setSourceNormals] This class does not require "
162 "input source normals\n",
175 PCL_WARN(
"[pcl::registration::%s::setTargetPoints] This class does not require an "
176 "input target cloud\n",
190 PCL_WARN(
"[pcl::registration::%s::setTargetNormals] This class does not require "
191 "input target normals\n",
213 using Ptr = shared_ptr<DataContainerInterface>;
214 using ConstPtr = shared_ptr<const DataContainerInterface>;
229 template <
typename Po
intT,
typename NormalT = pcl::Po
intNormal>
245 , input_transformed_()
248 , input_normals_transformed_()
251 , class_name_(
"DataContainer")
252 , needs_normals_(needs_normals)
253 , target_cloud_updated_(true)
254 , force_no_recompute_(false)
271 inline PointCloudConstPtr
const
285 target_cloud_updated_ =
true;
289 inline PointCloudConstPtr
const
306 force_no_recompute_ = force_no_recompute;
307 target_cloud_updated_ =
true;
316 input_normals_ = normals;
320 inline NormalsConstPtr
323 return (input_normals_);
332 target_normals_ = normals;
336 inline NormalsConstPtr
339 return (target_normals_);
348 if (target_cloud_updated_ && !force_no_recompute_) {
349 tree_->setInputCloud(target_);
351 std::vector<int> indices(1);
352 std::vector<float> distances(1);
353 if (tree_->nearestKSearch((*input_)[index], 1, indices, distances))
354 return (distances[0]);
355 return (std::numeric_limits<double>::max());
368 return ((src.getVector4fMap() - tgt.getVector4fMap()).squaredNorm());
380 assert(input_normals_ && target_normals_ &&
381 "Normals are not set for the input and target point clouds");
384 return (
double((src.normal[0] * tgt.normal[0]) + (src.normal[1] * tgt.normal[1]) +
385 (src.normal[2] * tgt.normal[2])));
390 PointCloudConstPtr input_;
393 PointCloudPtr input_transformed_;
396 PointCloudConstPtr target_;
399 NormalsConstPtr input_normals_;
402 NormalsPtr input_normals_transformed_;
405 NormalsConstPtr target_normals_;
411 std::string class_name_;
418 bool target_cloud_updated_;
422 bool force_no_recompute_;
425 inline const std::string&
428 return (class_name_);
shared_ptr< CorrespondenceRejector > Ptr
double getCorrespondenceScoreFromNormals(const pcl::Correspondence &corr) override
Get the correspondence score for a given pair of correspondent points based on the angle between the ...
shared_ptr< const DataContainerInterface > ConstPtr
A point structure representing normal coordinates and the surface curvature estimate.
virtual void setInputCorrespondences(const CorrespondencesConstPtr &correspondences)
Provide a pointer to the vector of the input correspondences.
virtual bool requiresTargetNormals() const
See if this rejector requires target normals.
KdTree represents the base spatial locator class for kd-tree implementations.
shared_ptr< const CorrespondenceRejector > ConstPtr
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.
shared_ptr< const Correspondences > CorrespondencesConstPtr
const std::string & getClassName() const
Get a string representation of the name of this class.
NormalsConstPtr getInputNormals()
Get the normals computed on the input point cloud.
PointCloud represents the base class in PCL for storing collections of 3D points.
A point structure representing Euclidean xyz coordinates, and the RGB color.
shared_ptr< KdTree< PointT, Tree > > Ptr
shared_ptr< DataContainerInterface > Ptr
const PointCloudConstPtr getInputTarget()
Get a pointer to the input point cloud dataset target.
void setInputSource(const PointCloudConstPtr &cloud)
Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
DataContainer(bool needs_normals=false)
Empty constructor.
virtual bool requiresSourcePoints() const
See if this rejector requires source points.
void getCorrespondences(pcl::Correspondences &correspondences)
Run correspondence rejection.
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
DataContainerInterface provides a generic interface for computing correspondence scores between corre...
CorrespondencesConstPtr getInputCorrespondences()
Get a pointer to the vector of the input correspondences.
double getCorrespondenceScore(int index) override
Get the correspondence score for a point in the input cloud.
DataContainer is a container for the input and target point clouds and implements the interface to co...
virtual void setTargetPoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target cloud.
NormalsConstPtr getTargetNormals()
Get the normals computed on the target point cloud.
virtual ~CorrespondenceRejector()
Empty destructor.
void setInputNormals(const NormalsConstPtr &normals)
Set the normals computed on the input point cloud.
virtual double getCorrespondenceScore(int index)=0
virtual double getCorrespondenceScoreFromNormals(const pcl::Correspondence &)=0
virtual void setSourcePoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source cloud.
void setTargetNormals(const NormalsConstPtr &normals)
Set the normals computed on the target point cloud.
~DataContainer()
Empty destructor.
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.
const PointCloudConstPtr getInputSource()
Get a pointer to the input point cloud dataset target.
void getRejectedQueryIndices(const pcl::Correspondences &correspondences, std::vector< int > &indices)
Determine the indices of query points of correspondences that have been rejected, i....
virtual ~DataContainerInterface()=default
shared_ptr< PointCloud< PointT > > Ptr
index_t index_match
Index of the matching (target) point.
CorrespondenceRejector()
Empty constructor.
virtual void setTargetNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target normals.
shared_ptr< const PointCloud< PointT > > ConstPtr
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 ...
void setInputTarget(const PointCloudConstPtr &target)
Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
virtual bool requiresSourceNormals() const
See if this rejector requires source normals.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
index_t index_query
Index of the query (source) point.
Correspondence represents a match between two entities (e.g., points, descriptors,...
CorrespondencesConstPtr input_correspondences_
The input correspondences.
std::string rejection_name_
The name of the rejection method.
double getCorrespondenceScore(const pcl::Correspondence &corr) override
Get the correspondence score for a given pair of correspondent points.
virtual void setSourceNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source normals.
virtual bool requiresTargetPoints() const
See if this rejector requires a target cloud.
CorrespondenceRejector represents the base class for correspondence rejection methods
virtual void applyRejection(Correspondences &correspondences)=0
Abstract rejection method.