IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Homography3d.h
1 // Homography3d.h:
3 // ---------------
4 //
14 
15 #ifndef __IPSDKMATH_HOMOGRAPHY3D_H__
16 #define __IPSDKMATH_HOMOGRAPHY3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Homography3d::_matA' : class 'boost::numeric::ublas::bounded_matrix<ipsdk::ipReal64,0x04,0x04,boost::numeric::ublas::row_major>' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Homography3d'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKMath/Geometry/3d/Transform/BaseLinearGeometricTransform3d.h>
24 
25 namespace ipsdk {
26 namespace math {
27 namespace transform {
28 
31 
33 {
34 // predefined public type
35 public:
38 
39  (eTP_Axx)
40  (eTP_Axy)
41  (eTP_Axz)
42  (eTP_Axw)
43  (eTP_Ayx)
44  (eTP_Ayy)
45  (eTP_Ayz)
46  (eTP_Ayw)
47  (eTP_Azx)
48  (eTP_Azy)
49  (eTP_Azz)
50  (eTP_Azw)
51  (eTP_Awx)
52  (eTP_Awy)
53  (eTP_Awz)
54  (eTP_Aww)
55  );
56 
57  // declare geometric transformation 3d
59 
60 public:
64  {
65  _matA(0, 0) = 1; _matA(0, 1) = 0; _matA(0, 2) = 0; _matA(0, 3) = 0;
66  _matA(1, 0) = 0; _matA(1, 1) = 1; _matA(1, 2) = 0; _matA(1, 3) = 0;
67  _matA(2, 0) = 0; _matA(2, 1) = 0; _matA(2, 2) = 1; _matA(2, 3) = 0;
68  _matA(3, 0) = 0; _matA(3, 1) = 0; _matA(3, 2) = 0; _matA(3, 3) = 1;
69  }
70  Homography3d(const Matrix4d& matA) :
71  _matA(matA)
72  {
73  }
74  Homography3d(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
75  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
76  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
77  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww)
78  {
79  _matA(0, 0) = axx; _matA(0, 1) = axy; _matA(0, 2) = axz; _matA(0, 3) = axw;
80  _matA(1, 0) = ayx; _matA(1, 1) = ayy; _matA(1, 2) = ayz; _matA(1, 3) = ayw;
81  _matA(2, 0) = azx; _matA(2, 1) = azy; _matA(2, 2) = azz; _matA(2, 2) = azw;
82  _matA(3, 0) = awx; _matA(3, 1) = awy; _matA(3, 2) = awz; _matA(3, 2) = aww;
83  }
84  ~Homography3d() {}
86 
87 // methods
88 public:
92  static bool transform(const Matrix4d& matA,
93  ipReal64& x, ipReal64& y, ipReal64& z)
94  {
95  return transform(matA(0, 0), matA(0, 1), matA(0, 2), matA(0, 3),
96  matA(1, 0), matA(1, 1), matA(1, 2), matA(1, 3),
97  matA(2, 0), matA(2, 1), matA(2, 2), matA(2, 3),
98  matA(3, 0), matA(3, 1), matA(3, 2), matA(3, 3),
99  x, y, z);
100  }
101  static bool transform(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
102  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
103  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
104  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww,
105  ipReal64& x, ipReal64& y, ipReal64& z)
106  {
107  const ipReal64 xTmp = axx*x + axy*y + axz*z + axw;
108  const ipReal64 yTmp = ayx*x + ayy*y + ayz*z + ayw;
109  const ipReal64 zTmp = azx*x + azy*y + azz*z + azw;
110  const ipReal64 wTmp = awx*x + awy*y + awz*z + aww;
111  if (wTmp == 0)
112  return false;
113  x = xTmp / wTmp;
114  y = yTmp / wTmp;
115  z = zTmp / wTmp;
116 
117  return true;
118  }
120 
122  static Matrix4d getHomogenousMatrix(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
123  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
124  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
125  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww)
126  {
127  Matrix4d transform;
128  transform(0, 0) = axx; transform(0, 1) = axy; transform(0, 2) = axz; transform(0, 3) = axw;
129  transform(1, 0) = ayx; transform(1, 1) = ayy; transform(1, 2) = ayz; transform(1, 3) = ayw;
130  transform(2, 0) = azx; transform(2, 1) = azy; transform(2, 2) = azz; transform(2, 2) = azw;
131  transform(3, 0) = awx; transform(3, 1) = awy; transform(3, 2) = awz; transform(3, 2) = aww;
132 
133  return transform;
134  }
135 
137  static bool isInvertible(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
138  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
139  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
140  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww);
141 
146  static Matrix4d getInvHomogenousMatrix(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
147  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
148  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
149  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww)
150  {
151  // invert input parameters
152  Matrix4d matA;
153  matA(0, 0) = axx; matA(0, 1) = axy; matA(0, 2) = axz; matA(0, 3) = axw;
154  matA(1, 0) = ayx; matA(1, 1) = ayy; matA(1, 2) = ayz; matA(1, 3) = ayw;
155  matA(2, 0) = azx; matA(2, 1) = azy; matA(2, 2) = azz; matA(2, 2) = azw;
156  matA(3, 0) = awx; matA(3, 1) = awy; matA(3, 2) = awz; matA(3, 2) = aww;
157  getInvParams(matA(0, 0), matA(0, 1), matA(0, 2), matA(0, 3),
158  matA(1, 0), matA(1, 1), matA(1, 2), matA(1, 3),
159  matA(2, 0), matA(2, 1), matA(2, 2), matA(2, 3),
160  matA(3, 0), matA(3, 1), matA(3, 2), matA(3, 3));
161 
162  return matA;
163  }
169  static void getInvParams(ipReal64& axx, ipReal64& axy, ipReal64& axz, ipReal64& axw,
170  ipReal64& ayx, ipReal64& ayy, ipReal64& ayz, ipReal64& ayw,
171  ipReal64& azx, ipReal64& azy, ipReal64& azz, ipReal64& azw,
172  ipReal64& awx, ipReal64& awy, ipReal64& awz, ipReal64& aww);
173 
175  static Vector getIdentityParams();
176 
179  void setParams(const Matrix4d& matA)
180  {
181  _matA = matA;
182  }
183  void setParams(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 axw,
184  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 ayw,
185  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 azw,
186  const ipReal64 awx, const ipReal64 awy, const ipReal64 awz, const ipReal64 aww)
187  {
188  _matA(0, 0) = axx; _matA(0, 1) = axy; _matA(0, 2) = axz; _matA(0, 3) = axw;
189  _matA(1, 0) = ayx; _matA(1, 1) = ayy; _matA(1, 2) = ayz; _matA(1, 3) = ayw;
190  _matA(2, 0) = azx; _matA(2, 1) = azy; _matA(2, 2) = azz; _matA(2, 2) = azw;
191  _matA(3, 0) = awx; _matA(3, 1) = awy; _matA(3, 2) = awz; _matA(3, 2) = aww;
192  }
194 
198  void setParams(const Vector& params);
199 
201  void setIdentity();
202 
204  void apply(ipReal64& x, ipReal64& y, ipReal64& z) const;
205 
207  Matrix4d getHomogenousMatrix() const;
208 
210  Vector getParams() const;
211 
213  bool isInvertible() const;
214 
218  Matrix4d getInvHomogenousMatrix() const;
219 
223  Vector getInvParams() const;
224 
225 // attributes
226 protected:
228  Matrix4d _matA;
229 };
230 
233 
234 inline void
236 {
238 }
239 
242 
243 } // end of namespace transform
244 } // end of namespace math
245 } // end of namespace ipsdk
247 #pragma warning (pop)
248 
249 #endif // __IPSDKMATH_HOMOGRAPHY3D_H__
void setParams(const Matrix4d &matA)
select parameters associated to transformation
Definition: Homography3d.h:197
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void setIdentity()
set transformation parameters to identity
Definition: Homography3d.h:253
Base class for linear geometric transformation 3d management.
Definition: BaseLinearGeometricTransform3d.h:27
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
IPSDKGEOMETRY_API bool apply(const BaseGeometryTransform2d &transform, BaseGeometryEntity2d &entity)
function allowing to apply in situ a given transformation on an entity
#define IPSDK_DECLARE_TRANSFORM3D(className)
macro allowing to declare a geometric transformation 3d
Definition: Transform3dHdrMacros.h:54
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
boost::numeric::ublas::bounded_matrix< ipReal64, 4, 4 > Matrix4d
4d matrix (4x4) type associated to library
Definition: LinearAlgebraTypes.h:57
static Vector getIdentityParams()
retrieve identity parameters for transformation
Transformation class allowing to manage 3d homography transformations.
Definition: Homography3d.h:32
#define IPSDK_ENUM(enumTypeStr, enumSeq)
macro allowing to declare an enumerate for library
Definition: EnumMacros.h:26
eTransformParams
Definition: Homography3d.h:39