Open3D (C++ API)
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 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 <tuple>
30 #include <vector>
31 #include <Eigen/Core>
32 #include <Eigen/StdVector>
33 
34 namespace Eigen {
35 
37 typedef Eigen::Matrix<double, 6, 6> Matrix6d;
38 typedef Eigen::Matrix<double, 6, 1> Vector6d;
39 
42 typedef Eigen::Matrix<double, 6, 6, Eigen::DontAlign> Matrix6d_u;
43 typedef Eigen::Matrix<double, 4, 4, Eigen::DontAlign> Matrix4d_u;
44 
45 } // namespace Eigen
46 
47 namespace open3d {
48 namespace utility {
49 
50 using Matrix4d_allocator = Eigen::aligned_allocator<Eigen::Matrix4d>;
51 using Matrix6d_allocator = Eigen::aligned_allocator<Eigen::Matrix6d>;
52 using Vector2d_allocator = Eigen::aligned_allocator<Eigen::Vector2d>;
53 using Vector4i_allocator = Eigen::aligned_allocator<Eigen::Vector4i>;
54 using Vector4d_allocator = Eigen::aligned_allocator<Eigen::Vector4d>;
55 using Vector6d_allocator = Eigen::aligned_allocator<Eigen::Vector6d>;
56 
60 Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input);
61 
67 Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input);
68 
70 std::tuple<bool, Eigen::VectorXd> SolveLinearSystemPSD(
71  const Eigen::MatrixXd &A,
72  const Eigen::VectorXd &b,
73  bool prefer_sparse = false,
74  bool check_symmetric = false,
75  bool check_det = false,
76  bool check_psd = false);
77 
81 std::tuple<bool, Eigen::Matrix4d> SolveJacobianSystemAndObtainExtrinsicMatrix(
82  const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr);
83 
87 std::tuple<bool, std::vector<Eigen::Matrix4d, Matrix4d_allocator>>
88 SolveJacobianSystemAndObtainExtrinsicMatrixArray(const Eigen::MatrixXd &JTJ,
89  const Eigen::VectorXd &JTr);
90 
96 template <typename MatType, typename VecType>
97 std::tuple<MatType, VecType, double> ComputeJTJandJTr(
98  std::function<void(int, VecType &, double &)> f,
99  int iteration_num,
100  bool verbose = true);
101 
107 template <typename MatType, typename VecType>
108 std::tuple<MatType, VecType, double> ComputeJTJandJTr(
109  std::function<
110  void(int,
111  std::vector<VecType, Eigen::aligned_allocator<VecType>> &,
112  std::vector<double> &)> f,
113  int iteration_num,
114  bool verbose = true);
115 
116 } // namespace utility
117 } // namespace open3d
Eigen::aligned_allocator< Eigen::Vector2d > Vector2d_allocator
Definition: Eigen.h:52
std::tuple< bool, Eigen::Matrix4d > SolveJacobianSystemAndObtainExtrinsicMatrix(const Eigen::Matrix6d &JTJ, const Eigen::Vector6d &JTr)
Definition: Eigen.cpp:121
Eigen::aligned_allocator< Eigen::Vector4d > Vector4d_allocator
Definition: Eigen.h:54
Eigen::aligned_allocator< Eigen::Matrix6d > Matrix6d_allocator
Definition: Eigen.h:51
Eigen::Matrix4d TransformVector6dToMatrix4d(const Eigen::Vector6d &input)
Definition: Eigen.cpp:92
Definition: EigenHelperForNonRigidOptimization.h:33
Eigen::aligned_allocator< Eigen::Vector4i > Vector4i_allocator
Definition: Eigen.h:53
std::tuple< bool, std::vector< Eigen::Matrix4d, Matrix4d_allocator > > SolveJacobianSystemAndObtainExtrinsicMatrixArray(const Eigen::MatrixXd &JTJ, const Eigen::VectorXd &JTr)
Definition: Eigen.cpp:139
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: Eigen.h:38
Eigen::Vector6d TransformMatrix4dToVector6d(const Eigen::Matrix4d &input)
Definition: Eigen.cpp:104
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:37
Eigen::aligned_allocator< Eigen::Vector6d > Vector6d_allocator
Definition: Eigen.h:55
std::tuple< MatType, VecType, double > ComputeJTJandJTr(std::function< void(int, VecType &, double &)> f, int iteration_num, bool verbose)
Definition: Eigen.cpp:168
Definition: PinholeCameraIntrinsic.cpp:33
Eigen::aligned_allocator< Eigen::Matrix4d > Matrix4d_allocator
Definition: Eigen.h:50
Eigen::Matrix< double, 6, 6, Eigen::DontAlign > Matrix6d_u
Definition: Eigen.h:42
Eigen::Matrix< double, 4, 4, Eigen::DontAlign > Matrix4d_u
Definition: Eigen.h:43
Eigen::Matrix< double, 6, 6 > Matrix6d
Extending Eigen namespace by adding frequently used matrix type.
Definition: Eigen.h:37