41#ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_H_
42#define PCL_REGISTRATION_IMPL_CORRESPONDENCE_ESTIMATION_H_
44#include <pcl/common/copy_point.h>
45#include <pcl/common/io.h>
51template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
56 if (cloud->points.empty()) {
57 PCL_ERROR(
"[pcl::registration::%s::setInputTarget] Invalid or empty point cloud "
71template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
76 PCL_ERROR(
"[pcl::registration::%s::compute] No input target dataset was given!\n",
95template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
115template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
123 double max_dist_sqr = max_distance * max_distance;
125 correspondences.resize(
indices_->size());
128 std::vector<float> distance(1);
130 unsigned int nr_valid_correspondences = 0;
137 for (
const auto& idx : (*
indices_)) {
138 tree_->nearestKSearch((*
input_)[idx], 1, index, distance);
139 if (distance[0] > max_dist_sqr)
145 correspondences[nr_valid_correspondences++] = corr;
152 for (
const auto& idx : (*indices_)) {
157 tree_->nearestKSearch(pt, 1, index, distance);
158 if (distance[0] > max_dist_sqr)
164 correspondences[nr_valid_correspondences++] = corr;
167 correspondences.resize(nr_valid_correspondences);
171template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
184 double max_dist_sqr = max_distance * max_distance;
186 correspondences.resize(
indices_->size());
188 std::vector<float> distance(1);
190 std::vector<float> distance_reciprocal(1);
192 unsigned int nr_valid_correspondences = 0;
200 for (
const auto& idx : (*
indices_)) {
201 tree_->nearestKSearch((*
input_)[idx], 1, index, distance);
202 if (distance[0] > max_dist_sqr)
205 target_idx = index[0];
208 (*
target_)[target_idx], 1, index_reciprocal, distance_reciprocal);
209 if (distance_reciprocal[0] > max_dist_sqr || idx != index_reciprocal[0])
215 correspondences[nr_valid_correspondences++] = corr;
223 for (
const auto& idx : (*
indices_)) {
228 tree_->nearestKSearch(pt_src, 1, index, distance);
229 if (distance[0] > max_dist_sqr)
232 target_idx = index[0];
239 pt_tgt, 1, index_reciprocal, distance_reciprocal);
240 if (distance_reciprocal[0] > max_dist_sqr || idx != index_reciprocal[0])
246 correspondences[nr_valid_correspondences++] = corr;
249 correspondences.resize(nr_valid_correspondences);
PointCloudConstPtr input_
bool initCompute()
This method should get called before starting the actual computation.
PointCloudTargetConstPtr target_
The input point cloud dataset target.
bool initCompute()
Internal computation initialization.
bool source_cloud_updated_
Variable that stores whether we have a new source cloud, meaning we need to pre-process it again.
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
PointRepresentationConstPtr point_representation_
The point representation used (internal).
IndicesPtr const getIndicesSource()
Get a pointer to the vector of indices used for the source dataset.
void setInputTarget(const PointCloudTargetConstPtr &cloud)
Provide a pointer to the input target (e.g., the point cloud that we want to align the input source t...
const std::string & getClassName() const
Abstract class get name method.
bool target_cloud_updated_
Variable that stores whether we have a new target cloud, meaning we need to pre-process it again.
KdTreePtr tree_
A pointer to the spatial search object used for the target dataset.
PointCloudSourceConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object used for the source dataset.
bool initComputeReciprocal()
Internal computation initialization for reciprocal correspondences.
bool force_no_recompute_reciprocal_
A flag which, if set, means the tree operating on the source cloud will never be recomputed.
IndicesPtr target_indices_
The target point cloud dataset indices.
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
void determineCorrespondences(pcl::Correspondences &correspondences, double max_distance=std::numeric_limits< double >::max()) override
Determine the correspondences between input and target cloud.
void determineReciprocalCorrespondences(pcl::Correspondences &correspondences, double max_distance=std::numeric_limits< double >::max()) override
Determine the reciprocal correspondences between input and target cloud.
void copyPoint(const PointInT &point_in, PointOutT &point_out)
Copy the fields of a source point into a target point.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
bool isSamePointType()
Check if two given point types are the same or not.
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.