42 #include <pcl/registration/correspondence_rejection.h>
43 #include <pcl/conversions.h>
45 #include <pcl/point_cloud.h>
50 namespace registration {
71 using Ptr = shared_ptr<CorrespondenceRejectorVarTrimmed>;
72 using ConstPtr = shared_ptr<const CorrespondenceRejectorVarTrimmed>;
76 : trimmed_distance_(0), factor_(), min_ratio_(0.05), max_ratio_(0.95), lambda_(0.95)
78 rejection_name_ =
"CorrespondenceRejectorVarTrimmed";
95 return trimmed_distance_;
102 template <
typename Po
intT>
106 if (!data_container_)
108 static_pointer_cast<DataContainer<PointT>>(data_container_)->setInputSource(cloud);
115 template <
typename Po
intT>
119 if (!data_container_)
121 static_pointer_cast<DataContainer<PointT>>(data_container_)->setInputTarget(target);
137 setInputSource<PointXYZ>(cloud);
153 setInputTarget<PointXYZ>(cloud);
163 template <
typename Po
intT>
166 bool force_no_recompute =
false)
168 static_pointer_cast<DataContainer<PointT>>(data_container_)
169 ->setSearchMethodTarget(tree, force_no_recompute);
221 getRemainingCorrespondences(*input_correspondences_, correspondences);
259 optimizeInlierRatio(std::vector<double>& dists)
const;
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
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.
CorrespondenceRejectoVarTrimmed implements a simple correspondence rejection method by considering as...
bool requiresSourcePoints() const override
See if this rejector requires source points.
void applyRejection(pcl::Correspondences &correspondences) override
Apply the rejection algorithm.
void setTargetPoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Method for setting the target cloud.
void setMaxRatio(double ratio)
brief set the maximum overlap ratio
double trimmed_distance_
The inlier distance threshold (based on the computed trim factor) between two correspondent points in...
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...
double getMaxRatio() const
brief get the maximum overlap ratio
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 setInputTarget(const typename pcl::PointCloud< PointT >::ConstPtr &target)
Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
DataContainerInterface::Ptr DataContainerPtr
void setSourcePoints(pcl::PCLPointCloud2::ConstPtr cloud2) override
Blob method for setting the source cloud.
double getTrimmedDistance() const
Get the trimmed distance used for thresholding in correspondence rejection.
void setMinRatio(double ratio)
brief set the minimum overlap ratio
CorrespondenceRejectorVarTrimmed()
Empty constructor.
DataContainerPtr data_container_
A pointer to the DataContainer object containing the input and target point clouds.
double lambda_
part of the term that balances the root mean square difference.
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.
double getMinRatio() const
brief get the minimum overlap ratio
double min_ratio_
The minimum overlap ratio between the input and target clouds.
double factor_
The factor for correspondence rejection.
bool requiresTargetPoints() const override
See if this rejector requires a target cloud.
double max_ratio_
The maximum overlap ratio between the input and target clouds.
double getTrimFactor() const
Get the computed inlier ratio used for thresholding in correspondence rejection.
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.
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