Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FMatrix.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 __BIAS_FMatrix_hh__
27 #define __BIAS_FMatrix_hh__
28 
29 #include <bias_config.h>
30 #include <Base/Geometry/FMatrixBase.hh>
31 #include <Base/Debug/Error.hh>
32 #include <Base/Debug/Debug.hh>
33 
34 #include <Geometry/PMatrix.hh>
35 
36 #define D_FMATRIX_GETEPIPOLES 0x0001
37 
38 namespace BIAS {
39  /** @class FMatrix
40  @ingroup g_geometry
41  @brief class representing a Fundamental matrix
42 
43  A fundemantal matrix describes the orientation and position of
44  two image planes. It can be used to estimate the epipolarline and to
45  distinguish between mismatches and good matches */
46  class BIASGeometry_EXPORT FMatrix : public FMatrixBase, public Debug
47  {
48  public:
49  FMatrix() : Debug()
50  {};
51 
52  explicit FMatrix(const MatrixInitType& i)
53  : FMatrixBase(i){};
54 
55  FMatrix(const FMatrix& f) : FMatrixBase(f)
56  {};
57 
58  FMatrix(const FMatrixBase& f) : FMatrixBase(f) {};
59 
61 
62  /** @brief computes an F matrix from two cameras (defined by arbitrary
63  P matrices, not only metric ones)
64  @author koeser 09/2003 */
66  { ComputeFromPMatrices(P1, P2); };
67 
68  ~FMatrix() {};
69 
70  FMatrix& operator=(const FMatrix& f);
71 
72  /** @brief computes an F matrix from two cameras (defined by arbitrary
73  P matrices, not only metric ones)
74  @author koeser, updated 07/2004 */
75  void ComputeFromPMatrices(BIAS::PMatrix &P1, BIAS::PMatrix &P2);
76 
77  /** @brief Computes the epipoles from this F Matrix
78  @return 0 on success, <0 if epipoles could not be retrieved
79  @author JMF/koeser **/
80  int GetEpipoles(HomgPoint2D &Epipole1, HomgPoint2D &Epipole2) const;
81 
82  /** @brief same as above, additionally homogenizes epipoles */
84  HomgPoint2D &E2) const
85  { GetEpipoles(E1, E2); E1.Homogenize(); E2.Homogenize(); };
86 
87 
88  /** @brief Decomposes f matrix to product (skew)(rank3) */
89  void DecomposetoSR(BIAS::Matrix3x3<double> &skew_matrix,
90  BIAS::Matrix3x3<double> &rank3_matrix);
91 
92  /** @brief Returns true if all properties of the F-Matrix are correct,
93  at the moment only rank 2 is checked
94  @author mdunda 08 2003 **/
95  bool IsValid();
96 
97 
100  return *this;
101  }
102 
103  /** returns residual error as in Zisserman p. 288 */
104  double GetResidualError(const std::vector<BIAS::HomgPoint2D> &p1,
105  const std::vector<BIAS::HomgPoint2D> &p2);
106  };
107 
108 
109 
110 } // namespace BIAS
111 
112 
113 #endif // __BIAS_FMatrix_hh__
FMatrix(const MatrixInitType &i)
Definition: FMatrix.hh:52
MatrixInitType
can be passed to matrix constructors to init the matrix with the most often used values ...
Definition: Matrix.hh:59
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint2D.hh:215
describes the epipolar relationship between a point and his mapping on a corresponding epipolar line...
Definition: FMatrixBase.hh:67
class representing a Fundamental matrix
Definition: FMatrix.hh:46
FMatrix(BIAS::PMatrix &P1, BIAS::PMatrix &P2)
computes an F matrix from two cameras (defined by arbitrary P matrices, not only metric ones) ...
Definition: FMatrix.hh:65
void GetEpipolesHomogenized(HomgPoint2D &E1, HomgPoint2D &E2) const
same as above, additionally homogenizes epipoles
Definition: FMatrix.hh:83
FMatrix(const FMatrixBase &f)
Definition: FMatrix.hh:58
Matrix3x3< T > & operator=(const Matrix3x3< T > &mat)
assignment operator
Definition: Matrix3x3.cpp:704
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
FMatrix & operator=(const Matrix3x3< FMATRIX_TYPE > &f)
Definition: FMatrix.hh:98
FMatrix(const FMatrix &f)
Definition: FMatrix.hh:55
FMatrix(const Matrix3x3< FMATRIX_TYPE > &f)
Definition: FMatrix.hh:60