Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMatrix.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 
26 #ifndef __BIAS_PMatrix_hh__
27 #define __BIAS_PMatrix_hh__
28 #include "bias_config.h"
29 
30 #include <Base/Common/BIASpragmaStart.hh>
31 
32 
33 #include <Base/Debug/Debug.hh>
34 #ifdef BIAS_HAVE_XML2
35 # include <Base/Common/XMLBase.hh>
36 #endif
37 #include <Base/Geometry/PMatrixBase.hh>
38 
39 #include <Base/Geometry/HomgLine2D.hh>
40 #include <Base/Geometry/HomgPlane3D.hh>
41 #include <Base/Geometry/HomgPoint3D.hh>
42 #include <MathAlgo/SVD.hh>
43 #include <Base/Geometry/KMatrix.hh>
44 #include <fstream>
45 #include <string>
46 
47 namespace BIAS {
48 
49  /** @class PMatrix
50  @ingroup g_geometry
51  @brief describes a projective 3D -> 2D mapping in homogenous coordinates
52 
53  The P Matrix is a 3x4 matrix (3 rows {Zeilen}, 4 columns{Spalten})
54  describing a mapping between a 3D projective point X in space and the
55  corresponding projective 2D point x (in an image plane).
56 
57  x = P * X
58 
59  where X is of type HomgPoint3D and x of type HomgPoint2D.
60  After homogenizing, x[0] and x[1] contain the image coordinates of the
61  projection of the 3D point.
62 
63  If P is a metric camera, it can be composed/decomposed into external
64  parameters (orientation R and center C) and internal parameters (such
65  as the focal length in the calibration matrix K):
66 
67  With R' = transpose of R, K = Camera calibration matrix and
68  C = Camera center is:
69  P = (K R' | -K R' C)
70 
71  \ref geometry "See also the more general geometry section."
72 
73  Only implementation very specific to PMatrix
74  (and not valid for general matrices, e.g. like decomposition)
75  should be implemented here.
76 
77 
78  @attention For performance reasons, the PMatrix decomposition/svd is
79  only done once, subsequent calls to GetC(),... only return copies of the
80  precomputed values. If the fields of the PMatrix have changed, the
81  user is responsible for calling InvalidateDecomposition() to force a
82  re-decomposition at the next GetC(),... call.
83  If one does not call InvalidateDecomposition() after changing a PMatrix,
84  subsequent calls of GetC() may return outdated values !
85 
86  @author Jan Woetzel **/
87 
88  class BIASGeometry_EXPORT PMatrix : public PMatrixBase
89 #ifdef BIAS_HAVE_XML2
90  , public XMLBase
91 #endif
92  {
93  public:
94 
95  inline PMatrix() : PMatrixBase()
96  { Svd_ = NULL; InvalidateDecomposition(); };
97 
98  explicit PMatrix(const MatrixInitType& i)
99  : PMatrixBase(i) { Svd_ = NULL; InvalidateDecomposition(); };
100 
101  // DEPRECATED due to instantiation problem JW
102  //explicit inline PMatrix(const char *s) : PMatrixBase(s) { Svd_ = NULL; InvalidateDecomposition(); };
103  /// replacement for above JW
104  explicit PMatrix(const std::string & s);
105 
106  /** @author grest **/
107  inline PMatrix(const PMatrix & A)
108  { Svd_=NULL; operator=(A); }
109 
110  /** @author Jan Woetzel
111  @status beta (04/17/2002) **/
112  inline PMatrix(const PMatrixBase & Amat_ )
113  : PMatrixBase(Amat_)
114  { Svd_ = NULL; InvalidateDecomposition(); };
115 
116  /** @author Jan Woetzel
117  not fine, should no be here, better cast stepwise between direct
118  father and child
119  @status untested (04/17/2002) **/
120  PMatrix(const Matrix<PMATRIX_TYPE>& Amat);
121 
122  /** Take R, K, C and compose PMatrix
123  @author Jan-Friso Evers-Senne
124  @date 2002-08-20 */
126  const Matrix3x3<PMATRIX_TYPE> &R,
127  const Vector3<PMATRIX_TYPE> &C) {
128  Svd_ = NULL; Compose(K, R, C); }
129 
130  /** destructor
131  @status untested (04/17/2002) **/
132  virtual ~PMatrix();
133 
134  inline bool IsMetric() { return IsMetric_;}
135 
136  /** setting a new size different from 3x4 is not allowed for the fixed
137  size P-Matrix overloads the general newsize from basec class
138  @author Jan Woetzel **/
139  PMatrix& newsize(int rows, int cols);
140 
141  /** @brief computes translation vector origin world coo -> origin
142  camera coo (center), uses decomposition, which is cached */
143  int GetC(Vector3<double>& C);
144 
145  /** @brief computes translation vector origin world coo -> origin
146  camera coo (center), uses decomposition, which is cached */
147  BIAS::Vector3<double> GetC();
148 
149  /** @brief computes translation vector origin world coo -> origin
150  camera coo (center), uses decomposition, which is cached */
151  int GetC(HomgPoint3D& C);
152 
153  /** @brief this is another way of getting C,
154  especially interesting for non-metric cameras
155  @author koeser 07/2004 */
156  int GetNullVector(HomgPoint3D& C);
157 
158  /** @returns rotation matrix camera -> world coo
159  (which contains the column-vectors H0, V0, A (from left to right) ) */
160  int GetR(Matrix3x3<double>& R);
162  { if (!IsDecomposed_ ) if (Decompose_() != 0)
163  BIASERR("error decomposing"); return R_; };
164 
165  /// calibration matrix
166  int GetK(KMatrix& K);
167 
168  inline KMatrix GetK()
169  { if (!IsDecomposed_ ) if (Decompose_() != 0)
170  BIASERR("error decomposing"); return K_; };
171 
172  /**
173  @brief returns the unit vector H0, while H0 and V0 span
174  the camera coordinate system in world coordinates
175 
176  returns the unit vector H0 which is not the cam.
177  standard CAHV because image size is unknown (docu: JW 11/2002)
178  represents the world coordinates of the vector (1,0,0) in ics
179  A,H,V are orthonormal */
180  int GetH(Vector3<double>& H);
181  BIAS::Vector3<double> GetH();
182 
183  /** @return the unit vector V0 which is not the cam.#
184  standard CAHV because image size is unknown (docu: JW 11/2002)
185  A,H,V are orthonormal*/
186  int GetV(Vector3<double>& V);
187  BIAS::Vector3<double> GetV();
188 
189  /* @return up-vector of OpenGL camera
190  convenience call for OpenGL JW 09/2003 */
192  return GetV().GetNormalized() * (double)-1;
193  };
194 
195  /** @brief checks whether X is in optical A-dir from C
196  (only for metric cameras)
197  @author koeser 01/05 */
198  inline bool IsInFrontOfCamera(const Vector3<double>& X) {
199  return ((X-GetC()).ScalarProduct(GetA())>0.0);
200  }
201 
202 
203  /** @brief returns the unit vector A which is the normal vector to the
204  image plane in world coordinates.
205 
206  or in other words: the camera orientation <br>
207  A,H,V are orthonormal*/
208  int GetA(Vector3<double>& A);
209 
210  /** @brief returns the unit vector A which is the normal vector to the
211  image plane in world coordinates.
212 
213  or in other words: the camera orientation <br>
214  A,H,V are orthonormal*/
215  BIAS::Vector3<double> GetA();
216 
217  /// Returns SVD of this.
218  void GetSVD(Matrix<double>& U, Vector<double>& S,
219  Matrix<double>& VT);
220 
221  /** @brief returns 4x3 pseudo inverse */
222  int GetPseudoInverse(BIAS::Matrix<double>& Pinv);
223 
224 
225  int GetHinf(BIAS::Matrix3x3<double> &Hinf);
226 
227  /** returns image plane in world coordinates */
228  void GetImagePlane(HomgPlane3D& plane);
229 
230  /** calls the above */
231  HomgPlane3D GetImagePlane();
232 
233  /** modify C and re-compose P
234  not fine to use, better use: Compose() */
235  void SetC(const Vector3<double>& newC);
236 
237  /** to re-Decompose_() after filling with data use this.
238  @author Jan-Friso Evers-Senne */
239  inline void InvalidateDecomposition();
240 
241  /** composes this from K, R and C
242  using P = [ K R' | -K R' C ]
243  with R' = transpose(R)
244  @author Felix Woelk */
245  void Compose(const Matrix3x3<double>& K, const Matrix3x3<double>& R,
246  const Vector3<double>& C);
247 
248  void Compose(const Matrix3x3<double>& K, const Matrix3x3<double>& R,
249  const HomgPoint3D& C);
250 
251  /** @author woelk 02/2006 */
252  void Compose(const Matrix3x3<double>& K,
253  const Vector<double>& parametrization,
254  enum E_ParametrizationType param_type);
255 
256  /** return line resulting of intersection of the two image planes
257  in pixel coordinates of this camera
258  return -1 if camera planes are parallel */
259  int
260  GetIntersectionOfImagePlanes(PMatrix& P, HomgLine2D& intersection);
261 
262  /** calls the above
263  returns line at infinity if planes are parallel */
264  inline HomgLine2D GetIntersectionOfImagePlanes(PMatrix& P);
265 
266  /** Returns a homogenized 3D point X on the viewray of x,
267  which always lies in front of the camera(this is checked).
268  @author Daniel Grest, last edit Jan 2003 */
269  HomgPoint3D BackprojectPseudoinverse (const HomgPoint2D& x);
270 
271  /** returns vector from C to point, w of point determines ray length
272  analytical inverse of K is used */
273  Vector3<double> GetRayWorldCoo(const HomgPoint2D& point);
274  /** returns a 3D point res which is located
275  depth away from center of projection in direction given by point */
276  void BackprojectWorldCoo(const HomgPoint2D& point, double depth,
277  HomgPoint3D& res);
278 
279  /** Inverts the PMatrix application to a 3D point whose z-component
280  * in <b>cameracoordinates</b> and its imagepoint (x,y) is known.
281  */
282  void BackprojectByZDepth(const double& x,
283  const double& y,
284  const double& z_depth,
285  HomgPoint3D& res);
286 
287 
288  /** returns normed vector from C to point
289  analytical inverse of K is used */
290  Vector3<double> GetNormRayWorldCoo(const HomgPoint2D& point);
291 
292  /** write the CAHV decomposition of this P matrix
293  in CAHV 1,0 format to stream os
294  (see RK's/TNT CAHV1.0 fromat in SequenceReconstruction/
295  Sequenetracking/KochSI.C)
296  cols, rows is the size of the image this P matrix corresponds to.
297  image size is neccessary because of shift of the axis origin
298  cenetered/in left corner
299  This is the 'Cunningham' format (see diss. Reinhard Koch, p.14)
300  @author Jan Woetzel 11/2002
301  @argument cols number of pixels
302  @argument rows number of pixels */
303  int WriteCAHV_10(int cols, int rows, std::ostream &os=std::cout);
304 
305  /** assignment operator
306  @author Jan Woetzel
307  @status alpha (02/28/2002)**/
308  PMatrix& operator=(const PMatrix &mat);
309 
310  /** @return field of view angle in rad.
311  for max: angle in rad between upper left and lower right
312  opposing image corners.
313  for min: min. angle of (horiz. vert) angle.
314  Max. field of view (not horizontal or verttical fov.)
315  @param optmin true if the min angle should be used,
316  else the max angle(=quer)
317  @param dimX horiz. image dimension in pixel (=columns)
318  @param dimY vert. image dimension in pixel (=rows)
319  unfortunately not const because missing consts in decompose etc..
320  we assume rectangular pixels for min(x,y) selection.
321  @author JW 06/2003 */
322  float GetFieldOfView(const unsigned int dimX,
323  const unsigned int dimY,
324  const bool optmin=true);
325 
326  /* similar to the above, but
327  @return fov in Y-direction in rad
328  The angle (should be) measured as total vertical/horizontal, indepedant
329  of proj. center
330  TODO/FIXME/HACK! (currently assumes optical center is in image center
331  JW 09/2003 */
332  float GetFieldOfViewY(const unsigned int dimX, const unsigned int dimY,
333  const bool & compY=true);
334 
335  // interface for the above
336  float GetFieldOfViewX(const unsigned int dimX, const unsigned int dimY)
337  {return GetFieldOfViewY(dimX, dimY, false);}
338 
339  ///// convenience interface for the above
340  //float GetFieldOfViewX(const Vector2<unsigned int> & imgDim)
341  //{return GetFieldOfViewX(imgDim[0], imgDim[1]);}
342  //
343  ///// convenience interface for the above
344  //float GetFieldOfViewY(const Vector2<unsigned int> & imgDim)
345  //{return GetFieldOfViewY(imgDim[0], imgDim[1]);}
346 
347  /** overload Load because it has to invalidate decomposition! JW 09/2003 */
348  bool Load(const std::string & filename){
349  bool result = BIAS::PMatrixBase::Load(filename);
350  InvalidateDecomposition();
351  return result;
352  };
353 
354 
355  bool Save(const std::string & filename);
356 
357  /** decompose the P-matrix to [ A | a ] where A is a 3x3-matrix
358  and a is a 3-vector.
359  @author mdunda 01 2004 */
360  void DecomposeAa(BIAS::Matrix3x3<PMATRIX_TYPE> &A,
361  BIAS::Vector3<PMATRIX_TYPE> &a) const;
362 
363  /** Get the projective homography matrix so that P * H = [ I | 0 ]
364  @author mdunda 01 2004 */
365  Matrix4x4<PMATRIX_TYPE> GetCanonicalH() const;
366  void GetCanonicalH(Matrix4x4<PMATRIX_TYPE> &ProjH) const;
367 
368  /** @brief scale P such that optical axis (first three entries of last row)
369  has unit length
370  @author koeser 03/2004 */
371  inline void Normalize();
372 
373 
374  /** @brief Load calibration data file from BBC-Free-D system
375 
376  opens a free-d file and reads first (or only) piece of free-d data
377  @param AddCenterPointShiftX add this to the principle point (in meter)
378  @param AddCenterPointShiftY add this to the principle point (in meter)
379  @author evers, koeser */
380  int LoadBBC(const std::string &filename,
381  const double& AddCenterPointShiftX = 0.0,
382  const double& AddCenterPointShiftY = 0.0);
383 
384  /** @brief Load next piece of calibration data from an open BBC-Free-D file
385  @param AddCenterPointShiftX add this to the principle point (in meter)
386  @param AddCenterPointShiftY add this to the principle point (in meter)
387  @author evers, koeser */
388  int BBCIn(std::ifstream &ifs,
389  const double& AddCenterPointShiftX = 0.0,
390  const double& AddCenterPointShiftY = 0.0);
391 
392 #ifdef BIAS_HAVE_XML2
393  /** @brief specialization of XML block name function */
394  virtual int XMLGetClassName(std::string& TopLevelTag,
395  double& Version) const;
396 
397  /** @brief specialization of XML write function */
398  virtual int XMLOut(const xmlNodePtr Node, XMLIO& XMLObject) const;
399 
400  /** @brief specialization of XML read function */
401  virtual int XMLIn(const xmlNodePtr Node, XMLIO& XMLObject);
402 #endif
403 
404 
406  Covariance_ = cov; return 0;}
407 
409  cov = Covariance_ ; return 0;}
410 
411  /** @brief returns average squared projection Error */
412  double GetProjectionError(const std::vector<BIAS::HomgPoint2D>& points2D, const std::vector<BIAS::HomgPoint3D>& points3D);
413 
414  protected:
415  /** @brief Computes K,R,C, assuming a metric PMatrix P = K[R^T | -R^T * C]
416  with K[0][1]=0 (zero skew) and K[2][2]=1
417 
418  Does a LU-Decomposition of the first 3x3 part. Finally C is computed
419  from the last column of P
420  @attention this is NOT the cam.### 'standard' CAHV !
421  and pmatrix must be metric, i.e. there must not be a _projective_ skew
422  due to distorted 3d space coordinates:
423  .Projection equation: x = P * H^-1 * H * X
424  . = (P * H^-1) * (H * X)
425  . = P' * X'
426  If such a P' (with a projective distortion H) is estimated for some
427  reason, the lu factorization makes no sense and the Get-Functions will
428  return bad values, e.g. R is no rotation ...
429  To get the center in the H-distorted space in that case, you should
430  call PMatrix::GetNullVector instead.
431  If you get a k[0][1]==skew!=0.0 the decomposition failed.
432  (comments added by koeser)
433  @author woelk */
434  int Decompose_();
435 
436  void Compose_();
437 
438  //* @brief computes a new svd for pseudoinverse */
439  inline int MakeSVD_();
440 
441  /** @brief check if SVD is still valid */
442  inline void CheckSVD_();
443 
444  /** @brief check if Decomposition is still valid */
445  inline void CheckDecomposition_();
446 
447  /// camera center in wcs (extrinsic parameter)
449 
450  /// unit vector in wcs assigning the direction of
451  /// the optical axis
453 
454  /// unit vector in wcs assigning the direction
455  /// of the horizontal axis of the image plane
457 
458  /// unit vector in wcs assigning the direction
459  /// of the vertical axis of the image plane
461 
462  /// Hinfinity
464 
465  Matrix3x3<double> R_; ///< rotation matrix (intrinsic parameter)
466  KMatrix K_; ///< camera calibration matrix (intrinsic parameter)
467  SVD *Svd_; ///< (for decomposition, docu: JW 11/2002)
468 
469 #ifdef BIAS_DEBUG
470  /// backup of P at time of last decomposition to check whether
471  /// decomposition is still valid
474 
475 #endif
477 
478  /// tells us whether we have a chached decomposition with C,A,...
480 
481  /// tells us whether we have an arbitrary 3x4 matrix or
482  /// a P which is exactly a composition of P = K * R [ I | -C ]
483  /// this is called a metric pmatrix
484  bool IsMetric_;
485  }; // class PMatrix
486  // ====================================
487 
488 
489 
490 
491  inline HomgLine2D
493  {
494  HomgLine2D intersection(0.0, 0.0, 0.0);
495  GetIntersectionOfImagePlanes(P, intersection);
496  return intersection;
497  }
498 
500  if (Svd_!=NULL) delete Svd_;
501  Svd_ = NULL;
502 #ifdef BIAS_DEBUG
505 #endif
506  IsDecomposed_ = false;
507  IsMetric_ = false; }
508 
510 #ifdef BIAS_DEBUG
512  if (Svd_ != NULL) CheckSVD_();
513 #endif
514 
515  // make determinant of front 3x3 matrix > 0 by multiplying with -1 one if necessary
517  for(unsigned int i=0; i < 3; i++){
518  for(unsigned int j=0; j < 3; j++){
519  M[i][j] = (*this)[i][j];
520  }
521  }
522  bool changedSign = false;
523  if(M.GetDeterminant() < 0){
524  this->MultiplyIP(-1);
525  changedSign = true;
526  }
527 
528  // normalize last rot to unit length
529  const PMATRIX_TYPE* pLastRow = row_[2];
530  (*this) /= sqrt(pLastRow[0]*pLastRow[0] +
531  pLastRow[1]*pLastRow[1] + pLastRow[2]*pLastRow[2]);
532 
533  // multiplication with -1 touches rotation, therefore decomposition is invalid
534  if(changedSign)
535  IsDecomposed_ = false;
536 
537 #ifdef BIAS_DEBUG
538  if (IsDecomposed_) {
539 
540  PConsistencyBackup_ = (*this);
541  }
542  if (Svd_ != NULL) {
543  PConsistencyBackupSVD_ = (*this);
544  }
545 #endif
546  }
547 
548  inline int PMatrix::MakeSVD_(){
549  int retvalue = 0;
550  if (Svd_!=NULL) {
551 #ifdef BIAS_DEBUG
552  CheckSVD_();
553 #endif
554  } else {
555  Svd_ = new SVD;
556  retvalue = Svd_->compute(*this);
557 #ifdef BIAS_DEBUG
558  PConsistencyBackupSVD_ = (*this);
559 #endif
560  }
561  return retvalue;
562  }
563 
564  inline void PMatrix::CheckSVD_() {
565 #ifdef BIAS_DEBUG
566  // check if PMatrix is _REALLY_ still valid
567  if (memcmp((void*)PConsistencyBackupSVD_.GetData(),
568  (void*)GetData(),12*sizeof(double))) {
569  BIASERR("Tried to access cached decomp.(outdated) for changed PMatrix! "
570  <<"You have to invalidate after changing PMatrix! Aborting.");
571  BIASABORT;
572  }
573 #endif
574  }
575 
577 #ifdef BIAS_DEBUG
578  // check if PMatrix is _REALLY_ still valid
579  if (memcmp((void*)PConsistencyBackup_.GetData(),
580  (void*)GetData(),12*sizeof(double))) {
581  BIASERR("Tried to access cached(outdated) svd for changed PMatrix ! "
582  <<"You have to invalidate after changing PMatrix! Aborting.");
583  BIASABORT;
584  }
585 #endif
586  }
587 
588 
589 } // end namespace
590 
591 
592 #include <Base/Common/BIASpragmaEnd.hh>
593 
594 #endif
595 
Matrix3x4< double > PConsistencyBackup_
backup of P at time of last decomposition to check whether decomposition is still valid ...
Definition: PMatrix.hh:472
bool IsDecomposed_
tells us whether we have a chached decomposition with C,A,...
Definition: PMatrix.hh:479
KMatrix K_
camera calibration matrix (intrinsic parameter)
Definition: PMatrix.hh:466
MatrixInitType
can be passed to matrix constructors to init the matrix with the most often used values ...
Definition: Matrix.hh:59
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
computes and holds the singular value decomposition of a rectangular (not necessarily quadratic) Matr...
Definition: SVD.hh:92
PMatrix(const MatrixInitType &i)
Definition: PMatrix.hh:98
bool Load(const std::string &filename)
overload Load because it has to invalidate decomposition! JW 09/2003
Definition: PMatrix.hh:348
int MakeSVD_()
Definition: PMatrix.hh:548
void Fill(const T &scalar)
Takes the elements of a Vector and put them as diagonal elements into a matrix.
Definition: Matrix.cpp:82
void CheckSVD_()
check if SVD is still valid
Definition: PMatrix.hh:564
float GetFieldOfViewX(const unsigned int dimX, const unsigned int dimY)
Definition: PMatrix.hh:336
KMatrix GetK()
Definition: PMatrix.hh:168
Vector3< double > V0_
unit vector in wcs assigning the direction of the vertical axis of the image plane ...
Definition: PMatrix.hh:460
Matrix3x3< double > R_
rotation matrix (intrinsic parameter)
Definition: PMatrix.hh:465
Matrix< double > Covariance_
Definition: PMatrix.hh:476
BIAS::Vector3< T > GetNormalized() const
return a normalized vector of this
Definition: Vector3.cpp:47
PMatrix(const PMatrixBase &Amat_)
Definition: PMatrix.hh:112
SVD * Svd_
(for decomposition, docu: JW 11/2002)
Definition: PMatrix.hh:467
Matrix3x3< double > GetR()
Definition: PMatrix.hh:161
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
Definition: XMLIO.hh:72
bool Load(const std::string &filename)
method to load directly from a given filename.
void InvalidateDecomposition()
to re-Decompose_() after filling with data use this.
Definition: PMatrix.hh:499
T ** row_
Definition: cmat.h:88
a line l = (a b c)^T is a form of the implicit straight line equation 0 = a*x + b*y + c if homogenize...
Definition: HomgLine2D.hh:48
BIAS::Vector3< double > GetUp_gl()
Definition: PMatrix.hh:191
T * GetData()
get the pointer to the data array of the matrix (for faster direct memeory access) ...
Definition: Matrix.hh:185
class BIASGeometry_EXPORT PMatrix
is a &#39;fixed size&#39; quadratic matrix of dim.
Definition: Matrix.hh:54
Base class with interface for xml output.
Definition: XMLBase.hh:56
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrixBase.hh:74
int GetIntersectionOfImagePlanes(PMatrix &P, HomgLine2D &intersection)
return line resulting of intersection of the two image planes in pixel coordinates of this camera ret...
Definition: PMatrix.cpp:539
class Vector3 contains a Vector of fixed dim.
Definition: Matrix.hh:53
bool IsMetric()
Definition: PMatrix.hh:134
void MultiplyIP(const PMATRIX_TYPE &scalar)
in place multiplication function
Definition: Matrix.hh:448
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
T GetDeterminant() const
returns the Determinant |A| of this
Definition: Matrix3x3.cpp:347
Vector3< double > C_
camera center in wcs (extrinsic parameter)
Definition: PMatrix.hh:448
bool IsInFrontOfCamera(const Vector3< double > &X)
checks whether X is in optical A-dir from C (only for metric cameras)
Definition: PMatrix.hh:198
Matrix3x4< double > PConsistencyBackupSVD_
Definition: PMatrix.hh:473
Vector3< double > A_
unit vector in wcs assigning the direction of the optical axis
Definition: PMatrix.hh:452
bool IsMetric_
tells us whether we have an arbitrary 3x4 matrix or a P which is exactly a composition of P = K * R [...
Definition: PMatrix.hh:484
int SetCovariance(const BIAS::Matrix< double > &cov)
Definition: PMatrix.hh:405
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
PMatrix(const Matrix3x3< PMATRIX_TYPE > &K, const Matrix3x3< PMATRIX_TYPE > &R, const Vector3< PMATRIX_TYPE > &C)
Take R, K, C and compose PMatrix.
Definition: PMatrix.hh:125
int GetCovariance(BIAS::Matrix< double > &cov)
Definition: PMatrix.hh:408
void CheckDecomposition_()
check if Decomposition is still valid
Definition: PMatrix.hh:576
PMatrix(const PMatrix &A)
Definition: PMatrix.hh:107
Vector3< double > H0_
unit vector in wcs assigning the direction of the horizontal axis of the image plane ...
Definition: PMatrix.hh:456
int compute(const Matrix< double > &M, double ZeroThreshold=DEFAULT_DOUBLE_ZERO_THRESHOLD)
use our naming convention
Definition: SVD.hh:132
void Normalize()
scale P such that optical axis (first three entries of last row) has unit length
Definition: PMatrix.hh:509
Matrix3x3< double > Hinf_
Hinfinity.
Definition: PMatrix.hh:463
A homogeneous plane (in P^3) All points X on the plane p fulfill p &#39; * X = 0.
Definition: HomgPlane3D.hh:46