Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FMatrixBase.cpp
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 #include "FMatrixBase.hh"
26 #include <Base/Common/W32Compat.hh>
27 #include "HomgPoint3D.hh"
28 #include "PMatrixBase.hh"
29 
30 #include <Base/Common/BIASpragma.hh>
31 
32 
33 using namespace BIAS;
34 using namespace std;
35 
37 {}
38 
39 
40 /** Returns epipolar line in image 1 for point in image 2. */
42 {
43  HomgLine2D homline;
44  GetEpipolarLineImage1(point,homline);
45  return homline;
46 }
47 
49  HomgLine2D& homline) const {
50 
51  const register FMATRIX_TYPE *matP = this->GetData();
52  homline[0] = point[0] * matP[0]
53  + point[1] * matP[3]
54  + point[2] * matP[6];
55  homline[1] = point[0] * matP[1]
56  + point[1] * matP[4]
57  + point[2] * matP[7];
58  homline[2] = point[0] * matP[2]
59  + point[1] * matP[5]
60  + point[2] * matP[8];
61 }
62 
63 /** Returns epipolar line in image 2 for point in image 1. */
65 {
66  HomgLine2D homline((*this)*point);
67  return homline;
68 }
69 
71  HomgLine2D& homline) const
72 {
73  homline=HomgLine2D((*this)*point);
74 }
75 
77  const RMatrixBase& R2, const Vector3<double>& C2)
78 {
79  RMatrixBase R;
80  (R2.Transpose()).Mult(R1, R);
81  HomgPoint2D e;
82  HomgPoint3D C1h(C1);
83  PMatrixBase P(R2, C2);
84  e=P*C1h;
85  e.Homogenize();
88  ec.Mult(R, *this);
89 }
90 
91 void FMatrixBase::
92 Compose(const KMatrix& K1, const RMatrixBase& R1, const Vector3<double>& C1,
93  const KMatrix& K2, const RMatrixBase& R2, const Vector3<double>& C2)
94 {
95  // Compose as Essential matrix E first
96  Compose(R1, C1, R2, C2);
97 
98  // Now set Fundamental matrix as F = K2^-T E K1^-1
99  BIAS::Matrix3x3<double> K1Inv, K2Inv, tmp;
100  if (K1.GetInverse(K1Inv) != 0) {
101  BIASERR("Failed to invert K1!");
102  BIASABORT;
103  }
104  if (K2.GetInverse(K2Inv) != 0) {
105  BIASERR("Failed to invert K2!");
106  BIASABORT;
107  }
108  K2.Transpose().Mult(*this, tmp);
109  tmp.Mult(K1Inv, *this);
110 }
~FMatrixBase()
destructor untested (04/18/2002)
Definition: FMatrixBase.cpp:36
HomgLine2D GetEpipolarLineImage2(const HomgPoint2D &point) const
Returns epipolar line in image 2 for point in image 1.
Definition: FMatrixBase.cpp:64
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
void Mult(const Vector3< T > &argvec, Vector3< T > &destvec) const
matrix - vector multiplicate this matrix with Vector3, storing the result in destvec calculates: dest...
Definition: Matrix3x3.hh:302
int GetInverse(Matrix3x3< T > &inv) const
Matrix inversion: inverts this and stores resulty in argument inv.
Definition: Matrix3x3.cpp:373
a line l = (a b c)^T is a form of the implicit straight line equation 0 = a*x + b*y + c if homogenize...
Definition: HomgLine2D.hh:48
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrixBase.hh:74
HomgLine2D GetEpipolarLineImage1(const HomgPoint2D &point) const
Returns epipolar line in image 1 for point in image 2.
Definition: FMatrixBase.cpp:41
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
Definition: Matrix3x3.cpp:167
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
void Compose(const KMatrix &K1, const RMatrixBase &R1, const Vector3< double > &C1, const KMatrix &K2, const RMatrixBase &R2, const Vector3< double > &C2)
constructs the FMatrix from image 1 to image 2 as K1 [e]_x R K2
Definition: FMatrixBase.cpp:92
Implements a 3D rotation matrix.
Definition: RMatrixBase.hh:44
void SetAsCrossProductMatrix(const Vector3< T > &vec)
Sets matrix from vector as cross product matrix of this vector.
Definition: Matrix3x3.cpp:275