Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CylindricalRectification.hh
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 #include <Base/Common/BIASpragmaStart.hh>
26 
27 #ifndef __CylindricalRectification_hh__
28 #define __CylindricalRectification_hh__
29 
30 #include <Image/RectificationViaProjectionMappingBase.hh>
31 
32 
33 namespace BIAS {
34 
35 #define DEG_TO_RAD 0.0017453292
36 
37  /** Class implements rectification by image \b projection onto a cylinder.
38  * ProjectionParametersCylindric are calculated and used to represent
39  * the rectified state. The input projections are for now restricted to
40  * *Perspective and *Spherical cameras.
41  *
42  * \ingroup g_filter
43  * \author bartczak 11/2006
44  */
45  template <class InputStorageType, class OutputStorageType>
46  class BIASImage_EXPORT CylindricalRectification :
47  public RectificationViaProjectionMappingBase<InputStorageType,
48  OutputStorageType>
49  {
50  public:
51  virtual ~CylindricalRectification();
52 
53  /**
54  * Parameter determines the extend of the cylinder along the cylinder axis.
55  * This parameter controls how close optical rays are allowed to point into
56  * the directions of the epipoles.
57  */
58  CylindricalRectification(double maxAngleRAD = 70*DEG_TO_RAD);
59 
60  /** only perspective and spherical cameras are allowed */
61  virtual bool
62  IsInputCameraValid(const BIAS::Image<InputStorageType>& img,
63  const BIAS::ProjectionParametersBase* proj);
64 
65  protected:
66  virtual int DetermineRectificationParameters_();
67 
68  /** @{
69  * Determines the internal parameters of rectifying camera.
70  * Untill now the worst case parameters are determined trying to
71  * achieve no pixel loss.
72  *
73  * \param camera input (original) camera
74  * \param rectPose the base of the (new) rectifying camera
75  * \param minX/maxX length of the needed cylinder length
76  * \param minPhi/maxPhi extend of the cylinder around its axis
77  * \param relativeXRes pixels per length unit along cylinder axis
78  * \param relativePhiRes pixels per angle unit around cylinder axis
79  */
80  int DetermineCylindricCameraBoundries_(
81  const ProjectionParametersBase* camera,
82  const Pose& rectPose,
83  double& minX, double& maxX,
84  double& minPhi, double& maxPhi,
85  double& relativeXRes,
86  double& relativePhiRes) const;
87 
88 
89  int DetermineCylindricCameraBoundriesPerspective_(
90  const ProjectionParametersBase* camera,
91  const Pose& rectPose,
92  double& minX, double& maxX,
93  double& minPhi, double& maxPhi,
94  double& relativeXRes,
95  double& relativePhiRes) const;
96 
97  int DetermineCylindricCameraBoundriesSpherical_(
98  const ProjectionParametersBase* camera,
99  const Pose& rectPose,
100  double& minX, double& maxX,
101  double& minPhi, double& maxPhi,
102  double& relativeXRes,
103  double& relativePhiRes) const;
104 
105  int DetermineCylindricCameraBoundriesCylindric_(
106  const ProjectionParametersBase* camera,
107  const Pose& rectPose,
108  double& minX, double& maxX,
109  double& minPhi, double& maxPhi,
110  double& relativeXRes,
111  double& relativePhiRes) const;
112 
113  /** @} */
114  /**
115  * The maximally allowed half viewing angle of cylindrical rectification
116  * camera. Indirectly determines the minimal angle between cylinder
117  * axis and all optical rays.
118  */
120 
121  //HELPERS
122  static int ProjectOntoUnitCylinder_(BIAS::HomgPoint3D& point, double& phi);
123  static void SetMinMaxFrom_(BIAS::HomgPoint3D& rectPoint,
124  double& minX, double& maxX,
125  double& minPhi, double& maxPhi);
126  };
127 
128 
129 }//namespace
130 
131 #endif
132 #include <Base/Common/BIASpragmaEnd.hh>
133 
Base class for rectification implementations that make use of projections to represent rectified stat...
double maxHalfAngleInX_
The maximally allowed half viewing angle of cylindrical rectification camera.
Class implements rectification by image projection onto a cylinder.
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...