Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestCalibratedPyramid.cpp
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003-2009 (see file CONTACT for details)
4  Multimediale Systeme der Informationsverarbeitung
5  Institut fuer Informatik
6  Christian-Albrechts-Universitaet Kiel
7 
8  BIAS is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 2.1 of the License, or
11  (at your option) any later version.
12 
13  BIAS is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with BIAS; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
21 
22 /**
23  * @example TestCalibratedPyramid.cpp
24  * @relates CalibratedPyramid
25  * @brief shows usage of calibrated pyramid
26  * @author MIP
27  * @date 2007
28  */
29 
30 
31 #include <Base/Geometry/KMatrix.hh>
32 #include <Geometry/ProjectionParametersPerspective.hh>
33 #include <Image/CalibratedPyramid.hh>
34 
35 #include <vector>
36 
37 using namespace BIAS;
38 using namespace std;
39 
40 SharedPtr<ProjectionParametersBase> GetProjPersp(const double focal)
41 {
42  // generate projection parameters with fake K matrix
44  K[0][0] = K[1][1] = focal;
45  K[0][2] = 320.0; K[1][2] = 240.0;
46 
49  projpersp->SetK(K);
51  DynamicCast<ProjectionParametersBase>(projpersp);
52  BIASASSERT(proj);
53  return proj;
54 }
55 
56 void GetCalibratedPyramid(CalibratedPyramid<unsigned char>& cp)
57 {
60  im->FillImageWithXValue();
61  const double focal = 800.0;
63  ci.image = im;
64  ci.projection = GetProjPersp(focal);
65 
66  cp.Init(ci);
67 }
68 
69 
70 void TestInit()
71 {
72  Image<unsigned char> im(640, 480, 1);
73  im.FillImageWithXValue();
74  const int x = 42, y = 42;
75  unsigned char val = im.GetImageDataArray()[y][x];
76 
81 
82  const unsigned size = 2;
83  const double factor = 4.0;
84  cp.Init(ci, size, factor);
85 
86  if (cp.IsEmpty()) { BIASABORT; }
87  if (cp.Size()!=size) { BIASABORT; }
88  if (!Equal(cp.GetRescaleFactor(), factor)) { BIASABORT; }
89 
90  // test access
91  unsigned char mval = cp[0].image->GetImageDataArray()[y][x];
92  if (val != mval) { BIASABORT; }
93 }
94 
95 
96 void TestSTL()
97 {
98  vector<CalibratedPyramid<unsigned char> > vcp(3);
100  GetCalibratedPyramid(cp);
101  vcp[1] = cp;
102 }
103 
104 
105 int main(int argc, char *argv[])
106 {
107  TestInit();
108  TestSTL();
109  return 0;
110 }
This class takes care of consisiten re-sampling of images and associated ProjectionParameters.
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
pointer with reference count and automatic deletion
Definition: SharedPtr.hh:50
SharedPtr< Image< StorageType > > image
helper class holding image and associated calibration
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
SharedPtr< ProjectionParametersBase > projection
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
virtual void SetK(const KMatrix &K)
sets the internal parameters from a given KMatrix and updates the cached K and its inverse ...