Open3D (C++ API)  0.18.0+80ae047
Eigen.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <Eigen/StdVector>
12 #include <tuple>
13 #include <vector>
14 
16 namespace Eigen {
17 
19 typedef Eigen::Matrix<double, 6, 6> Matrix6d;
20 typedef Eigen::Matrix<double, 6, 1> Vector6d;
21 typedef Eigen::Matrix<uint8_t, 3, 1> Vector3uint8;
22 
25 typedef Eigen::Matrix<double, 6, 6, Eigen::DontAlign> Matrix6d_u;
26 typedef Eigen::Matrix<double, 4, 4, Eigen::DontAlign> Matrix4d_u;
27 
28 } // namespace Eigen
30 
31 namespace open3d {
32 namespace utility {
33 
34 using Matrix4d_allocator = Eigen::aligned_allocator<Eigen::Matrix4d>;
35 using Matrix6d_allocator = Eigen::aligned_allocator<Eigen::Matrix6d>;
36 using Vector2d_allocator = Eigen::aligned_allocator<Eigen::Vector2d>;
37 using Vector3uint8_allocator = Eigen::aligned_allocator<Eigen::Vector3uint8>;
38 using Vector4i_allocator = Eigen::aligned_allocator<Eigen::Vector4i>;
39 using Vector4d_allocator = Eigen::aligned_allocator<Eigen::Vector4d>;
40 using Vector6d_allocator = Eigen::aligned_allocator<Eigen::Vector6d>;
41 
43 Eigen::Matrix3d SkewMatrix(const Eigen::Vector3d &vec);
44 
48 Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input);
49 
55 Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input);
56 
58 std::tuple<bool, Eigen::VectorXd> SolveLinearSystemPSD(
59  const Eigen::MatrixXd &A,
60  const Eigen::VectorXd &b,
61  bool prefer_sparse = false,
62  bool check_symmetric = false,
63  bool check_det = false,
64  bool check_psd = false);
65 
69 std::tuple<bool, Eigen::Matrix4d> SolveJacobianSystemAndObtainExtrinsicMatrix(
70  const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr);
71 
75 std::tuple<bool, std::vector<Eigen::Matrix4d, Matrix4d_allocator>>
76 SolveJacobianSystemAndObtainExtrinsicMatrixArray(const Eigen::MatrixXd &JTJ,
77  const Eigen::VectorXd &JTr);
78 
84 template <typename MatType, typename VecType>
85 std::tuple<MatType, VecType, double> ComputeJTJandJTr(
86  std::function<void(int, VecType &, double &, double &)> f,
87  int iteration_num,
88  bool verbose = true);
89 
95 template <typename MatType, typename VecType>
96 std::tuple<MatType, VecType, double> ComputeJTJandJTr(
97  std::function<
98  void(int,
99  std::vector<VecType, Eigen::aligned_allocator<VecType>> &,
100  std::vector<double> &,
101  std::vector<double> &)> f,
102  int iteration_num,
103  bool verbose = true);
104 
105 Eigen::Matrix3d RotationMatrixX(double radians);
106 Eigen::Matrix3d RotationMatrixY(double radians);
107 Eigen::Matrix3d RotationMatrixZ(double radians);
108 
111 Eigen::Vector3uint8 ColorToUint8(const Eigen::Vector3d &color);
113 Eigen::Vector3d ColorToDouble(uint8_t r, uint8_t g, uint8_t b);
114 Eigen::Vector3d ColorToDouble(const Eigen::Vector3uint8 &rgb);
115 
117 template <typename IdxType>
118 Eigen::Matrix3d ComputeCovariance(const std::vector<Eigen::Vector3d> &points,
119  const std::vector<IdxType> &indices);
120 
122 template <typename IdxType>
123 std::tuple<Eigen::Vector3d, Eigen::Matrix3d> ComputeMeanAndCovariance(
124  const std::vector<Eigen::Vector3d> &points,
125  const std::vector<IdxType> &indices);
126 
133 template <typename RealType, typename IdxType>
134 std::tuple<Eigen::Vector3d, Eigen::Matrix3d> ComputeMeanAndCovariance(
135  const RealType *const points, const std::vector<IdxType> &indices);
136 
137 } // namespace utility
138 } // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:45
int points
Definition: FilePCD.cpp:54
Definition: NonRigidOptimizer.cpp:22
std::tuple< MatType, VecType, double > ComputeJTJandJTr(std::function< void(int, VecType &, double &, double &)> f, int iteration_num, bool verbose)
Definition: Eigen.cpp:146
Eigen::aligned_allocator< Eigen::Vector2d > Vector2d_allocator
Definition: Eigen.h:36
Eigen::Vector3d ColorToDouble(uint8_t r, uint8_t g, uint8_t b)
Color conversion from uint8_t 0-255 to double [0,1].
Definition: Eigen.cpp:277
Eigen::Matrix3d ComputeCovariance(const std::vector< Eigen::Vector3d > &points, const std::vector< IdxType > &indices)
Function to compute the covariance matrix of a set of points.
Definition: Eigen.cpp:286
std::tuple< bool, Eigen::VectorXd > SolveLinearSystemPSD(const Eigen::MatrixXd &A, const Eigen::VectorXd &b, bool prefer_sparse, bool check_symmetric, bool check_det, bool check_psd)
Function to solve Ax=b.
Definition: Eigen.cpp:19
Eigen::Matrix3d RotationMatrixX(double radians)
Definition: Eigen.cpp:247
Eigen::Matrix3d SkewMatrix(const Eigen::Vector3d &vec)
Genretate a skew-symmetric matrix from a vector 3x1.
Definition: Eigen.cpp:413
Eigen::aligned_allocator< Eigen::Vector4d > Vector4d_allocator
Definition: Eigen.h:39
Eigen::aligned_allocator< Eigen::Vector4i > Vector4i_allocator
Definition: Eigen.h:38
std::tuple< bool, std::vector< Eigen::Matrix4d, Matrix4d_allocator > > SolveJacobianSystemAndObtainExtrinsicMatrixArray(const Eigen::MatrixXd &JTJ, const Eigen::VectorXd &JTr)
Definition: Eigen.cpp:117
Eigen::aligned_allocator< Eigen::Vector6d > Vector6d_allocator
Definition: Eigen.h:40
Eigen::Matrix3d RotationMatrixZ(double radians)
Definition: Eigen.cpp:261
Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input)
Definition: Eigen.cpp:74
Eigen::aligned_allocator< Eigen::Matrix6d > Matrix6d_allocator
Definition: Eigen.h:35
Eigen::Matrix3d RotationMatrixY(double radians)
Definition: Eigen.cpp:254
std::tuple< bool, Eigen::Matrix4d > SolveJacobianSystemAndObtainExtrinsicMatrix(const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr)
Definition: Eigen.cpp:103
Eigen::aligned_allocator< Eigen::Matrix4d > Matrix4d_allocator
Definition: Eigen.h:34
std::tuple< Eigen::Vector3d, Eigen::Matrix3d > ComputeMeanAndCovariance(const std::vector< Eigen::Vector3d > &points, const std::vector< IdxType > &indices)
Function to compute the mean and covariance matrix of a set of points.
Definition: Eigen.cpp:320
Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input)
Definition: Eigen.cpp:86
Eigen::Vector3uint8 ColorToUint8(const Eigen::Vector3d &color)
Definition: Eigen.cpp:268
Eigen::aligned_allocator< Eigen::Vector3uint8 > Vector3uint8_allocator
Definition: Eigen.h:37
Definition: PinholeCameraIntrinsic.cpp:16