Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleEpipolarLine.cpp

Example for epipolar line estimation

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@example ExampleEpipolarLine.cpp
@brief Example for epipolar line estimation
@ingroup g_examples
@author MIP
*/
#include <Geometry/FMatrix.hh>
#include <Geometry/RMatrix.hh>
#include <Geometry/PMatrix.hh>
#include <Geometry/EpipolarLine.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
// set up two perspective pinhole cameras and commpute epipolar geometry:
Vector3<double> C1(0,0,0), C2(1,0,0);
PMatrix P1(K1,R1,C1), P2(K2,R2,C2);
FMatrix F(P1,P2);
// F[0][0] = -7.93016446160826e-18;
// F[0][1] = -0.142857142857143;
// F[0][2] = 0.142857142857143;
//
// F[1][0] = 0.142857142857143;
// F[1][1] = 9.51619735392991e-17;
// F[1][2] = -1;
//
// F[2][0] = -0.142857142857143;
// F[2][1] = 1;
// F[2][2] = 1.58603289232165e-16;
// two corresponding 2d points (x2 yet undefined)
HomgPoint3D X(0,0,1);
HomgPoint2D x1(P1*X), x2(P2*X);
x1.Homogenize();
x2.Homogenize();
EpipolarLine e = F * x1;
// e[0] = -0.1447129985;
// e[1] = 0.9894736722;
// e[2] = 0.02351731724;
double minx = -0.704896591;
double miny = -0.5087899419;
double maxx = 0.6917137055;
double maxy = 0.5023428813;
HomgPoint2D epipoleinimage1(0,0,0), epipoleinimage2(0,0,0);
F.GetEpipolesHomogenized(epipoleinimage1, epipoleinimage2);
epipoleinimage2.DeterminePosition(minx, miny, maxx, maxy);
int res = e.Recalc(minx,miny,maxx,maxy,epipoleinimage2,epos2);
cout<<"result from recalc is "<<res<<endl;
/*
if (fabs(x2.ScalarProduct(e))>1e-5) {
BIASERR("Something went wrong with P and F !!!");
BIASABORT;
}
*/
cout<<"Epipolar line is "<<e<<" with epipole "<< epipoleinimage2
<<" and epos "
<<int(epos2)<<endl;
cout<<" far intersection is "<<e.GetFarIntersectionWithImageBorder()
<<" close intersection: "<<e.GetCloseIntersectionWithImageBorder()
<<endl;
return 0;
}