Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMatrixLinear.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #ifndef PMatrixLinear_hh_
27 #define PMatrixLinear_hh_
28 #include <Base/Common/BIASpragmaStart.hh>
29 #include <vector>
30 
31 #include <Base/Debug/Debug.hh>
32 #include <Base/Geometry/HomgPoint3D.hh>
33 #include <Base/Geometry/HomgPoint2D.hh>
34 #include <MathAlgo/SVD.hh>
35 #include "PMatrix.hh"
36 
37 namespace BIAS {
38  /** @class PMatrixLinear
39  @ingroup g_estimation
40  @brief This class computes a PMatrix from 2D/3D correspondences with
41  linear methods.
42 
43  No nonlinear constraints are enforced: If you have noisy points, you
44  may get inexact rotations or non-metric PMatrices, although you
45  compute in a metric framework. however, this class provides
46  functions which can also be applied in projectively skewed space.
47  @author koeser/frahm
48  */
49 
50  class BIASGeometry_EXPORT PMatrixLinear : public Debug {
51 
52  public:
53 
54  PMatrixLinear();
55 
56  /** @brief computes a least squares solution P via SVD, if at least 6 2d-3d
57  correspondences (pointers) are provided in points3D and points2D.
58 
59  @attention P may not exactly be decomposable due to noise in points
60  @param points3D 3D points which project to points2D
61  @param points2D 2D projections of points3D, any K allowed !
62  @param P resulting (not always metric) PMatrix
63  @return false on ambiguity, true on success */
64  bool Compute(const std::vector<HomgPoint3D*> &points3D,
65  const std::vector<HomgPoint2D*> &points2D,
66  PMatrix& P);
67 
68  /** @brief computes a least squares solution P via SVD, if at least 6 2d-3d
69  correspondences are provided in points3D and points2D
70 
71  Algorithm used is DLT. Fails if points3D are coplanar.
72  @attention P may not exactly be decomposable due to noise in points
73  @param points3D 3D points which project to points2D
74  @param points2D 2D projections of points3D, any K allowed !
75  @param P resulting (not always metric) PMatrix
76  @return false on ambiguity, true on success */
77  bool Compute(const std::vector<HomgPoint3D> &points3D,
78  const std::vector<HomgPoint2D> &points2D,
79  PMatrix& P);
80 
81  /** @brief given n>=6 2D/3D correspondences, compute approximate R and C
82  using linear methods (thats why we need 6, not 3 correspondences !)
83 
84  The lines of each two 3D points and their projections into the image
85  are used to determine the rotation of P. For n points, we have
86  n(n-1)/2 lines (quadratic in n!) and also linear equations,
87  dont pass too many points if you are interested in performance ! After
88  R is determined, C is computed separately using linear methods (DLT)
89  starting from the equation Rx ~= [ I |-C] X
90  Algorithm fails if points3D are coplanar
91  @attention R is no real rotation, enforce afterwards, if you want that!
92  @param points3D 3D points which project to points2D
93  @param points2D 2D projections of points3D, K=Identity required !
94  @param Pose result R^T*[ I |-C]
95  @return true on success, false on error (ambiguity)
96  @author koeser 10/2004 */
97  bool ComputeCalibrated(const std::vector<HomgPoint3D*> &points3D,
98  const std::vector<HomgPoint2D*> &points2D,
99  PMatrix& Pose);
100 
101 
102  /** @brief sets up the homogeneous equation system A for pmatrix
103  computation using the 2d/3d correspondences provided
104  @author frahm */
105  bool GetPEstSystemHom(Matrix<double>& A,
106  const std::vector<HomgPoint3D*>& points3D,
107  const std::vector<HomgPoint2D*>& points2D);
108 
109  /** @brief sets up an inhomogeneous equation system A for pmatrix
110  computation using the 2d/3d correspondences provided
111  @author frahm */
112  bool GetPEstSystemInHom(Matrix<double>& A, Vector<double>& b,
113  const std::vector<HomgPoint3D*>& points3D,
114  const std::vector<HomgPoint2D*>& points2D);
115 
116 
117  };
118 }
119 
120 #include <Base/Common/BIASpragmaEnd.hh>
121 
122 #endif
123 
This class computes a PMatrix from 2D/3D correspondences with linear methods.
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88