Open3D (C++ API)  0.16.0
Eigen.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <Eigen/Core>
30#include <Eigen/StdVector>
31#include <tuple>
32#include <vector>
33
35namespace Eigen {
36
38typedef Eigen::Matrix<double, 6, 6> Matrix6d;
39typedef Eigen::Matrix<double, 6, 1> Vector6d;
40typedef Eigen::Matrix<uint8_t, 3, 1> Vector3uint8;
41
44typedef Eigen::Matrix<double, 6, 6, Eigen::DontAlign> Matrix6d_u;
45typedef Eigen::Matrix<double, 4, 4, Eigen::DontAlign> Matrix4d_u;
46
47} // namespace Eigen
49
50namespace open3d {
51namespace utility {
52
53using Matrix4d_allocator = Eigen::aligned_allocator<Eigen::Matrix4d>;
54using Matrix6d_allocator = Eigen::aligned_allocator<Eigen::Matrix6d>;
55using Vector2d_allocator = Eigen::aligned_allocator<Eigen::Vector2d>;
56using Vector3uint8_allocator = Eigen::aligned_allocator<Eigen::Vector3uint8>;
57using Vector4i_allocator = Eigen::aligned_allocator<Eigen::Vector4i>;
58using Vector4d_allocator = Eigen::aligned_allocator<Eigen::Vector4d>;
59using Vector6d_allocator = Eigen::aligned_allocator<Eigen::Vector6d>;
60
62Eigen::Matrix3d SkewMatrix(const Eigen::Vector3d &vec);
63
67Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input);
68
74Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input);
75
77std::tuple<bool, Eigen::VectorXd> SolveLinearSystemPSD(
78 const Eigen::MatrixXd &A,
79 const Eigen::VectorXd &b,
80 bool prefer_sparse = false,
81 bool check_symmetric = false,
82 bool check_det = false,
83 bool check_psd = false);
84
88std::tuple<bool, Eigen::Matrix4d> SolveJacobianSystemAndObtainExtrinsicMatrix(
89 const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr);
90
94std::tuple<bool, std::vector<Eigen::Matrix4d, Matrix4d_allocator>>
96 const Eigen::VectorXd &JTr);
97
103template <typename MatType, typename VecType>
104std::tuple<MatType, VecType, double> ComputeJTJandJTr(
105 std::function<void(int, VecType &, double &, double &)> f,
106 int iteration_num,
107 bool verbose = true);
108
114template <typename MatType, typename VecType>
115std::tuple<MatType, VecType, double> ComputeJTJandJTr(
116 std::function<
117 void(int,
118 std::vector<VecType, Eigen::aligned_allocator<VecType>> &,
119 std::vector<double> &,
120 std::vector<double> &)> f,
121 int iteration_num,
122 bool verbose = true);
123
124Eigen::Matrix3d RotationMatrixX(double radians);
125Eigen::Matrix3d RotationMatrixY(double radians);
126Eigen::Matrix3d RotationMatrixZ(double radians);
127
130Eigen::Vector3uint8 ColorToUint8(const Eigen::Vector3d &color);
132Eigen::Vector3d ColorToDouble(uint8_t r, uint8_t g, uint8_t b);
133Eigen::Vector3d ColorToDouble(const Eigen::Vector3uint8 &rgb);
134
136template <typename IdxType>
137Eigen::Matrix3d ComputeCovariance(const std::vector<Eigen::Vector3d> &points,
138 const std::vector<IdxType> &indices);
139
141template <typename IdxType>
142std::tuple<Eigen::Vector3d, Eigen::Matrix3d> ComputeMeanAndCovariance(
143 const std::vector<Eigen::Vector3d> &points,
144 const std::vector<IdxType> &indices);
145} // namespace utility
146} // namespace open3d
math::float4 color
Definition: LineSetBuffers.cpp:64
int points
Definition: FilePCD.cpp:73
Definition: NonRigidOptimizer.cpp:41
std::tuple< MatType, VecType, double > ComputeJTJandJTr(std::function< void(int, VecType &, double &, double &)> f, int iteration_num, bool verbose)
Definition: Eigen.cpp:165
Eigen::aligned_allocator< Eigen::Vector2d > Vector2d_allocator
Definition: Eigen.h:55
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:296
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:305
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:38
Eigen::Matrix3d RotationMatrixX(double radians)
Definition: Eigen.cpp:266
Eigen::Matrix3d SkewMatrix(const Eigen::Vector3d &vec)
Genretate a skew-symmetric matrix from a vector 3x1.
Definition: Eigen.cpp:387
Eigen::aligned_allocator< Eigen::Vector4d > Vector4d_allocator
Definition: Eigen.h:58
Eigen::aligned_allocator< Eigen::Vector4i > Vector4i_allocator
Definition: Eigen.h:57
std::tuple< bool, std::vector< Eigen::Matrix4d, Matrix4d_allocator > > SolveJacobianSystemAndObtainExtrinsicMatrixArray(const Eigen::MatrixXd &JTJ, const Eigen::VectorXd &JTr)
Definition: Eigen.cpp:136
Eigen::aligned_allocator< Eigen::Vector6d > Vector6d_allocator
Definition: Eigen.h:59
Eigen::Matrix3d RotationMatrixZ(double radians)
Definition: Eigen.cpp:280
Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input)
Definition: Eigen.cpp:93
Eigen::aligned_allocator< Eigen::Matrix6d > Matrix6d_allocator
Definition: Eigen.h:54
Eigen::Matrix3d RotationMatrixY(double radians)
Definition: Eigen.cpp:273
std::tuple< bool, Eigen::Matrix4d > SolveJacobianSystemAndObtainExtrinsicMatrix(const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr)
Definition: Eigen.cpp:122
Eigen::aligned_allocator< Eigen::Matrix4d > Matrix4d_allocator
Definition: Eigen.h:53
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:339
Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input)
Definition: Eigen.cpp:105
Eigen::Vector3uint8 ColorToUint8(const Eigen::Vector3d &color)
Definition: Eigen.cpp:287
Eigen::aligned_allocator< Eigen::Vector3uint8 > Vector3uint8_allocator
Definition: Eigen.h:56
Definition: PinholeCameraIntrinsic.cpp:35