41#ifndef PCL_REGISTRATION_IMPL_ICP_HPP_
42#define PCL_REGISTRATION_IMPL_ICP_HPP_
44#include <pcl/correspondence.h>
48template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
53 Eigen::Vector4f pt(0.0f, 0.0f, 0.0f, 1.0f), pt_t;
54 Eigen::Matrix4f tr = transform.template cast<float>();
59 Eigen::Vector3f nt, nt_t;
60 Eigen::Matrix3f rot = tr.block<3, 3>(0, 0);
62 for (std::size_t i = 0; i < input.size(); ++i) {
63 const std::uint8_t* data_in =
reinterpret_cast<const std::uint8_t*
>(&input[i]);
64 std::uint8_t* data_out =
reinterpret_cast<std::uint8_t*
>(&output[i]);
69 if (!std::isfinite(pt[0]) || !std::isfinite(pt[1]) || !std::isfinite(pt[2]))
82 if (!std::isfinite(nt[0]) || !std::isfinite(nt[1]) || !std::isfinite(nt[2]))
93 for (std::size_t i = 0; i < input.size(); ++i) {
94 const std::uint8_t* data_in =
reinterpret_cast<const std::uint8_t*
>(&input[i]);
95 std::uint8_t* data_out =
reinterpret_cast<std::uint8_t*
>(&output[i]);
100 if (!std::isfinite(pt[0]) || !std::isfinite(pt[1]) || !std::isfinite(pt[2]))
112template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
127 if (guess != Matrix4::Identity()) {
128 input_transformed->resize(
input_->size());
133 *input_transformed = *
input_;
150 if (rej->requiresTargetPoints())
151 rej->setTargetPoints(target_blob);
153 rej->setTargetNormals(target_blob);
191 PCL_DEBUG(
"Applying a correspondence rejector method: %s.\n",
192 rej->getClassName().c_str());
193 if (rej->requiresSourcePoints())
194 rej->setSourcePoints(input_transformed_blob);
196 rej->setSourceNormals(input_transformed_blob);
197 rej->setInputCorrespondences(temp_correspondences);
207 PCL_ERROR(
"[pcl::%s::computeTransformation] Not enough correspondences found. "
208 "Relax your threshold parameters.\n",
212 Scalar>::CONVERGENCE_CRITERIA_NO_CORRESPONDENCES);
233 converged_ =
static_cast<bool>((*convergence_criteria_));
236 Scalar>::CONVERGENCE_CRITERIA_NOT_CONVERGED);
239 PCL_DEBUG(
"Transformation "
240 "is:\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%5f\t%5f\t%5f\t%5f\n\t%"
241 "5f\t%5f\t%5f\t%5f\n",
265template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
276 PCL_WARN(
"[pcl::%s::determineRequiredBlobData] Estimator expects source normals, "
277 "but we can't provide them.\n",
281 PCL_WARN(
"[pcl::%s::determineRequiredBlobData] Estimator expects target normals, "
282 "but we can't provide them.\n",
286 for (std::size_t i = 0; i < correspondence_rejectors_.size(); i++) {
288 need_source_blob_ |= rej->requiresSourcePoints();
289 need_source_blob_ |= rej->requiresSourceNormals();
290 need_target_blob_ |= rej->requiresTargetPoints();
293 PCL_WARN(
"[pcl::%s::determineRequiredBlobData] Rejector %s expects source "
294 "normals, but we can't provide them.\n",
296 rej->getClassName().c_str());
298 if (rej->requiresTargetNormals() && !target_has_normals_) {
299 PCL_WARN(
"[pcl::%s::determineRequiredBlobData] Rejector %s expects target "
300 "normals, but we can't provide them.\n",
301 getClassName().c_str(),
302 rej->getClassName().c_str());
307template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
typename Registration< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
std::size_t y_idx_offset_
std::size_t nz_idx_offset_
bool use_reciprocal_correspondence_
The correspondence type used for correspondence estimation.
std::size_t ny_idx_offset_
bool need_source_blob_
Checks for whether estimators and rejectors need various data.
pcl::registration::DefaultConvergenceCriteria< Scalar >::Ptr convergence_criteria_
bool source_has_normals_
Internal check whether source dataset has normals or not.
virtual void transformCloud(const PointCloudSource &input, PointCloudSource &output, const Matrix4 &transform)
Apply a rigid transform to a given dataset.
virtual void determineRequiredBlobData()
Looks at the Estimators and Rejectors and determines whether their blob-setter methods need to be cal...
std::size_t nx_idx_offset_
Normal fields offset.
typename Registration< PointSource, PointTarget, Scalar >::PointCloudSource PointCloudSource
void computeTransformation(PointCloudSource &output, const Matrix4 &guess) override
Rigid transformation computation method with initial guess.
bool target_has_normals_
Internal check whether target dataset has normals or not.
typename PointCloudSource::Ptr PointCloudSourcePtr
std::size_t z_idx_offset_
std::size_t x_idx_offset_
XYZ fields offset.
typename IterativeClosestPoint< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
typename IterativeClosestPoint< PointSource, PointTarget, Scalar >::PointCloudSource PointCloudSource
virtual void transformCloud(const PointCloudSource &input, PointCloudSource &output, const Matrix4 &transform)
Apply a rigid transform to a given dataset.
PointCloudConstPtr input_
Matrix4 final_transformation_
double corr_dist_threshold_
CorrespondenceEstimationPtr correspondence_estimation_
Matrix4 previous_transformation_
CorrespondencesPtr correspondences_
TransformationEstimationPtr transformation_estimation_
double transformation_rotation_epsilon_
double euclidean_fitness_epsilon_
double transformation_epsilon_
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
int min_number_correspondences_
PointCloudTargetConstPtr target_
const std::string & getClassName() const
shared_ptr< CorrespondenceRejector > Ptr
DefaultConvergenceCriteria represents an instantiation of ConvergenceCriteria, and implements the fol...
void transformPointCloudWithNormals(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const Eigen::Matrix< Scalar, 4, 4 > &transform, bool copy_all_fields)
Transform a point cloud and rotate its normals using an Eigen transform.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
shared_ptr< Correspondences > CorrespondencesPtr
void toPCLPointCloud2(const pcl::PointCloud< PointT > &cloud, pcl::PCLPointCloud2 &msg)
Convert a pcl::PointCloud<T> object to a PCLPointCloud2 binary data blob.
shared_ptr< ::pcl::PCLPointCloud2 > Ptr