43 #include <pcl/registration/correspondence_rejection.h>
44 #include <pcl/conversions.h>
48 namespace registration {
67 using Ptr = shared_ptr<CorrespondenceRejectorDistance>;
68 using ConstPtr = shared_ptr<const CorrespondenceRejectorDistance>;
73 rejection_name_ =
"CorrespondenceRejectorDistance";
104 return std::sqrt(max_distance_);
111 template <
typename Po
intT>
115 if (!data_container_)
117 static_pointer_cast<DataContainer<PointT>>(data_container_)->setInputSource(cloud);
124 template <
typename Po
intT>
128 if (!data_container_)
130 static_pointer_cast<DataContainer<PointT>>(data_container_)->setInputTarget(target);
146 setInputSource<PointXYZ>(cloud);
162 setInputTarget<PointXYZ>(cloud);
172 template <
typename Po
intT>
175 bool force_no_recompute =
false)
177 static_pointer_cast<DataContainer<PointT>>(data_container_)
178 ->setSearchMethodTarget(tree, force_no_recompute);
188 getRemainingCorrespondences(*input_correspondences_, correspondences);
PointCloud represents the base class in PCL for storing collections of 3D points.
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
CorrespondenceRejectorDistance implements a simple correspondence rejection method based on threshold...
float max_distance_
The maximum distance threshold between two correspondent points in source <-> target.
void applyRejection(pcl::Correspondences &correspondences) override
Apply the rejection algorithm.
DataContainerInterface::Ptr DataContainerPtr
void setSearchMethodTarget(const typename pcl::search::KdTree< PointT >::Ptr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the target cloud.
~CorrespondenceRejectorDistance() override=default
Empty destructor.
bool requiresSourcePoints() const override
See if this rejector requires source points.
float getMaximumDistance() const
Get the maximum distance used for thresholding in correspondence rejection.
void setTargetPoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Method for setting the target cloud.
void getRemainingCorrespondences(const pcl::Correspondences &original_correspondences, pcl::Correspondences &remaining_correspondences) override
Get a list of valid correspondences after rejection from the original set of correspondences.
void setSourcePoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Blob method for setting the source cloud.
virtual void setMaximumDistance(float distance)
Set the maximum distance used for thresholding in correspondence rejection.
void setInputSource(const typename pcl::PointCloud< PointT >::ConstPtr &cloud)
Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
void setInputTarget(const typename pcl::PointCloud< PointT >::ConstPtr &target)
Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
CorrespondenceRejectorDistance()
Empty constructor.
DataContainerPtr data_container_
A pointer to the DataContainer object containing the input and target point clouds.
bool requiresTargetPoints() const override
See if this rejector requires a target cloud.
CorrespondenceRejector represents the base class for correspondence rejection methods
shared_ptr< const CorrespondenceRejector > ConstPtr
CorrespondencesConstPtr input_correspondences_
The input correspondences.
const std::string & getClassName() const
Get a string representation of the name of this class.
shared_ptr< CorrespondenceRejector > Ptr
std::string rejection_name_
The name of the rejection method.
DataContainer is a container for the input and target point clouds and implements the interface to co...
shared_ptr< DataContainerInterface > Ptr
shared_ptr< KdTree< PointT, Tree > > Ptr
Defines functions, macros and traits for allocating and using memory.
float distance(const PointT &p1, const PointT &p2)
void fromPCLPointCloud2(const pcl::PCLPointCloud2 &msg, pcl::PointCloud< PointT > &cloud, const MsgFieldMap &field_map, const std::uint8_t *msg_data)
Convert a PCLPointCloud2 binary data blob into a pcl::PointCloud<T> object using a field_map.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr