ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Registration.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <tuple>
11 #include <vector>
12 
16 
17 namespace cloudViewer {
18 namespace t {
19 
20 namespace geometry {
21 class PointCloud;
22 }
23 
24 namespace pipelines {
25 namespace registration {
26 class Feature;
27 
32 public:
44  double relative_rmse = 1e-6,
45  int max_iteration = 30)
48  max_iteration_(max_iteration) {}
50 
51 public:
60 };
61 
66 public:
72  4, core::Float64, core::Device("CPU:0")))
73  : transformation_(transformation), inlier_rmse_(0.0), fitness_(0.0) {}
74 
76 
77  bool IsBetterThan(const RegistrationResult &other) const {
78  return fitness_ > other.fitness_ || (fitness_ == other.fitness_ &&
79  inlier_rmse_ < other.inlier_rmse_);
80  }
81 
82 public:
90  double inlier_rmse_;
93  double fitness_;
95  bool converged_{false};
97  size_t num_iterations_{0};
98 };
99 
108 RegistrationResult EvaluateRegistration(
109  const geometry::PointCloud &source,
110  const geometry::PointCloud &target,
112  const core::Tensor &transformation =
114 
133 RegistrationResult
134 ICP(const geometry::PointCloud &source,
135  const geometry::PointCloud &target,
136  const double max_correspondence_distance,
137  const core::Tensor &init_source_to_target =
139  const TransformationEstimation &estimation =
140  TransformationEstimationPointToPoint(),
141  const ICPConvergenceCriteria &criteria = ICPConvergenceCriteria(),
142  const double voxel_size = -1.0,
143  const std::function<void(const std::unordered_map<std::string, core::Tensor>
144  &)> &callback_after_iteration = nullptr);
145 
171 RegistrationResult MultiScaleICP(
172  const geometry::PointCloud &source,
173  const geometry::PointCloud &target,
174  const std::vector<double> &voxel_sizes,
175  const std::vector<ICPConvergenceCriteria> &criteria_list,
176  const std::vector<double> &max_correspondence_distances,
177  const core::Tensor &init_source_to_target =
179  const TransformationEstimation &estimation =
180  TransformationEstimationPointToPoint(),
181  const std::function<
182  void(const std::unordered_map<std::string, core::Tensor> &)>
183  &callback_after_iteration = nullptr);
184 
196  const geometry::PointCloud &target,
197  const double max_correspondence_distance,
198  const core::Tensor &transformation);
199 
200 } // namespace registration
201 } // namespace pipelines
202 } // namespace t
203 } // namespace cloudViewer
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Definition: Tensor.cpp:418
A point cloud contains a list of 3D points.
Definition: PointCloud.h:82
Class that defines the convergence criteria of ICP.
Definition: Registration.h:31
ICPConvergenceCriteria(double relative_fitness=1e-6, double relative_rmse=1e-6, int max_iteration=30)
Parameterized Constructor. ICP algorithm stops if the relative change of fitness and rmse hit relativ...
Definition: Registration.h:43
int max_iteration_
Maximum iteration before iteration stops.
Definition: Registration.h:59
bool IsBetterThan(const RegistrationResult &other) const
Definition: Registration.h:77
core::Tensor transformation_
The estimated transformation matrix of dtype Float64 on CPU device.
Definition: Registration.h:84
bool converged_
Specifies whether the algorithm converged or not.
Definition: Registration.h:95
RegistrationResult(const core::Tensor &transformation=core::Tensor::Eye(4, core::Float64, core::Device("CPU:0")))
Parameterized Constructor.
Definition: Registration.h:71
size_t num_iterations_
Number of iterations the algorithm took to converge.
Definition: Registration.h:97
double inlier_rmse_
RMSE of all inlier correspondences. Lower is better.
Definition: Registration.h:90
const Dtype Float64
Definition: Dtype.cpp:43
::ccPointCloud PointCloud
Definition: PointCloud.h:19
core::Tensor GetInformationMatrix(const geometry::PointCloud &source, const geometry::PointCloud &target, const double max_correspondence_distance, const core::Tensor &transformation)
Computes Information Matrix, from the transfromation between source and target pointcloud....
static const double max_correspondence_distance
RegistrationResult ICP(const geometry::PointCloud &source, const geometry::PointCloud &target, const double max_correspondence_distance, const core::Tensor &init_source_to_target, const TransformationEstimation &estimation, const ICPConvergenceCriteria &criteria, const double voxel_size, const std::function< void(const std::unordered_map< std::string, core::Tensor > &)> &callback_after_iteration)
Functions for ICP registration.
RegistrationResult EvaluateRegistration(const geometry::PointCloud &source, const geometry::PointCloud &target, double max_correspondence_distance, const core::Tensor &transformation)
Function for evaluating registration between point clouds.
RegistrationResult MultiScaleICP(const geometry::PointCloud &source, const geometry::PointCloud &target, const std::vector< double > &voxel_sizes, const std::vector< ICPConvergenceCriteria > &criterias, const std::vector< double > &max_correspondence_distances, const core::Tensor &init_source_to_target, const TransformationEstimation &estimation, const std::function< void(const std::unordered_map< std::string, core::Tensor > &)> &callback_after_iteration)
Functions for Multi-Scale ICP registration. It will run ICP on different voxel level,...
Generic file read and write utility for python interface.