45template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
50 if (cloud->points.empty()) {
51 PCL_ERROR(
"[pcl::%s::setInputSource] Invalid or empty point cloud dataset given!\n",
59template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
64 if (cloud->points.empty()) {
65 PCL_ERROR(
"[pcl::%s::setInputTarget] Invalid or empty point cloud dataset given!\n",
73template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
78 PCL_ERROR(
"[pcl::registration::%s::compute] No input target dataset was given!\n",
103template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
108 PCL_ERROR(
"[pcl::registration::%s::compute] No input source dataset was given!\n",
120template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
123 const std::vector<float>& distances_a,
const std::vector<float>& distances_b)
125 unsigned int nr_elem =
126 static_cast<unsigned int>(std::min(distances_a.size(), distances_b.size()));
127 Eigen::VectorXf map_a = Eigen::VectorXf::Map(distances_a.data(), nr_elem);
128 Eigen::VectorXf map_b = Eigen::VectorXf::Map(distances_b.data(), nr_elem);
129 return (
static_cast<double>((map_a - map_b).sum()) /
static_cast<double>(nr_elem));
132template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
136 double fitness_score = 0.0;
143 std::vector<float> nn_dists(1);
147 for (
const auto& point : input_transformed) {
151 tree_->nearestKSearch(point, 1, nn_indices, nn_dists);
154 if (nn_dists[0] <= max_range) {
156 fitness_score += nn_dists[0];
162 return (fitness_score / nr);
163 return (std::numeric_limits<double>::max());
166template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
170 align(output, Matrix4::Identity());
173template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
191 output.
width =
static_cast<std::uint32_t
>(input_->width);
192 output.
height = input_->height;
197 for (std::size_t i = 0; i < indices_->size(); ++i)
202 tree_->setPointRepresentation(point_representation_);
211 for (std::size_t i = 0; i <
indices_->size(); ++i)
212 output[i].data[3] = 1.0;
PointCloudConstPtr input_
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
bool initCompute()
This method should get called before starting the actual computation.
bool deinitCompute()
This method should get called after finishing the actual computation.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
void resize(std::size_t count)
Resizes the container to contain count elements.
std::uint32_t width
The point cloud width (if organized as an image-structure).
pcl::PCLHeader header
The point cloud header.
std::uint32_t height
The point cloud height (if organized as an image-structure).
bool target_cloud_updated_
Variable that stores whether we have a new target cloud, meaning we need to pre-process it again.
Matrix4 final_transformation_
The final transformation matrix estimated by the registration method after N iterations.
bool initCompute()
Internal computation initialization.
virtual void setInputSource(const PointCloudSourceConstPtr &cloud)
Provide a pointer to the input source (e.g., the point cloud that we want to align to the target)
pcl::PointCloud< PointSource > PointCloudSource
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object of the source.
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
virtual 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...
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
KdTreePtr tree_
A pointer to the spatial search object.
Matrix4 previous_transformation_
Eigen::Matrix< Scalar, 4, 4 > Matrix4
void align(PointCloudSource &output)
Call the registration algorithm which estimates the transformation and returns the transformed source...
double getFitnessScore(double max_range=std::numeric_limits< double >::max())
Obtain the Euclidean fitness score (e.g., mean of squared distances from the source to the target)
bool force_no_recompute_reciprocal_
A flag which, if set, means the tree operating on the source cloud will never be recomputed.
bool initComputeReciprocal()
Internal computation when reciprocal lookup is needed.
virtual void computeTransformation(PointCloudSource &output, const Matrix4 &guess)=0
bool source_cloud_updated_
Variable that stores whether we have a new source cloud, meaning we need to pre-process it again.
PointCloudTargetConstPtr target_
The input point cloud dataset target.
const std::string & getClassName() const
Abstract class get name method.
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const Eigen::Matrix< Scalar, 4, 4 > &transform, bool copy_all_fields)
Apply a rigid transform defined by a 4x4 matrix.
IndicesAllocator<> Indices
Type used for indices in PCL.
constexpr bool isXYZFinite(const PointT &) noexcept