Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleProjectionParametersIO.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 ExampleProjectionParametersIO.cpp
28  @relates ProjectionParametersIO
29  @brief small example demonstrating the ProjectionParametersIO
30  @ingroup g_examples
31  @author woelk 12/2006
32 */
33 
34 #include <Geometry/ProjectionParametersIO.hh>
35 #include <iostream>
36 
37 using namespace BIAS;
38 using namespace std;
39 
40 int main (int argc, char* argv[])
41 {
42  CameraData cd, cd2;
43  vector<CameraData> vcd, vcd2;
44 #ifdef BIAS_HAVE_XML2
45  if (argc<2) {
46  cout <<"no file given, using some build-in data"<<endl;
48  }
49  else {
50  if (ProjectionParametersIO::ReadCameraData(argv[1],cd)<0) {
51  cout << "Error reading file:" << argv[1] << endl;
52  } else {
53  cout << "Read file:" << argv[1] << endl;
54  }
55  }
56 
57  if (argc<3) {
58  cout <<"no rig file given, using some build-in data"<<endl;
60  } else {
61  BIASASSERT(argc>1);
62  if (ProjectionParametersIO::ReadRigData(argv[2],vcd)<0) {
63  cout << "Error reading file:" << argv[1] << endl;
64  } else {
65  cout << "Read file:" << argv[1] << endl;
66  }
67  }
68  cout << "File contents: ";
69  if (argc>1)
70  cout<<argv[1] ;
71  cout << "-------------------" << endl;
72  cout << cd;
73  ProjectionParametersIO::WriteCameraData("CamDataTest.xml",cd);
74  cout <<"CamDataTest.xml created" << endl;
75 
76  ProjectionParametersIO::ReadCameraData("CamDataTest.xml",cd2);
77  cout << "File contents: " << "CamDataTest.xml"
78  << "-------------------" << endl;
79  cout << cd2;
80  ProjectionParametersIO::WriteCameraData("CamDataTestRewrite.xml", cd2);
81  cout <<"CamDataTestRewrite.xml created" << endl;
82 
83  cout << "File contents: ";
84  if (argc>2)
85  cout<<argv[2];
86  cout<< "-------------------" << endl;
87  cout << vcd;
88  ProjectionParametersIO::WriteRigData("RigDataTest.xml",vcd);
89  cout <<"RigDataTest.xml created" << endl;
90 
91  ProjectionParametersIO::ReadRigData("RigDataTest.xml",vcd2);
92  cout << "File contents: " << "RigDataTest.xml"
93  << "-------------------" << endl;
94  cout << vcd2;
95  ProjectionParametersIO::WriteRigData("RigDataTestRewrite.xml", vcd2);
96  cout <<"RigDataTestRewrite.xml created" << endl;
97 #endif
98  return 0;
99 }
static void SetData_DummyRig(std::vector< CameraData > &vcd)
static int ReadCameraData(const std::string &Filename, CameraData &cd, const bool silent=false)
Read a camera data parameter file and store the data in (*this)
static int WriteCameraData(const std::string &Filename, const CameraData &cd)
Write all data to a camera data parameter file )
static int ReadRigData(const std::string &filename, std::vector< CameraData > &vcd, const bool silent=false)
Read a rig parameter file and store the data in (*this) the Camera-, Center-, RMatrix-, and KMatrix-Vectors are reset from the file.
static int WriteRigData(const std::string &filename, const std::vector< CameraData > &vcd, const std::vector< SensorData > &vsd=std::vector< SensorData >(0, SensorData()))
Write all data camera data and camera positions in the rig to a rig parameter file in XML-notation...
static void SetData_OMNITECH_ORIFL_190_3(CameraData &cd)