Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleLoadBOG_P.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT 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 ExampleLoadBOG_P.cpp
28  @brief Example Daimler .bog reader
29  @ingroup g_examples
30  @author Jan Woetzel
31 */
32 
33 
34 #include <Base/Common/BIASpragma.hh>
35 
36 // STD
37 #include <iostream>
38 #include <fstream>
39 #include <string>
40 #include <vector>
41 
42 // BIAS
43 #include <Base/Math/BogIO.hh>
44 #include <Base/Math/Vector3.hh>
45 #include <Base/Geometry/KMatrix.hh>
46 #include <Geometry/PMatrix.hh>
47 #include <Geometry/RMatrix.hh>
48 
49 
50 using namespace std;
51 using namespace BIAS;
52 
53 // entry JW
54 int main(int argc, char** argv){
55  cout<<"started "<<argv[0]<<endl;
56 #ifdef BIAS_TESTS_DATA
57  string filename(BIAS_TESTS_DATA "calib01.bog");
58 #else
59  string filename("calib01.bog");
60  cout<<"BIAS_TESTS_DATA not defined."<<endl;
61  return -1;
62 #endif
63  if (argc>1) filename=argv[1];
64  cout<<"using filename "<<filename<<endl;
65  int result=0;
66  //bool ok=true;
67 
68  PMatrix P;
69  if (0!=P.LoadBOG(filename)) return -2;
70  cout<<"P: "<<P<<endl;
71  P.Save("out_ExampleLoadBOGP.P");
72 
73  KMatrix K;
74  LoadBogK(filename, K);
75  RMatrix R;
76  LoadBogRC(filename, R);
77  Vector3<double> C;
78  C.LoadBogTC(filename);
79 
80  // compare:
81  cout<<"bog.K: "<<K<<endl;
82  cout<<"P.K : "<<P.GetK()<<endl;
83 
84  cout<<"bog.R: "<<R<<endl;
85  cout<<"P.R : "<<P.GetR()<<endl;
86  Vector3<double> axis;
87  double angle=0;
88  R.GetRotationAxisAngle(axis,angle);
89  cout<<"P.angle="<<angle<<" axis="<<axis<<endl;
90 
91  cout<<"bog.C: "<<C<<endl;
92  cout<<"P.C : "<<P.GetC()<<endl;
93 
94  return result; // OK.
95 }
int LoadBogTC(const std::string &filename)
reads the TC part of a BOG file which is used by Daimler Chrysler for storing Camera center position...
Definition: Vector3.cpp:161
int LoadBogK(const std::string &filename, Matrix3x3< T > &mat)
Definition: BogIO.hh:91
int GetR(Matrix3x3< double > &R)
Definition: PMatrix.cpp:204
3D rotation matrix
Definition: RMatrix.hh:49
int LoadBOG(const std::string &filename)
Load a Daimler .bog fiel and compose a P matrix from it.
int GetC(Vector3< double > &C)
computes translation vector origin world coo -&gt; origin camera coo (center), uses decomposition, which is cached
Definition: PMatrix.cpp:165
bool Save(const std::string &filename)
Definition: PMatrix.cpp:1146
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
int LoadBogRC(const std::string &filename, Matrix3x3< T > &mat)
Definition: BogIO.hh:17
int GetRotationAxisAngle(Vector3< ROTATION_MATRIX_TYPE > &axis, ROTATION_MATRIX_TYPE &angle) const
Calculates angle and rotation axis representation for this rotation matrix.
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
int GetK(KMatrix &K)
calibration matrix
Definition: PMatrix.cpp:220