Image Component Library (ICL)
Homography2D.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/Homography2D.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLMath/FixedMatrix.h>
35 #include <ICLUtils/Point32f.h>
36 
37 namespace icl{
38  namespace math{
39 
41 
155  template<class T>
156  struct ICLMath_IMP GenericHomography2D : public FixedMatrix<T, 3, 3>{
159 
161  enum Algorithm{
164  };
165 
168 
170  GenericHomography2D(const utils::Point32f *pAs, const utils::Point32f *pBs, int n=4, Algorithm algo = Advanced);
171 
172 
175  float az = H(0,2)*p.x + H(1,2) * p.y + H(2,2);
176  return utils::Point32f(( H(0,0)*p.x + H(1,0) * p.y + H(2,0) ) / az,
177  ( H(0,1)*p.x + H(1,1) * p.y + H(2,1) ) / az );
178  }
179 
181  inline utils::Point32f apply(const utils::Point32f &p) const{
182  return apply_homography(*this,p);
183  }
184 
187  float az = H(0,2)*p.x + H(1,2) * p.y + H(2,2);
188  return utils::Point(round(( H(0,0)*p.x + H(1,0) * p.y + H(2,0) ) / az),
189  round(( H(0,1)*p.x + H(1,1) * p.y + H(2,1) ) / az) );
190  }
191 
193  inline utils::Point32f apply_int(const utils::Point32f &p) const{
194  return apply_homography_int(*this, p);
195  }
196  };
197 
200 
201 
202  } // namespace math
203 }
204 
FixedMatrix< T, 3, 3 > Super
super class typedef for shorter super-class references
Definition: Homography2D.h:158
utils::Point32f apply_int(const utils::Point32f &p) const
applies the homography
Definition: Homography2D.h:193
Powerful and highly flexible matrix class implementation.
Definition: FixedMatrix.h:172
undocument this line if you encounter any issues!
Definition: Any.h:37
float y
y position of this point
Definition: Point32f.h:48
use the simple algorithm (
Definition: Homography2D.h:162
GenericHomography2D()
Empty constructor.
Definition: Homography2D.h:167
utils::Point32f apply(const utils::Point32f &p) const
applies the homography
Definition: Homography2D.h:181
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
static utils::Point apply_homography_int(const FixedMatrix< float, 3, 3 > &H, const utils::Point &p)
applies a given homography matrix
Definition: Homography2D.h:186
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
#define ICLMath_IMP
Definition: CompatMacros.h:172
float x
x position of this point
Definition: Point32f.h:45
GenericHomography2D< float > Homography2D
default homography 2D type definition (usually float depth is enough)
Definition: Homography2D.h:199
static utils::Point32f apply_homography(const FixedMatrix< float, 3, 3 > &H, const utils::Point32f &p)
applies a given homography matrix
Definition: Homography2D.h:174
use the advanced algorithm (
Definition: Homography2D.h:163
Utility structure that represents a 2D homography (implemented for float and double)
Definition: Homography2D.h:156
Algorithm
Internally used algorithm type.
Definition: Homography2D.h:161