Blender  V3.3
homography_parameterization.h
Go to the documentation of this file.
1 // Copyright (c) 2011 libmv authors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
21 #ifndef LIBMV_MULTIVIEW_HOMOGRAPHY_PARAMETERIZATION_H_
22 #define LIBMV_MULTIVIEW_HOMOGRAPHY_PARAMETERIZATION_H_
23 
24 #include "libmv/numeric/numeric.h"
25 
26 namespace libmv {
27 
36 template <typename T = double>
38  public:
39  typedef Eigen::Matrix<T, 8, 1> Parameters; // a, b, ... g, h
40  typedef Eigen::Matrix<T, 3, 3> Parameterized; // H
41 
43  static void To(const Parameters& p, Parameterized* h) {
44  // clang-format off
45  *h << p(0), p(1), p(2),
46  p(3), p(4), p(5),
47  p(6), p(7), 1.0;
48  // clang-format on
49  }
50 
52  static void From(const Parameterized& h, Parameters* p) {
53  // clang-format off
54  *p << h(0, 0), h(0, 1), h(0, 2),
55  h(1, 0), h(1, 1), h(1, 2),
56  h(2, 0), h(2, 1);
57  // clang-format on
58  }
59 };
60 
70 template <typename T = double>
72  public:
73  typedef Eigen::Matrix<T, 15, 1> Parameters; // a, b, ... n, o
74  typedef Eigen::Matrix<T, 4, 4> Parameterized; // H
75 
77  static void To(const Parameters& p, Parameterized* h) {
78  // clang-format off
79  *h << p(0), p(1), p(2), p(3),
80  p(4), p(5), p(6), p(7),
81  p(8), p(9), p(10), p(11),
82  p(12), p(13), p(14), 1.0;
83  // clang-format on
84  }
85 
87  static void From(const Parameterized& h, Parameters* p) {
88  // clang-format off
89  *p << h(0, 0), h(0, 1), h(0, 2), h(0, 3),
90  h(1, 0), h(1, 1), h(1, 2), h(1, 3),
91  h(2, 0), h(2, 1), h(2, 2), h(2, 3),
92  h(3, 0), h(3, 1), h(3, 2);
93  // clang-format on
94  }
95 };
96 
97 } // namespace libmv
98 
99 #endif // LIBMV_MULTIVIEW_HOMOGRAPHY_PARAMETERIZATION_H_
static void To(const Parameters &p, Parameterized *h)
Convert from the 8 parameters to a H matrix.
static void From(const Parameterized &h, Parameters *p)
Convert from a H matrix to the 8 parameters.
static void To(const Parameters &p, Parameterized *h)
Convert from the 15 parameters to a H matrix.
static void From(const Parameterized &h, Parameters *p)
Convert from a H matrix to the 15 parameters.