Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProjectionError.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003, 2004 (see file CONTACTS 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 /**
27  @example ProjectionError.cpp
28  @relates ProjectionError
29  @brief example investigating P-Matrix
30  @ingroup g_examples
31  @author MIP
32 */
33 
34 #include <Geometry/ProjectionError.hh>
35 #include <Utils/Param.hh>
36 #include <MathAlgo/StandardDeviation.hh>
37 
38 using namespace BIAS;
39 using namespace std;
40 
41 int main(int argc, char **argv)
42 {
43  Param pp;
44  pp.AddParamDouble("baseline", "Abstand der beiden Kameras",
45  0.0, 0.0, DBL_MAX, 'b', 1);
46  pp.AddParamDouble("angle", "Winkel Kamera1-Objekt-Kamera2",
47  7.5, -90.0, 90.0, 'a', 1);
48  pp.AddParamDouble("mindepth", "Minimale Tiefe",
49  0.0, 0.0, DBL_MAX, 'd', 1);
50  pp.AddParamDouble("maxdepth", "Maximale Tiefe",
51  0.0, 0.0, DBL_MAX, 'D', 1);
52  pp.AddParamDouble("offset", "Verschiebung auf der Bildebene",
53  0.5, 0.0, DBL_MAX, 'o', 1);
54  pp.AddParamInt("resolution", "Horizontale Kameraaufloesung",
55  0, 0, INT_MAX, 'r', 1);
56  pp.AddParamInt("tests", "Anzahl an Tests",
57  25, 0, INT_MAX, 't', 1);
58  pp.SetGroupName(1, "Parameter");
59 
60  pp.ParseCommandLine(argc, argv);
61 
62  double b = *pp.GetParamDouble("baseline");
63  double a = *pp.GetParamDouble("angle");
64  double dMin = *pp.GetParamDouble("mindepth");
65  double dMax = *pp.GetParamDouble("maxdepth");
66  double offset = *pp.GetParamDouble("offset");
67  int res = *pp.GetParamInt("resolution");
68  int nTests = *pp.GetParamInt("tests");
69 
70  if (dMin <= 0 || res <= 0)
71  {
72  pp.Usage();
73  return 1;
74  }
75 
76  if (dMax <= dMin)
77  nTests = 1;
78 
79  ProjectionError pe;
80  double d = dMin;
81  if (b == 0.0)
82  pe.Init(res, dMin, a * M_PI / 180.0);
83  else
84  pe.Init(res, b);
85 
87  for (int i = 0; i < nTests; i++)
88  {
89  sd.Clear();
90  sd.AddValue(pe.ComputeDiff(d, -offset));
91  sd.AddValue(pe.ComputeDiff(d, 0.0));
92  sd.AddValue(pe.ComputeDiff(d, offset));
93  double s = sd.CalcStandardDeviation();
94 
95  cout << d << "\t" << s << endl;
96 
97  d += (dMax - dMin) / (nTests - 1);
98  }
99 
100  if (b == 0.0)
101  {
102  b = pe.GetBaseline();
103  cout << "Baseline: " << b << endl;
104  }
105 
106  return 0;
107 }
108 
void Init(int res, double depth, double angle)
Initiates cameras and calculates the length of the baseline based on minDepth and angle...
double * GetParamDouble(const std::string &name) const
Definition: Param.cpp:665
double GetBaseline() const
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:351
double CalcStandardDeviation()
Compute standard deviation of internally sorted values.
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
double ComputeDiff(double z, double offset)
void Clear()
Clear the internally stored values.
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
Definition: Param.cpp:176
Computes the standard deviation and mean of given values.
int * GetParamInt(const std::string &name) const
Definition: Param.cpp:618
void AddValue(double v)
Add a value to the vector of internally stored values.
This class Param provides generic support for parameters.
Definition: Param.hh:231
int SetGroupName(const int group_id, const std::string &name)
sets the name for a group
Definition: Param.cpp:1448
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Definition: Param.cpp:276