Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleEpipolarLine.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 /**
26  @example ExampleEpipolarLine.cpp
27  @brief Example for epipolar line estimation
28  @ingroup g_examples
29  @author MIP
30 */
31 #include <Geometry/FMatrix.hh>
32 #include <Geometry/RMatrix.hh>
33 #include <Geometry/PMatrix.hh>
34 #include <Geometry/EpipolarLine.hh>
35 
36 using namespace BIAS;
37 using namespace std;
38 
39 
40 int main(int argc, char *argv[])
41 {
42  // set up two perspective pinhole cameras and commpute epipolar geometry:
45  Vector3<double> C1(0,0,0), C2(1,0,0);
46  PMatrix P1(K1,R1,C1), P2(K2,R2,C2);
47  FMatrix F(P1,P2);
48 
49 
50 // F[0][0] = -7.93016446160826e-18;
51 // F[0][1] = -0.142857142857143;
52 // F[0][2] = 0.142857142857143;
53 //
54 // F[1][0] = 0.142857142857143;
55 // F[1][1] = 9.51619735392991e-17;
56 // F[1][2] = -1;
57 //
58 // F[2][0] = -0.142857142857143;
59 // F[2][1] = 1;
60 // F[2][2] = 1.58603289232165e-16;
61 
62 
63 
64 
65 
66 
67  // two corresponding 2d points (x2 yet undefined)
68  HomgPoint3D X(0,0,1);
69  HomgPoint2D x1(P1*X), x2(P2*X);
70  x1.Homogenize();
71  x2.Homogenize();
72  EpipolarLine e = F * x1;
73 // e[0] = -0.1447129985;
74 // e[1] = 0.9894736722;
75 // e[2] = 0.02351731724;
76 
77  double minx = -0.704896591;
78  double miny = -0.5087899419;
79  double maxx = 0.6917137055;
80  double maxy = 0.5023428813;
81  HomgPoint2D epipoleinimage1(0,0,0), epipoleinimage2(0,0,0);
82  F.GetEpipolesHomogenized(epipoleinimage1, epipoleinimage2);
84  epipoleinimage2.DeterminePosition(minx, miny, maxx, maxy);
85 
86 
87 
88  int res = e.Recalc(minx,miny,maxx,maxy,epipoleinimage2,epos2);
89  cout<<"result from recalc is "<<res<<endl;
90  /*
91  if (fabs(x2.ScalarProduct(e))>1e-5) {
92  BIASERR("Something went wrong with P and F !!!");
93  BIASABORT;
94  }
95  */
96 
97  cout<<"Epipolar line is "<<e<<" with epipole "<< epipoleinimage2
98  <<" and epos "
99  <<int(epos2)<<endl;
100  cout<<" far intersection is "<<e.GetFarIntersectionWithImageBorder()
101  <<" close intersection: "<<e.GetCloseIntersectionWithImageBorder()
102  <<endl;
103 
104 
105  return 0;
106 }
int Recalc(unsigned int width, unsigned int height, HomgPoint2D &epipole, enum HomgPoint2D::EPosition epos)
assumes that data_ is already set
virtual HomgPoint2D & GetFarIntersectionWithImageBorder()
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
3D rotation matrix
Definition: RMatrix.hh:49
class representing a Fundamental matrix
Definition: FMatrix.hh:46
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
virtual HomgPoint2D & GetCloseIntersectionWithImageBorder()
A class for representing epipolar lines with useful functions like ScanLine().
Definition: EpipolarLine.hh:69