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

example investigating P-Matrix

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003, 2004 (see file CONTACTS 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 ProjectionError.cpp
@relates ProjectionError
@brief example investigating P-Matrix
@ingroup g_examples
@author MIP
*/
#include <Geometry/ProjectionError.hh>
#include <Utils/Param.hh>
#include <MathAlgo/StandardDeviation.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char **argv)
{
Param pp;
pp.AddParamDouble("baseline", "Abstand der beiden Kameras",
0.0, 0.0, DBL_MAX, 'b', 1);
pp.AddParamDouble("angle", "Winkel Kamera1-Objekt-Kamera2",
7.5, -90.0, 90.0, 'a', 1);
pp.AddParamDouble("mindepth", "Minimale Tiefe",
0.0, 0.0, DBL_MAX, 'd', 1);
pp.AddParamDouble("maxdepth", "Maximale Tiefe",
0.0, 0.0, DBL_MAX, 'D', 1);
pp.AddParamDouble("offset", "Verschiebung auf der Bildebene",
0.5, 0.0, DBL_MAX, 'o', 1);
pp.AddParamInt("resolution", "Horizontale Kameraaufloesung",
0, 0, INT_MAX, 'r', 1);
pp.AddParamInt("tests", "Anzahl an Tests",
25, 0, INT_MAX, 't', 1);
pp.SetGroupName(1, "Parameter");
pp.ParseCommandLine(argc, argv);
double b = *pp.GetParamDouble("baseline");
double a = *pp.GetParamDouble("angle");
double dMin = *pp.GetParamDouble("mindepth");
double dMax = *pp.GetParamDouble("maxdepth");
double offset = *pp.GetParamDouble("offset");
int res = *pp.GetParamInt("resolution");
int nTests = *pp.GetParamInt("tests");
if (dMin <= 0 || res <= 0)
{
pp.Usage();
return 1;
}
if (dMax <= dMin)
nTests = 1;
double d = dMin;
if (b == 0.0)
pe.Init(res, dMin, a * M_PI / 180.0);
else
pe.Init(res, b);
for (int i = 0; i < nTests; i++)
{
sd.Clear();
sd.AddValue(pe.ComputeDiff(d, -offset));
sd.AddValue(pe.ComputeDiff(d, 0.0));
sd.AddValue(pe.ComputeDiff(d, offset));
double s = sd.CalcStandardDeviation();
cout << d << "\t" << s << endl;
d += (dMax - dMin) / (nTests - 1);
}
if (b == 0.0)
{
b = pe.GetBaseline();
cout << "Baseline: " << b << endl;
}
return 0;
}