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

example demonstrating F-Matrix

, FMatrixEstimation

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 FMatrixTest.cpp
@relates FMatrix, FMatrixEstimation
@brief example demonstrating F-Matrix
@ingroup g_examples
@author MIP
*/
#include "../FMatrix.hh"
#include "../FMatrixEstimation.hh"
#include "../PMatrixEstimation.hh"
#include "../PMatrixLinear.hh"
#include "../Triangulation.hh"
#include "../../Base/Math/Random.hh"
using namespace BIAS;
using namespace std;
// ---------------------------------------------------------------------------
//int main(int argc, char *argv[])
int main()
{
BIAS::FMatrix F, TheoF;
std::vector<FMatrix> vecF;
BIAS::Random Randomizer;
for (unsigned int i=0; i<1; i++) {
// generate random ps:
for (unsigned int x=0; x<4; x++)
for (unsigned int y=0; y<3; y++) {// mit K, R und C erzeugen
P1[y][x] = Randomizer.GetUniformDistributed(-1.0, 1.0);
P2[y][x] = Randomizer.GetUniformDistributed(-1.0, 1.0);
}
TheoF.ComputeFromPMatrices(P1, P2);
vector<HomgPoint3D> points;
vector<HomgPoint2D> p1,p2;
cout << "Randomized correspondences are "<<endl;
for (unsigned int p=0; p<7; p++) {
points.push_back(HomgPoint3D(Randomizer.GetUniformDistributed(-1.0,
1.0),
Randomizer.GetUniformDistributed(-1.0,
1.0),
Randomizer.GetUniformDistributed(-1.0,
1.0)));
p1.push_back(P1 * points[p]); p1[p].Homogenize();
cout << "{ "<<p1[p]<<" ";
p2.push_back(P2 * points[p]); p2[p].Homogenize();
cout << p2[p]<<" } "<<endl;
}
bool NormalizeHartley = true;
FMatrixEstimation FEstimator(NormalizeHartley);
//vecF.resize(1);
vecF.clear();
FEstimator.SevenPoint(vecF,p1,p2);
// ground truth daten in threedout ausgeben und anzeigen(mipview3d)
// hier hat man F
// nimm leicht falsches K an und
// rufe auf PMatrixEstimation::InitFromF(falschK, P1,P2, F): hier 2 funktionen! unterschied ?
// Trianguate(P1,P2, p1,p2, points3d)
// ThreedOut::ASddPoints(points3d)
// threedout::AddCameras(P1,P2)
// threedout::vrmlout("myswcene.wrl");
// spaeter punkte verrauschen +- 0.x pixel
// spaeter: selbstkalibrierung
HomgPoint2D e1,e2, theoe1, theoe2;
cout << "Computing epipoles "<<endl;
TheoF.GetEpipolesHomogenized(theoe1, theoe2);
for (unsigned int s=0; s<vecF.size(); s++) {
vecF[s].GetEpipolesHomogenized(e1, e2);
cout << "True epipoles are "<<theoe1<<" and "<<theoe2<<endl;
cout << "est. epipoles are "<<e1<<" and "<<e2<<endl;
}
}
return 0;
}