Image Component Library (ICL)
Projective4PointTransform.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/Projective4PointTransform.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 
34 #include <ICLUtils/Point32f.h>
35 #include <vector>
36 #include <ICLUtils/Rect32f.h>
37 #include <ICLUtils/Rect.h>
38 
39 namespace icl{
40  namespace math{
41 
43 
53  utils::Point32f m_srcQuad[4], m_dstQuad[4];
54 
55 
56  public:
57 
60 
62  Projective4PointTransform(const utils::Point32f srcQuad[4], const utils::Point32f dstQuad[4]);
63 
65  Projective4PointTransform(const std::vector<utils::Point32f> &srcQuad,
66  const std::vector<utils::Point32f> dstQuad);
67 
69 
72 
74 
77  void init(const utils::Point32f srcQuad[4], const utils::Point32f dstQuad[4]);
78 
80 
84  void init(const utils::Rect32f &srcRect, const utils::Rect32f &dstRect=utils::Rect32f::null);
85 
87 
88  void init(const utils::Rect &srcRect, const utils::Rect &dstRect=utils::Rect::null);
89 
91  const Mat3 &getAInv() const { return m_Ainv; }
92 
94  const Mat3 &getB() const { return m_B; }
95 
97 
99  const Mat3 &getC() const { return m_C; }
100 
102  std::vector<utils::Point32f> getSrcQuad() const;
103 
105  std::vector<utils::Point32f> getDstQuad() const;
106 
108  inline utils::Point32f mapPoint(const utils::Point32f &p) const{
109  Vec3 m = m_C * Vec3(p.x,p.y,1);
110  const float norm = m[2] ? 1/m[2] : 1;
111  return utils::Point32f(m[0]*norm,m[1]*norm);
112  }
113 
115  void setSrcQuad(const utils::Point32f srcQuad[4]);
116 
118  void setDstQuad(const utils::Point32f dstQuad[4]);
119 
121  void setSrcQuad(const utils::Point32f &a, const utils::Point32f &b,
122  const utils::Point32f &c, const utils::Point32f &d);
123 
125  void setDstQuad(const utils::Point32f &a, const utils::Point32f &b,
126  const utils::Point32f &c, const utils::Point32f &d);
127 
128 
130 
131  std::vector<utils::Point32f> map(const std::vector<utils::Point32f> &src);
132 
134  template<class SrcForwardIterator, class DstForwardIterator>
135  inline void map(SrcForwardIterator begin, SrcForwardIterator end, DstForwardIterator dst){
136  while(begin != end){
137  *dst++ = mapPoint(*begin++);
138  }
139  }
140 
141  };
142  }
143 }
Mat3 m_B
internally held destination transform
Definition: Projective4PointTransform.h:51
Mat3 m_C
internally held result-transform C = B * A_inv
Definition: Projective4PointTransform.h:52
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API core::Img< T > norm(const core::Img< T > &image)
normalize an images range to [0,255]
#define ICLMath_API
Definition: CompatMacros.h:173
Utility class that provides functions to perspectively map 4 points of a source frame into 4 points o...
Definition: Projective4PointTransform.h:49
float y
y position of this point
Definition: Point32f.h:48
static const Rect32f null
!< height of the rect
Definition: Rect32f.h:54
static const Rect null
null Rect is w=0, h=0, x=0, y=0
Definition: Rect.h:99
Floating point precision implementation of the Rect class.
Definition: Rect32f.h:45
void map(SrcForwardIterator begin, SrcForwardIterator end, DstForwardIterator dst)
maps points in an iterator based fashion
Definition: Projective4PointTransform.h:135
const Mat3 & getAInv() const
returns the internally stored inverse source transform matrix
Definition: Projective4PointTransform.h:91
Mat3 m_Ainv
internally held inverse source transform
Definition: Projective4PointTransform.h:50
const Mat3 & getC() const
returns the internally stored combined transform matrix
Definition: Projective4PointTransform.h:99
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
float x
x position of this point
Definition: Point32f.h:45
utils::Point32f mapPoint(const utils::Point32f &p) const
maps a single point from the source quadrangle into the destination quadrangle
Definition: Projective4PointTransform.h:108
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
FixedColVector< icl32f, 3 > Vec3
another shortcut for 3D vectors
Definition: HomogeneousMath.h:40
const Mat3 & getB() const
returns the internally stored inverse destination transform matrix
Definition: Projective4PointTransform.h:94