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

Example for TrifocalTensor with Synthetic Matches

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 ExampleTFT.cpp
* @relates TrifocalTensorBase
@ingroup g_examples
@brief Example for TrifocalTensor with Synthetic Matches
@author MIP */
#include <iostream>
#include <Utils/GenSynthMatches.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Geometry/TrifocalTensorBase.hh>
#include <Base/Common/BIASpragma.hh>
using namespace BIAS;
using namespace std;
#define DEFAULT_PARA_FILE_NAME "TFT.ini"
#define DEBUG true
int main(int argc, char *argv[])
{
Param para;
GenSynthMatches gsm(para);
// gsm.AddDebugLevel(GSM_CAM_MOTION);
// gsm.AddDebugLevel(GSM_VIEWINGVOL);
// gsm.AddDebugLevel(GSM_3D_POINTS);
// gsm.AddDebugLevel(GSM_2D_MATCHES);
// gsm.AddDebugLevel(GSM_MOVIN_TRANSF);
bool FoundDefaultParaFile=true;
ifstream is(DEFAULT_PARA_FILE_NAME);
if (!is){
is.close();
if (DEBUG) cerr << "reading "<<DEFAULT_PARA_FILE_NAME<<" failed"<<endl;
FoundDefaultParaFile=false;
} else {
if (DEBUG) cerr << "reading "<<DEFAULT_PARA_FILE_NAME<<endl;
para.ReadParameter(DEFAULT_PARA_FILE_NAME);
}
int argind = para.ParseCommandLine(argc, argv);
if (argind<0){
BIASERR("error parsing command line");
return -1;
}
if ((!FoundDefaultParaFile) && (*para.GetParamString("readconfig")=="")) {
cerr << "no parameter file found, writing default to "
<<DEFAULT_PARA_FILE_NAME<<"\n";
para.SetWriteOptions(true,false,false);
para.WriteParameter(DEFAULT_PARA_FILE_NAME);
}
if (*para.GetParamInt("NumImages")<3){
BIASERR("must be at least 3 images for trifocal tensor");
BIASASSERT(false);
}
gsm.WriteData("data.txt");
//cout << gsm <<endl;
gsm.DrawTrue(im, 0, 2);
//ImageIO::Save("true.mip", im);
ImageIO::Save("true.mip", im);
gsm.DrawNoisy(im, 0, 2);
//ImageIO::Save("noisy.mip", im);
ImageIO::Save("noisy.mip", im);
int num=*para.GetParamInt("NumPoints");
vector<HomgPoint2D> m1, m2, m3;
vector<RMatrixBase> R(3);
vector<HomgPoint3D> C(3);
gsm.GetNormalizedPoints(0, m1);
gsm.GetNormalizedPoints(1, m2);
gsm.GetNormalizedPoints(2, m3);
gsm.GetR(R);
gsm.GetC(C);
tft.Compose(R[0], R[1], R[2], C[0], C[1], C[2]);
/*
vector<RMatrixBase> mR(2);
vector<Vector3<double> > mC(2);
for (int i=1; i<3; i++){
mR[i-1]=R[0].Transpose() * R[i];
C[i].Homogenize(); C[0].Homogenize();
HomgPoint3D dC=C[i]-C[0];
for (int k=0; k<3; k++) mC[i-1][k]=dC[k];
mC[i-1]=R[0].Transpose() * mC[i-1];
}
tft.Compose(mR[0], mR[1], mC[0], mC[1]);
*/
for (int i=0; i<num; i++){
tft.CheckPointCorr(m1[i], m2[i], m3[i], res);
//cerr << setw(3)<<i<<" : " << res ;//<< endl;
cerr << setw(3)<<i<<" : " << res.NormL1() <<"\t"<< res.NormL2()<<endl;
}
return 0;
}