Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleExtractKFromMipImage.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 ExampleExtractKFromMipImage.cpp
27  @relates KMatrix,Image,
28  @brief Example for extracting the K-Matrix from a mip image
29  @ingroup g_examples
30  @author MIP
31 */
32 
33 #include <iostream>
34 #include <sstream>
35 
36 #include <Image/Camera.hh>
37 #include <Base/Image/ImageIO.hh>
38 #include <Geometry/Projection.hh>
39 #include <Geometry/ProjectionParametersPerspective.hh>
40 #include <Base/Geometry/KMatrix.hh>
41 
42 using namespace BIAS;
43 using namespace std;
44 
45 
46 int main(int argc, char** argv) {
47 
48  // argument specified?
49  if (argc != 2) {
50  BIASERR("don't know which image to use!/n/n usage: ExampleExtractKFromMipImage <path_to_image>");
51  BIASABORT;
52  }
53 
55 
56  // load image
57  if (ImageIO::Load(argv[1], image) != 0) {
58  BIASERR("specified image could not be loaded!");
59  BIASABORT;
60  }
61  cout << "image loaded successfully!" << endl;
62 
63  // check for valid projection
64  image.ParseMetaData();
65  if (!image.IsProjValid()) {
66  BIASERR("image contains no valid projection!");
67  BIASABORT;
68  }
69 
70  // extract projection and K matrix
71  cout << "getting K... ";
72  Projection proj = image.GetProj();
75  KMatrix K = ppp->GetK();
76 
77  cout << "done!" << endl;
78 
79  // save K matrix
80  ostringstream filenameK;
81  filenameK << argv[1] << ".mat";
82  cout << "saving K as " << filenameK.str() << endl;
83  K.Save(filenameK.str());
84 
85  return 0;
86 }
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
bool Save(const std::string &fname) const
Definition: Matrix3x3.cpp:563
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
Definition: Projection.hh:194
This class hides the underlying projection model, like projection matrix, spherical camera...
Definition: Projection.hh:70
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
Definition: ImageIO.cpp:141
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
bool IsProjValid() const
Definition: Camera.hh:221
const BIAS::Projection & GetProj() const
Definition: Camera.hh:109
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...
Definition: Camera.cpp:154