46 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
49 if (cloud->points.empty ())
51 PCL_ERROR (
"[pcl::%s::setInputTarget] Invalid or empty point cloud dataset given!\n", getClassName ().c_str ());
55 target_cloud_updated_ =
true;
59 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
bool
64 PCL_ERROR (
"[pcl::registration::%s::compute] No input target dataset was given!\n", getClassName ().c_str ());
69 if (target_cloud_updated_ && !force_no_recompute_)
71 tree_->setInputCloud (target_);
72 target_cloud_updated_ =
false;
76 if (correspondence_estimation_)
78 correspondence_estimation_->setSearchMethodTarget (tree_, force_no_recompute_);
79 correspondence_estimation_->setSearchMethodSource (tree_reciprocal_, force_no_recompute_reciprocal_);
89 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
bool
94 PCL_ERROR (
"[pcl::registration::%s::compute] No input source dataset was given!\n", getClassName ().c_str ());
98 if (source_cloud_updated_ && !force_no_recompute_reciprocal_)
100 tree_reciprocal_->setInputCloud (input_);
101 source_cloud_updated_ =
false;
107 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline double
109 const std::vector<float> &distances_a,
110 const std::vector<float> &distances_b)
112 unsigned int nr_elem =
static_cast<unsigned int> (std::min (distances_a.size (), distances_b.size ()));
113 Eigen::VectorXf map_a = Eigen::VectorXf::Map (&distances_a[0], nr_elem);
114 Eigen::VectorXf map_b = Eigen::VectorXf::Map (&distances_b[0], nr_elem);
115 return (
static_cast<double> ((map_a - map_b).sum ()) /
static_cast<double> (nr_elem));
119 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline double
122 double fitness_score = 0.0;
128 std::vector<int> nn_indices (1);
129 std::vector<float> nn_dists (1);
133 for (
const auto& point: input_transformed)
136 tree_->nearestKSearch (point, 1, nn_indices, nn_dists);
139 if (nn_dists[0] <= max_range)
142 fitness_score += nn_dists[0];
148 return (fitness_score / nr);
149 return (std::numeric_limits<double>::max ());
154 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
157 align (output, Matrix4::Identity ());
161 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
168 output.
resize (indices_->size ());
170 output.
header = input_->header;
172 if (indices_->size () != input_->size ())
174 output.
width = indices_->size ();
180 output.
height = input_->height;
185 for (std::size_t i = 0; i < indices_->size (); ++i)
186 output[i] = (*input_)[(*indices_)[i]];
189 if (point_representation_ && !force_no_recompute_)
190 tree_->setPointRepresentation (point_representation_);
194 final_transformation_ = transformation_ = previous_transformation_ = Matrix4::Identity ();
198 for (std::size_t i = 0; i < indices_->size (); ++i)
199 output[i].data[3] = 1.0;
201 computeTransformation (output, guess);