Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleProjectionParametersSpherical.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  @example ExampleProjectionParametersSpherical.cpp
27  @relates ProjectionParametersSpherical
28  @brief small example demonstrating the ProjectionParametersSpherical
29  @ingroup g_examples
30  @author ischiller 10/2009
31 */
32 
33 #include <Geometry/ProjectionParametersSpherical.hh>
34 #include <Base/Image/Image.hh>
35 #include <Base/Image/ImageIO.hh>
36 
37 using namespace BIAS;
38 using namespace std;
39 
40 int main(int argc, char *argv[])
41 {
42  int ImgWidth=800, ImgHeight=800;
44  pps.SetImageSize(ImgWidth,ImgHeight);
45  pps.SetPrincipal(ImgWidth/2,ImgHeight/2);
46  std::vector<double> corrX, corrY;
47  double maxAngle = 180;
48  corrX.push_back(0.0);
49  corrX.push_back(M_PI*maxAngle/90.0);
50  corrY.push_back(0.0);
51  corrY.push_back(M_PI*maxAngle/180.0);
52 
53  pps.SetUndistortion(corrX, corrY, 356.0);
54 
55 
56  std::vector<double> coeffs(4);
57  coeffs[0] = 1.0;
58  coeffs[1] = 0.0;
59  coeffs[2] = 0.0;
60  coeffs[3] = 0.0;
61  pps.SetRadius(350);
62  pps.InitAngleCorrFromPoly(90.0*M_PI/180.0,coeffs);
63 
64 
65 #ifdef BIAS_HAVE_XML2
66  string fname = "ProjParSphericalExample01.xml";
67 
68 
69  int res = pps.XMLWrite(fname);
70 
71  if (res!=0)
72  {
73  cerr << "error writing "<< fname << endl;
74  return -3;
75  }
76  cout << "XMLWrite wrote "<< fname << endl;
77 
78  res = pps.XMLRead(fname);
79 
80  if (res!=0)
81  {
82  cerr << "error reading "<< fname << endl;
83  return -3;
84  }
85  cout << "XMLWrite read "<< fname << endl;
86  cout<<pps<<endl;
87 #else
88  cout<<"did not XMLWrite because BIAS_HAVE_XML2 not available."<<endl;
89 #endif
90 
91  return 0;
92 }
virtual void SetPrincipal(const double x, const double y)
Set principal point (in pixels relative to top left corner).
int XMLRead(const std::string &Filename)
derived classes must implement the function XMLIn which is called by this function XMLRead to read ev...
Definition: XMLBase.cpp:78
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
void SetRadius(const double r)
Set radius of spherical image in pixels.
int InitAngleCorrFromPoly(const double maxCamAngle, const double acCoeff0, const double acCoeff1, const double acCoeff2, const double acCoeff3, const double acCoeff4)
int XMLWrite(const std::string &Filename, int CompressionLevel=0, bool AutoAddCompressionSuffix=true, std::string encoding="UTF-8") const
call this to add the class to a new xml tree and write it to the file Filename.
Definition: XMLBase.cpp:40
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
int SetUndistortion(const std::vector< double > &undistAngles, const std::vector< double > &distAngles, const double radius)
Set undistortion polynomial from corresponding undistorted and distorted azimuth angles (in rad) and ...