Blender V4.3
triangulation.cc
Go to the documentation of this file.
1// Copyright (c) 2007, 2008 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
22
25
26namespace libmv {
27
28// HZ 12.2 pag.312
29void TriangulateDLT(const Mat34& P1,
30 const Vec2& x1,
31 const Mat34& P2,
32 const Vec2& x2,
33 Vec4* X_homogeneous) {
34 Mat4 design;
35 for (int i = 0; i < 4; ++i) {
36 design(0, i) = x1(0) * P1(2, i) - P1(0, i);
37 design(1, i) = x1(1) * P1(2, i) - P1(1, i);
38 design(2, i) = x2(0) * P2(2, i) - P2(0, i);
39 design(3, i) = x2(1) * P2(2, i) - P2(1, i);
40 }
41 Nullspace(&design, X_homogeneous);
42}
43
44void TriangulateDLT(const Mat34& P1,
45 const Vec2& x1,
46 const Mat34& P2,
47 const Vec2& x2,
48 Vec3* X_euclidean) {
49 Vec4 X_homogeneous;
50 TriangulateDLT(P1, x1, P2, x2, &X_homogeneous);
51 HomogeneousToEuclidean(X_homogeneous, X_euclidean);
52}
53
54} // namespace libmv
double Nullspace(TMat *A, TVec *nullspace)
Definition numeric.h:158
Eigen::Vector4d Vec4
Definition numeric.h:107
Eigen::Vector2d Vec2
Definition numeric.h:105
void TriangulateDLT(const Mat34 &P1, const Vec2 &x1, const Mat34 &P2, const Vec2 &x2, Vec4 *X_homogeneous)
void HomogeneousToEuclidean(const Mat &H, Mat *X)
Eigen::Matrix< double, 3, 4 > Mat34
Definition numeric.h:73
Eigen::Vector3d Vec3
Definition numeric.h:106