ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
TransformationEstimation.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 <Eigen.h>
11 
12 #include <string>
13 #include <utility>
14 
15 #include "pipelines/registration/RobustKernel.h"
16 
17 class ccPointCloud;
18 namespace cloudViewer {
19 
20 namespace pipelines {
21 namespace registration {
22 
23 typedef std::vector<Eigen::Vector2i> CorrespondenceSet;
24 
26  Unspecified = 0,
27  PointToPoint = 1,
28  PointToPlane = 2,
29  ColoredICP = 3,
30  GeneralizedICP = 4,
31 };
32 
39 public:
43 
44 public:
46  const = 0;
53  virtual double ComputeRMSE(const ccPointCloud &source,
54  const ccPointCloud &target,
55  const CorrespondenceSet &corres) const = 0;
62  virtual Eigen::Matrix4d ComputeTransformation(
63  const ccPointCloud &source,
64  const ccPointCloud &target,
65  const CorrespondenceSet &corres) const = 0;
66 };
67 
72 public:
77  TransformationEstimationPointToPoint(bool with_scaling = false)
78  : with_scaling_(with_scaling) {}
80 
81 public:
83  const override {
84  return type_;
85  }
86  double ComputeRMSE(const ccPointCloud &source,
87  const ccPointCloud &target,
88  const CorrespondenceSet &corres) const override;
89  Eigen::Matrix4d ComputeTransformation(
90  const ccPointCloud &source,
91  const ccPointCloud &target,
92  const CorrespondenceSet &corres) const override;
93 
94 public:
101  bool with_scaling_ = false;
102 
103 private:
104  const TransformationEstimationType type_ =
106 };
107 
112 public:
116 
120  std::shared_ptr<RobustKernel> kernel)
121  : kernel_(std::move(kernel)) {}
122 
123 public:
125  const override {
126  return type_;
127  };
128  double ComputeRMSE(const ccPointCloud &source,
129  const ccPointCloud &target,
130  const CorrespondenceSet &corres) const override;
131  Eigen::Matrix4d ComputeTransformation(
132  const ccPointCloud &source,
133  const ccPointCloud &target,
134  const CorrespondenceSet &corres) const override;
135 
136 public:
138  std::shared_ptr<RobustKernel> kernel_ = std::make_shared<L2Loss>();
139 
140 private:
141  const TransformationEstimationType type_ =
143 };
144 
145 } // namespace registration
146 } // namespace pipelines
147 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::t::pipelines::kernel::RtToTransformation
core::Tensor RtToTransformation(const core::Tensor &R, const core::Tensor &t)
Convert rotation and translation to the transformation matrix.
Definition: TransformationConverter.cpp:25
Registration.h
cloudViewer::core::Tensor::GetDtype
Dtype GetDtype() const
Definition: Tensor.h:1164
cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE
double ComputeRMSE(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences) const override
Computes RMSE (double) for PointToPoint method, between two pointclouds, given correspondences.
Definition: TransformationEstimation.cpp:39
cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeRMSE
double ComputeRMSE(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences) const override
Computes RMSE (double) for ColoredICP method, between two pointclouds, given correspondences.
Definition: TransformationEstimation.cpp:167
Eigen.h
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane
Definition: TransformationEstimation.h:111
cloudViewer::core::Tensor::GetLength
int64_t GetLength() const
Definition: Tensor.h:1125
TransformationConverter.h
cloudViewer::core::Tensor::GetShape
SizeVector GetShape() const
Definition: Tensor.h:1127
cloudViewer::core::Tensor::Mean
Tensor Mean(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1247
ccPointCloud::getEigenNormal
Eigen::Vector3d getEigenNormal(size_t index) const
Definition: ecvPointCloud.cpp:1600
core::Tensor
cloudViewer::pipelines::registration::TransformationEstimationType::ColoredICP
@ ColoredICP
cloudViewer::t::geometry::PointCloud::GetPointNormals
core::Tensor & GetPointNormals()
Get the value of the "normals" attribute. Convenience function.
Definition: PointCloud.h:130
cloudViewer::core::Tensor::Reshape
Tensor Reshape(const SizeVector &dst_shape) const
Definition: Tensor.cpp:671
cloudViewer::pipelines::registration::TransformationEstimation::ComputeRMSE
virtual double ComputeRMSE(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const =0
AssertTensorDevice
#define AssertTensorDevice(tensor,...)
Definition: TensorCheck.h:45
Eigen::Matrix6d
Eigen::Matrix< double, 6, 6 > Matrix6d
Extending Eigen namespace by adding frequently used matrix type.
Definition: Eigen.h:106
cloudViewer::pipelines::registration::TransformationEstimation::ComputeTransformation
virtual Eigen::Matrix4d ComputeTransformation(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const =0
cloudViewer::t::geometry::PointCloud::GetPointColors
core::Tensor & GetPointColors()
Get the value of the "colors" attribute. Convenience function.
Definition: PointCloud.h:127
cloudViewer::core::Tensor::Mul
Tensor Mul(const Tensor &value) const
Multiplies a tensor and returns the resulting tensor.
Definition: Tensor.cpp:1169
Eigen::Vector6d
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Eigen.h:107
cloudViewer::utility::SolveJacobianSystemAndObtainExtrinsicMatrix
std::tuple< bool, Eigen::Matrix4d > SolveJacobianSystemAndObtainExtrinsicMatrix(const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr)
Definition: Eigen.cpp:105
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::kernel_
std::shared_ptr< RobustKernel > kernel_
shared_ptr to an Abstract RobustKernel that could mutate at runtime.
Definition: TransformationEstimation.h:138
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::TransformationEstimationPointToPoint
TransformationEstimationPointToPoint(bool with_scaling=false)
Parameterized Constructor.
Definition: TransformationEstimation.h:77
cloudViewer::t::geometry::PointCloud::HasPointColors
bool HasPointColors() const
Definition: PointCloud.h:227
cloudViewer::utility::ComputeJTJandJTr
std::tuple< MatType, VecType, double > ComputeJTJandJTr(std::function< void(int, VecType &, double &, double &)> f, int iteration_num, bool verbose=true)
Definition: Eigen.cpp:148
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::ComputeTransformation
Eigen::Matrix4d ComputeTransformation(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const override
Definition: TransformationEstimation.cpp:60
cloudViewer::pipelines::registration::TransformationEstimation::~TransformationEstimation
virtual ~TransformationEstimation()
Definition: TransformationEstimation.h:42
cloudViewer::t::geometry::PointCloud
A point cloud contains a list of 3D points.
Definition: PointCloud.h:82
cloudViewer::t::geometry::PointCloud::HasPointNormals
bool HasPointNormals() const
Definition: PointCloud.h:234
cloudViewer::core::Dtype
Definition: Dtype.h:21
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint
Definition: TransformationEstimation.h:71
cloudViewer::t::pipelines::kernel::ComputeRtPointToPoint
std::tuple< core::Tensor, core::Tensor > ComputeRtPointToPoint(const core::Tensor &source_points, const core::Tensor &target_points, const core::Tensor &correspondence_indices)
Computes (R) Rotation {3,3} and (t) translation {3,} for point to point registration method.
Definition: Registration.cpp:205
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::TransformationEstimationPointToPlane
TransformationEstimationPointToPlane(std::shared_ptr< RobustKernel > kernel)
Constructor that takes as input a RobustKernel.
Definition: TransformationEstimation.h:119
cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::lambda_geometric_
double lambda_geometric_
Definition: TransformationEstimation.h:292
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::~TransformationEstimationPointToPlane
~TransformationEstimationPointToPlane() override
Definition: TransformationEstimation.h:115
cloudViewer::core::Tensor::Add_
Tensor Add_(const Tensor &value)
Definition: Tensor.cpp:1117
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::with_scaling_
bool with_scaling_
Set to True to estimate scaling, False to force scaling to be 1.
Definition: TransformationEstimation.h:101
cloudViewer::pipelines::registration::TransformationEstimationType::PointToPlane
@ PointToPlane
cloudViewer::PointCloudTpl::getEigenPoint
Eigen::Vector3d getEigenPoint(size_t index) const
Definition: PointCloudTpl.h:320
cloudViewer::t::pipelines::kernel::ComputePoseDopplerICP
core::Tensor ComputePoseDopplerICP(const core::Tensor &source_points, const core::Tensor &source_dopplers, const core::Tensor &source_directions, const core::Tensor &target_points, const core::Tensor &target_normals, const core::Tensor &correspondence_indices, const core::Tensor &current_transform, const core::Tensor &transform_vehicle_to_sensor, const std::size_t iteration, const double period, const double lambda_doppler, const bool reject_dynamic_outliers, const double doppler_outlier_threshold, const std::size_t outlier_rejection_min_iteration, const std::size_t geometric_robust_loss_min_iteration, const std::size_t doppler_robust_loss_min_iteration, const registration::RobustKernel &geometric_kernel, const registration::RobustKernel &doppler_kernel)
Computes pose for DopplerICP registration method.
Definition: Registration.cpp:98
cloudViewer::pipelines::registration::TransformationEstimationType::PointToPoint
@ PointToPoint
cloudViewer::core::SizeVector::ToString
std::string ToString() const
Definition: SizeVector.cpp:132
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE
double ComputeRMSE(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const override
Definition: TransformationEstimation.cpp:46
cloudViewer::pipelines::registration::TransformationEstimationType::GeneralizedICP
@ GeneralizedICP
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::ComputeRMSE
double ComputeRMSE(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const override
Definition: TransformationEstimation.cpp:19
cloudViewer::core::Device
Definition: Device.h:18
cloudViewer::t::geometry::kernel::image::To
void To(const core::Tensor &src, core::Tensor &dst, double scale, double offset)
Definition: Image.cpp:17
cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeRMSE
double ComputeRMSE(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences) const override
Computes RMSE (double) for DopplerICP method, between two pointclouds, given correspondences.
Definition: TransformationEstimation.cpp:307
TensorCheck.h
cloudViewer::core::Tensor::IndexGet
Tensor IndexGet(const std::vector< Tensor > &index_tensors) const
Advanced indexing getter. This will always allocate a new Tensor.
Definition: Tensor.cpp:905
ccPointCloud::hasNormals
bool hasNormals() const override
Returns whether normals are enabled or not.
Definition: ecvPointCloud.cpp:1693
cloudViewer::t::pipelines::registration::TransformationEstimationForDopplerICP::ComputeTransformation
core::Tensor ComputeTransformation(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences, const core::Tensor &current_transform=core::Tensor::Eye(4, core::Float64, core::Device("CPU:0")), const std::size_t iteration=0) const override
Estimates the transformation matrix for DopplerICP method, a tensor of shape {4, 4},...
Definition: TransformationEstimation.cpp:342
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::ComputeTransformation
Eigen::Matrix4d ComputeTransformation(const ccPointCloud &source, const ccPointCloud &target, const CorrespondenceSet &corres) const override
Definition: TransformationEstimation.cpp:32
cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeTransformation
core::Tensor ComputeTransformation(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences, const core::Tensor &current_transform=core::Tensor::Eye(4, core::Float64, core::Device("CPU:0")), const std::size_t iteration=0) const override
Estimates the transformation matrix for PointToPlane method, a tensor of shape {4,...
Definition: TransformationEstimation.cpp:134
cloudViewer::core::Float64
const Dtype Float64
Definition: Dtype.cpp:43
cloudViewer::t::geometry::PointCloud::GetDevice
core::Device GetDevice() const override
Returns the device attribute of this PointCloud.
Definition: PointCloud.h:421
cloudViewer::core::Tensor::GetDevice
Device GetDevice() const override
Definition: Tensor.cpp:1435
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::TransformationEstimationPointToPlane
TransformationEstimationPointToPlane()
Default Constructor.
Definition: TransformationEstimation.h:114
cloudViewer::t::pipelines::registration::AssertValidCorrespondences
static void AssertValidCorrespondences(const core::Tensor &correspondence_indices, const core::Tensor &source_points)
Definition: TransformationEstimation.cpp:19
cloudViewer::pipelines::registration::TransformationEstimationType::Unspecified
@ Unspecified
cloudViewer::core::SizeVector
Definition: SizeVector.h:70
TransformationEstimation.h
cloudViewer::core::Tensor::Mul_
Tensor Mul_(const Tensor &value)
Definition: Tensor.cpp:1189
cloudViewer::t::geometry::PointCloud::HasPointPositions
bool HasPointPositions() const
Definition: PointCloud.h:220
LogError
#define LogError(...)
Definition: Logging.h:60
cloudViewer::t::geometry::PointCloud::HasPointAttr
bool HasPointAttr(const std::string &key) const
Definition: PointCloud.h:207
cloudViewer::pipelines::registration::TransformationEstimationPointToPlane::GetTransformationEstimationType
TransformationEstimationType GetTransformationEstimationType() const override
Definition: TransformationEstimation.h:124
cloudViewer::t::geometry::PointCloud::GetPointAttr
const TensorMap & GetPointAttr() const
Getter for point_attr_ TensorMap. Used in Pybind.
Definition: PointCloud.h:111
cloudViewer::pipelines::registration::TransformationEstimation::GetTransformationEstimationType
virtual TransformationEstimationType GetTransformationEstimationType() const =0
cloudViewer::pipelines::registration::TransformationEstimationType
TransformationEstimationType
Definition: TransformationEstimation.h:25
AssertTensorDtype
#define AssertTensorDtype(tensor,...)
Definition: TensorCheck.h:21
std
Definition: Eigen.h:85
cloudViewer::t::pipelines::kernel::ComputePosePointToPlane
core::Tensor ComputePosePointToPlane(const core::Tensor &source_points, const core::Tensor &target_points, const core::Tensor &target_normals, const core::Tensor &correspondence_indices, const registration::RobustKernel &kernel)
Computes pose for point to plane registration method.
Definition: Registration.cpp:19
cloudViewer::core::Tensor::Ne
Tensor Ne(const Tensor &value) const
Element-wise not-equals-to of tensors, returning a new boolean tensor.
Definition: Tensor.cpp:1714
cloudViewer::core::Tensor::Sum
Tensor Sum(const SizeVector &dims, bool keepdim=false) const
Definition: Tensor.cpp:1240
cloudViewer::t::geometry::PointCloud::GetPointPositions
core::Tensor & GetPointPositions()
Get the value of the "positions" attribute. Convenience function.
Definition: PointCloud.h:124
cloudViewer::pipelines::registration::CorrespondenceSet
std::vector< Eigen::Vector2i > CorrespondenceSet
Definition: TransformationEstimation.h:23
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::GetTransformationEstimationType
TransformationEstimationType GetTransformationEstimationType() const override
Definition: TransformationEstimation.h:82
cloudViewer::pipelines::registration::TransformationEstimation::TransformationEstimation
TransformationEstimation()
Default Constructor.
Definition: TransformationEstimation.h:41
cloudViewer::pipelines::registration::TransformationEstimation
Definition: TransformationEstimation.h:38
AssertTensorShape
#define AssertTensorShape(tensor,...)
Definition: TensorCheck.h:61
cloudViewer::pipelines::registration::TransformationEstimationPointToPoint::~TransformationEstimationPointToPoint
~TransformationEstimationPointToPoint() override
Definition: TransformationEstimation.h:79
AssertTensorDtypes
#define AssertTensorDtypes(tensor,...)
Definition: TensorCheck.h:33
cloudViewer::t::pipelines::kernel::ComputePoseColoredICP
core::Tensor ComputePoseColoredICP(const core::Tensor &source_points, const core::Tensor &source_colors, const core::Tensor &target_points, const core::Tensor &target_normals, const core::Tensor &target_colors, const core::Tensor &target_color_gradients, const core::Tensor &correspondence_indices, const registration::RobustKernel &kernel, const double &lambda_geometric)
Computes pose for colored-icp registration method.
Definition: Registration.cpp:54
cloudViewer::t::pipelines::registration::TransformationEstimationForColoredICP::ComputeTransformation
core::Tensor ComputeTransformation(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences, const core::Tensor &current_transform=core::Tensor::Eye(4, core::Float64, core::Device("CPU:0")), const std::size_t iteration=0) const override
Estimates the transformation matrix for ColoredICP method, a tensor of shape {4, 4},...
Definition: TransformationEstimation.cpp:255
cloudViewer::t::pipelines::kernel::PoseToTransformation
core::Tensor PoseToTransformation(const core::Tensor &pose)
Convert pose to the transformation matrix.
Definition: TransformationConverter.cpp:73
cloudViewer::core::Int64
const Dtype Int64
Definition: Dtype.cpp:47
cloudViewer::t::pipelines::registration::TransformationEstimationPointToPlane::ComputeRMSE
double ComputeRMSE(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences) const override
Computes RMSE (double) for PointToPlane method, between two pointclouds, given correspondences.
Definition: TransformationEstimation.cpp:99
ecvPointCloud.h
cloudViewer::t::pipelines::registration::TransformationEstimationPointToPoint::ComputeTransformation
core::Tensor ComputeTransformation(const geometry::PointCloud &source, const geometry::PointCloud &target, const core::Tensor &correspondences, const core::Tensor &current_transform=core::Tensor::Eye(4, core::Float64, core::Device("CPU:0")), const std::size_t iteration=0) const override
Estimates the transformation matrix for PointToPoint method, a tensor of shape {4,...
Definition: TransformationEstimation.cpp:70