41 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_H_ 42 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_H_ 44 #include <pcl/registration/correspondence_types.h> 45 #include <pcl/registration/correspondence_sorting.h> 46 #include <pcl/console/print.h> 47 #include <pcl/common/transforms.h> 48 #include <pcl/point_cloud.h> 49 #include <pcl/search/kdtree.h> 53 namespace registration
62 typedef boost::shared_ptr<CorrespondenceRejector>
Ptr;
63 typedef boost::shared_ptr<const CorrespondenceRejector>
ConstPtr;
122 std::vector<int>& indices)
126 PCL_WARN (
"[pcl::registration::%s::getRejectedQueryIndices] Input correspondences not set (lookup of rejected correspondences _not_ possible).\n",
getClassName ().c_str ());
134 inline const std::string&
147 PCL_WARN (
"[pcl::registration::%s::setSourcePoints] This class does not require an input source cloud",
getClassName ().c_str ());
159 PCL_WARN (
"[pcl::registration::%s::setSourceNormals] This class does not require input source normals",
getClassName ().c_str ());
170 PCL_WARN (
"[pcl::registration::%s::setTargetPoints] This class does not require an input target cloud",
getClassName ().c_str ());
182 PCL_WARN (
"[pcl::registration::%s::setTargetNormals] This class does not require input target normals",
getClassName ().c_str ());
206 virtual double getCorrespondenceScore (
int index) = 0;
215 template <
typename Po
intT,
typename NormalT = pcl::Po
intNormal>
233 , input_transformed_ ()
236 , input_normals_transformed_ ()
239 , class_name_ (
"DataContainer")
240 , needs_normals_ (needs_normals)
241 , target_cloud_updated_ (true)
242 , force_no_recompute_ (false)
253 PCL_DEPRECATED (
"[pcl::registration::DataContainer::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.")
255 setInputCloud (
const PointCloudConstPtr &cloud);
258 PCL_DEPRECATED (
"[pcl::registration::DataContainer::getInputCloud] getInputCloud is deprecated. Please use getInputSource instead.")
259 PointCloudConstPtr
const 273 inline PointCloudConstPtr
const 284 target_cloud_updated_ =
true;
288 inline PointCloudConstPtr
const 300 bool force_no_recompute =
false)
303 if (force_no_recompute)
305 force_no_recompute_ =
true;
307 target_cloud_updated_ =
true;
317 inline NormalsConstPtr
327 inline NormalsConstPtr
336 if ( target_cloud_updated_ && !force_no_recompute_ )
338 tree_->setInputCloud (target_);
340 std::vector<int> indices (1);
341 std::vector<float> distances (1);
342 if (tree_->nearestKSearch (input_->points[index], 1, indices, distances))
343 return (distances[0]);
345 return (std::numeric_limits<double>::max ());
358 return ((src.getVector4fMap () - tgt.getVector4fMap ()).squaredNorm ());
370 assert (input_normals_ && target_normals_ &&
"Normals are not set for the input and target point clouds");
373 return (
double ((src.normal[0] * tgt.normal[0]) + (src.normal[1] * tgt.normal[1]) + (src.normal[2] * tgt.normal[2])));
378 PointCloudConstPtr input_;
381 PointCloudPtr input_transformed_;
384 PointCloudConstPtr target_;
387 NormalsConstPtr input_normals_;
390 NormalsPtr input_normals_transformed_;
393 NormalsConstPtr target_normals_;
399 std::string class_name_;
406 bool target_cloud_updated_;
410 bool force_no_recompute_;
415 inline const std::string&
421 #include <pcl/registration/impl/correspondence_rejection.hpp> A point structure representing normal coordinates and the surface curvature estimate.
virtual bool requiresTargetNormals() const
See if this rejector requires target normals.
DataContainer is a container for the input and target point clouds and implements the interface to co...
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...
int index_match
Index of the matching (target) point.
DataContainerInterface provides a generic interface for computing correspondence scores between corre...
boost::shared_ptr< const CorrespondenceRejector > ConstPtr
virtual void setInputCorrespondences(const CorrespondencesConstPtr &correspondences)
Provide a pointer to the vector of the input correspondences.
CorrespondenceRejector represents the base class for correspondence rejection methods ...
double getCorrespondenceScoreFromNormals(const pcl::Correspondence &corr)
Get the correspondence score for a given pair of correspondent points based on the angle betweeen the...
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 bool requiresSourcePoints() const
See if this rejector requires source points.
void getCorrespondences(pcl::Correspondences &correspondences)
Run correspondence rejection.
Correspondence represents a match between two entities (e.g., points, descriptors, etc).
const std::string & getClassName() const
Get a string representation of the name of this class.
DataContainer(bool needs_normals=false)
Empty constructor.
PointCloudConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
boost::shared_ptr< PointCloud< PointT > > Ptr
int index_query
Index of the query (source) point.
virtual void setTargetPoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target cloud.
CorrespondencesConstPtr getInputCorrespondences()
Get a pointer to the vector of the input correspondences.
void setInputNormals(const NormalsConstPtr &normals)
Set the normals computed on the input point cloud.
boost::shared_ptr< const Correspondences > CorrespondencesConstPtr
boost::shared_ptr< KdTree< PointT, Tree > > Ptr
void setInputSource(const PointCloudConstPtr &cloud)
Provide a source point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
CorrespondenceRejector()
Empty constructor.
boost::shared_ptr< ::pcl::PCLPointCloud2 const > ConstPtr
virtual ~DataContainerInterface()
virtual ~CorrespondenceRejector()
Empty destructor.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void getRejectedQueryIndices(const pcl::Correspondences &correspondences_before, const pcl::Correspondences &correspondences_after, std::vector< int > &indices, bool presorting_required=true)
Get the query points of correspondences that are present in one correspondence vector but not in the ...
NormalsConstPtr getInputNormals()
Get the normals computed on the input point cloud.
virtual void setSourcePoints(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source cloud.
CorrespondencesConstPtr input_correspondences_
The input correspondences.
void setInputTarget(const PointCloudConstPtr &target)
Provide a target point cloud dataset (must contain XYZ data!), used to compute the correspondence dis...
double getCorrespondenceScore(const pcl::Correspondence &corr)
Get the correspondence score for a given pair of correspondent points.
virtual void setSourceNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the source normals.
std::string rejection_name_
The name of the rejection method.
void getRejectedQueryIndices(const pcl::Correspondences &correspondences, std::vector< int > &indices)
Determine the indices of query points of correspondences that have been rejected, i...
virtual void applyRejection(Correspondences &correspondences)=0
Abstract rejection method.
void setTargetNormals(const NormalsConstPtr &normals)
Set the normals computed on the target point cloud.
A point structure representing Euclidean xyz coordinates, and the RGB color.
virtual bool requiresTargetPoints() const
See if this rejector requires a target cloud.
double getCorrespondenceScore(int index)
Get the correspondence score for a point in the input cloud.
boost::shared_ptr< CorrespondenceRejector > Ptr
NormalsConstPtr getTargetNormals()
Get the normals computed on the target point cloud.
virtual bool requiresSourceNormals() const
See if this rejector requires source normals.
virtual void setTargetNormals(pcl::PCLPointCloud2::ConstPtr)
Abstract method for setting the target normals.
virtual ~DataContainer()
Empty destructor.
KdTree represents the base spatial locator class for kd-tree implementations.
PointCloudConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.