Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProjectionParametersDynamicLoad.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_ProjectionParametersDynamicLoad_hh__
27 #define __BIAS_ProjectionParametersDynamicLoad_hh__
28 #include "bias_config.h"
29 
30 #include <Base/Common/BIASpragmaStart.hh>
31 #include <Geometry/ProjectionParametersBase.hh>
32 
33 #ifndef WIN32
34 
35 namespace BIAS {
36 
37 // typedef to make it easier to set up our factory
38 typedef ProjectionParametersBase* (*maker_t)();
39 
40 
41  /** @class ProjectionParametersDynamicLoad
42  * @ingroup g_geometry
43  * @brief can load exernally programmed child classes of ProjectionParametersBase
44  * @author sedlazeck */
45  class BIASGeometry_EXPORT ProjectionParametersDynamicLoad
46  : public ProjectionParametersBase {
47  public:
48 
49  ProjectionParametersDynamicLoad(const unsigned int width = 0,
50  const unsigned int height = 0)
51  : ProjectionParametersBase(width, height)
52  {
53  hndl_ = NULL;
54  dynptr_ = NULL;
55  className_ = "";
56  //InitFactory_(); // needs to be called after setting string specifiying, which projection should be loaded
57  }
58 
59  ProjectionParametersDynamicLoad(const std::string& className, const unsigned int width = 0,
60  const unsigned int height = 0)
61  : ProjectionParametersBase(width, height)
62  {
63  hndl_ = NULL;
64  dynptr_ = NULL;
65  className_ = className;
66  InitFactory_();
67  }
68 
69 
71  *this = P;
72  }
73 
77  if(P.dynptr_!=NULL){
78  dynptr_ = P.dynptr_->Clone();
79  } else {
80  dynptr_ = P.dynptr_;
81  }
82  hndl_ = P.hndl_;
83  className_ = P.className_;
84  return *this;
85  }
86 
87 
89 
90  /** @brief call this to start a run at the outer boundary of an image.
91  *
92  * You get the first boundary position in it, e.g. (0,0) for a perspective
93  * image. Feed this into GetNextBorderPixel to get the next position.
94  * @author koeser 09/2007 */
95  virtual void GetFirstBorderPixel(PixelIterator& it);
96 
97  /** @brief call this iteratively to run at the outer boundary of an image.
98  *
99  * All returned coordinates must have valid local rays in the camera
100  * coordinate system (e.g. in fisheye cams, we run at the fov circle) and
101  * must be in the image. Two subsequent coordinates must not be more
102  * distant than 1 pixel.
103  * @param it must be initialized by GetFirstBorderPixel
104  * @return false if the returned position closes the loop around the image
105  * @author koeser 09/2007 */
106  virtual bool GetNextBorderPixel(PixelIterator& it);
107 
108  /** @brief call this to start a run at the outer boundary of an image.
109  *
110  * You get the first edge position i.e. (-0.5, -0.5) for a perspective
111  * image. Feed this into GetNextBorderPixel to get the next position.
112  * @author bartczak 06/2009 */
113  virtual void GetFirstEdgePosition(PixelIterator& it);
114 
115  /** @brief call this iteratively to run at the outer edge of an image.
116  *
117  * Like the GetNextBorderPixel() method, however runs along the
118  * outer rim of an image, i.e. the coordinate range (-0.5, -0.5) and (W-0.5, H-0.5).
119  * The positions returned are the upper left corner of the pixels.
120  * These are at the same time the upper right corners of the neighboring pixel.
121  *
122  * @param it must be initialized by GetFirstBorderPixel
123  * @return false if the returned position closes the loop around the image
124  * @author bartczak 06/2009 */
125 
126  virtual bool GetNextEdgePosition(PixelIterator& it);
127 
128  /** Determines the maximal and minimal viewing range in means of
129  * spherical coordinates. The spherical coordinates are calculated
130  * relatively to the passed coordinate frame.
131  * The method is using the class SphericalCoordinates, see also the
132  * documentation there in order to understand the meaning of the
133  * sphericalReferenceFrame.
134  *
135  * \attention in order to make sense the sphericalReferenceFrame
136  * must have the same origin as the ProjectionParameters.
137  *
138  * \param sphericalReferenceFrame reference frame for the calculation of
139  * spherical coordinates belonging to optical rays, must be defined in the
140  * same coordinate frame like the local frame of the ProjectionParameters.
141  *
142  * \returns minPhi phi angle from (-M_PI, M_PI] with smallest value
143  * within viewing range.
144  * \returns maxPhi phi angle from (-M_PI, M_PI] with largest value
145  * within viewing range.
146  * \returns centerPhi phi angle from (-M_PI, M_PI] belonging to the
147  * optical ray passing through the image center. This angle
148  * allows to determine which direction the camera was facing
149  * in the sphericalReferenceFrame.
150  * \returns minTheta theta angle from [0, M_PI] with smallest value
151  * within viewing range.
152  * \returns maxTheta theta angle from [0, M_PI] with largest value
153  * within viewing range.
154  *
155  * \author bartczak 10/2007
156  **/
157  virtual int
158  GetSphericalViewingRange(const CoordinateTransform3D& sphericalReferenceFrame,
159  double& minPhi, double& maxPhi, double& centerPhi,
160  double& minTheta, double& maxTheta);
161 
162  /** Delivers the assumed minimal angular distance between two optical rays
163  * belonging to integer image coordinates within the FoV.
164  * \author bartczak 10/2007
165  **/
166  virtual int GetMinimalAngularSamplingStep(double& minAngleStep)
167  {
168  return dynptr_->GetMinimalAngularSamplingStep(minAngleStep);
169  }
170 
171  virtual const bool
173  return dynptr_->DoExtrinsicsDiffer(p);
174  }
175 
176  virtual const bool
177  DoIntrinsicsDiffer(const ProjectionParametersBase* p) const;
178 
179 
180  /** Checks if 3D point projects into specified image and returns
181  * belonging 2D image point.
182  * @param X assumes homogenized point!
183  * @author bartczak
184  */
185  virtual bool
187  bool IgnoreDistortion = false) const{
188  return dynptr_->DoesPointProjectIntoImage(X, x, IgnoreDistortion);
189  }
190 
191  /** Checks if 3D point projects into specified image and returns
192  * belonging 2D image point.
193  * @param localX assumes homogenized point!
194  * @author bartczak
195  */
196  virtual bool
197  DoesPointProjectIntoImageLocal(const Vector3<double>& localX,
198  HomgPoint2D& x,
199  bool IgnoreDistortion = false) const;
200 
201 
202  /** @brief calculates the projection of a point in the world coordinate
203  system to a pixel in the image plane of the camera
204  !warning! the function my return an invalid point (0,0,0) in certain
205  cases (3d point) behind camera or 3d point to close to camera center
206  @author woelk 05/2006 */
207  virtual inline HomgPoint2D Project(const HomgPoint3D &X,
208  bool IgnoreDistortion = false) const {
209  return dynptr_->Project(X, IgnoreDistortion);
210  }
211 
212  /** @brief calculates the projection of a point in the world coordinate
213  system to a pixel in the image plane of the camera. The
214  only case when this function may not compute the 2d point is when the
215  camera center and the 3d point coincide. This case must be indicated
216  by a negative return value. In all other cases, a valid 2d point is
217  computed, *particularily* when the 3d point is behind the camera
218  or when the resulting 2d point is at infinity.
219  returns negative, when 3d point and camera center coincide
220  @author woelk 05/2006 */
221  virtual inline int Project(const HomgPoint3D &X, HomgPoint2D &p2d,
222  bool IgnoreDistortion = false) const {
223 
224  return dynptr_->Project(X, p2d, IgnoreDistortion);
225  }
226 
227  /** @brief calculates the projection of a point in the local camera
228  coordinate system to a pixel in the image plane of the camera
229 
230  !warning! function return an invalid 2d point (0,0,0) in certain cases
231 
232  In the simplest case perspective pinhole projection x = K * point
233  where point is transformed of X using point = (R^T | -R^T C) X */
234  virtual HomgPoint2D
235  ProjectLocal(const Vector3<double>& point,
236  bool IgnoreDistortion = false) const;
237 
238  /** @brief calculates the projection of a point in the local camera
239  coordinate system to a pixel in the image plane of the camera. The
240  only case when this function may not compute the 2d point is when the
241  camera center and the 3d point coincide. This case must be indicated
242  by a negative return value. In all other cases, a 2d point must be
243  computed, *particularily* when the 3d point is behind the camera
244  or when the resulting 2d point is at infinity.
245 
246  In the simplest case perspective pinhole projection x = K * point
247  where point is transformed of X using point = (R^T | -R^T C) X
248  @author woelk 08/2008 (c) www.vision-n.de */
249  virtual int
250  ProjectLocal(const Vector3<double>& point, HomgPoint2D &p2d,
251  bool IgnoreDistortion = false) const;
252 
253  /** @brief calculates the unit size viewing ray from the camera center
254  (in the camera coordinate system) which belongs to the image position
255  pos e.g. pos=principal point results in (0,0,1)=optical axis */
256  virtual void
257  UnProjectLocal(const HomgPoint2D& pos, Vector3<double>& pointOnRay,
258  Vector3<double>& direction, bool IgnoreDistortion = false) const;
259 
260  /** @brief map points from image onto unit diameter image plane in 3D.
261  */
262  virtual HomgPoint3D
263  UnProjectToImagePlane(const HomgPoint2D& pos,
264  const double& depth = 1.0,
265  bool IgnoreDistortion = false) const;
266 
267  /** @brief unprojects the covariance matrices to K=Identity camera
268 
269  This uses the unscented transform to propagate covariance. Use a faster
270  or better specialization in derived class if you want.
271  @author koeser 06/2006 */
272  virtual Matrix3x3<double>
273  UnProjectCovLocal(const HomgPoint2D& pos, const Matrix3x3<double>& cov2D,
274  bool IgnoreDistortion = false, bool Normalize = false);
275 
276  /** @brief calculates the viewing ray in the global coordinate frame
277  from the camera center which belongs to the given image
278  position. The resulting vector3 may have any length.
279 
280  @author woelk 05/2006 */
281  virtual inline void UnProjectToRay(
282  const HomgPoint2D& pos, Vector3<double>& pointOnRay,
283  Vector3<double>& direction, bool IgnoreDistortion=false) const
284  {
285  dynptr_->UnProjectToRay(pos, pointOnRay, direction, IgnoreDistortion);
286  }
287 
288  virtual inline void UnProjectToRay(
289  const HomgPoint2D& pos, Vector3<double>& pointOnRay,
290  Vector3<double>& direction, const ProjectionParametersBase &proj,
291  bool IgnoreDistortion=false) const
292  {
293  dynptr_->UnProjectToRay(pos, pointOnRay, direction, proj, IgnoreDistortion);
294  }
295 
296  /** @brief calculates a 3D point in
297  the global (not the rig) coordinate system, which
298  belongs to the image position pos with distance depth to the
299  camera center.
300  @return: (0,0,0,0) is returned on failure */
301  virtual HomgPoint3D UnProjectToPoint(const HomgPoint2D& pos, double depth,
302  bool IgnoreDistortion = false) const{
303  return dynptr_->UnProjectToPoint(pos, depth, IgnoreDistortion);
304  }
305 
306  virtual HomgPoint3D UnProjectToPoint(const HomgPoint2D& pos, const double depth,
307  const ProjectionParametersBase &proj,
308  bool IgnoreDistortion = false) const{
309 
310  return dynptr_->UnProjectToPoint(pos, depth, proj, IgnoreDistortion);
311  }
312 
313  /** @brief calculates a 3D point in
314  the local camera coordinate system, which
315  belongs to the image position pos in cam with distance depth to the
316  camera center cam.
317  @author koeser */
318  virtual Vector3<double>
319  UnProjectToPointLocal(const HomgPoint2D& pos, const double& depth,
320  bool IgnoreDistortion = false) const{
321 
322  return dynptr_->UnProjectToPointLocal(pos, depth, IgnoreDistortion);
323  }
324 
325  /** Interface defintion for lens distortion function, implemented by
326  derived classes */
327  virtual bool Distort(BIAS::HomgPoint2D& point2d) const;
328 
329  /** Interface defintion for lens undistortion function, implemented by
330  derived classes */
331  virtual bool Undistort(BIAS::HomgPoint2D& point2d) const;
332 
333 
334  /** @brief Get warp (local magnification/shear/...) when going from the
335  * real image to ideal image with focal length = 1.
336  *
337  * When an image is undistorted to an ideal perspective camera with
338  * K=id, the region around each pixel must be warped. For perspective
339  * cameras without radial distortion this is the undoing (inverse) of
340  * the upper 2x2 part of the KMatrix (simply a rescale of coordinates).
341  * If radial distortion is present, the local warp depends on the image
342  * position. Same for most other camera models. This matrix is closely
343  * related to the absolute local image resolution.
344  *
345  * Instead of going to the w=1 (homogenized) ideal image, we can as well
346  * go to a tangent image. This can be steered by the parameter
347  * homogenized (if false, we use normalized mode).
348  *
349  * @author koeser 06/2008
350  */
351  virtual int GetUnProjectionJacobian(const HomgPoint2D& x,
352  Matrix2x2<double>& Jac,
353  const bool homogenized = true) const{
354  return dynptr_->GetUnProjectionJacobian(x, Jac, homogenized);
355  }
356 
357  // ---- Getter methods -------------------------------------------
358 
359  /** @brief Get projection center. */
360  virtual BIAS::Vector3<double> GetC() const
361  {
362  return dynptr_->GetC();
363  }
364 
365  /** @brief Get orientation as unit quaternion. */
367  {
368  return dynptr_->GetQ();
369  }
370 
371  /** @brief Return pose as 7 vector (first projection center C, then
372  unit quaternion Q representing orientation). */
373  virtual BIAS::Vector<double> GetCQ() const
374  {
375  return dynptr_->GetCQ();
376  }
377 
378  /** @brief Get orientation as rotation matrix R. */
379  virtual BIAS::RMatrix GetR() const{
380  return dynptr_->GetR();
381  }
382 
383  /** @brief Return pose covariance as 7x7 matrix with respect to C, Q. */
384  virtual BIAS::Matrix<POSE_TYPE> GetCov() const {
385  return dynptr_->GetCov();
386  }
387 
388  /** @brief Return complete pose object. */
389  virtual const BIAS::Pose& GetPose() const
390  {
391  return dynptr_->GetPose();
392  }
393 
394  /** @brief Return copy of pose parametrization object. */
396  {
397  return dynptr_->GetPoseParametrization();
398  }
399 
400  /** @brief Set pose from pose parametrization. */
401  virtual inline void SetPoseParametrization(const BIAS::PoseParametrization& pp)
402  { dynptr_->SetPoseParametrization(pp); }
403 
404  /** @brief Return cached 3x4 representation of external matrix [R|C] */
406  {
407  return dynptr_->GetExternals();
408  }
409 
410  /** @brief Obtain image dimensions. */
411  virtual inline int GetImageSize(unsigned int& Width, unsigned int& Height) const {
412  return dynptr_->GetImageSize(Width, Height);
413  }
414 
415  /**
416  * @brief Returns the image width.
417  *
418  * @return the image width
419  */
420  virtual inline
421  const unsigned int& GetImageWidth() const
422  {
423  return dynptr_->GetImageWidth();
424  }
425 
426  /**
427  * @brief Returns the image height.
428  *
429  * @return the image height
430  */
431  virtual inline
432  const unsigned int& GetImageHeight() const
433  {
434  return dynptr_->GetImageHeight();
435  }
436 
437  virtual inline std::string GetIdentifier() const {
438  return dynptr_->GetIdentifier();
439  }
440 
441  virtual inline std::string GetVideoSourceType() const {
442  return dynptr_->GetVideoSourceType();
443  }
444 
445  /** @brief Return aspectratio (i.e. cellsizeX / cellsizeY). */
446  virtual inline double GetAspectratio() const {
447  return dynptr_->GetAspectratio();
448  }
449 
450  /** @brief Get principal point (in pixels relative to top left corner). */
451  virtual inline int GetPrincipal(double& PrincipalX, double& PrincipalY) const {
452  return dynptr_->GetPrincipal(PrincipalX, PrincipalY);
453  }
454 
455  // ---- Setter methods ------------------------------------------------
456 
457  /** @brief Set CCD aspect ratio (i.e. cellsizeX / cellsizeY).
458  @author streckel */
459  virtual inline void SetAspectratio(const double AspectRatio) {
460  dynptr_->SetAspectratio(AspectRatio);
461  }
462 
463  /** @brief Set principal point (in pixels relative to top left corner).
464  @author streckel */
465  virtual inline void SetPrincipal(const double x, const double y) {
466  dynptr_->SetPrincipal(x, y);
467  }
468 
469  /** @brief Set image dimensions (in pixels). */
470  virtual inline void SetImageSize(const unsigned int w,
471  const unsigned int h) {
472  dynptr_->SetImageSize(w, h);
473  }
474 
475  /** @brief Set the identification string */
476  virtual inline void SetIdentifier(std::string name ){
477  dynptr_->SetIdentifier(name);
478  }
479 
480  /** @brief Set the camera source type */
481  virtual void SetVideoSourceType(const std::string &name){
482  dynptr_->SetVideoSourceType(name);
483  }
484 
485  /** @brief Adapt internal parameters to resampled image
486  @param ratio 2.0 = downsample by 2, 0.5 = upsample by 2.
487  @param offset Offset for principal point (applied before down/upsampling!)
488  \attention Delivers only correct results if ratio is chosen
489  to rescale image size to integral image dimensions
490  in both directions. Image size is rounded!
491  */
492  virtual void Rescale(double ratio, const double offset = 0.0){
493  dynptr_->Rescale(ratio, offset);
494  }
495 
496  /**
497  * @brief adapt internal parameters to new image size
498  * @param width and height are the new images sizes
499  * \attention Delivers only correct results if ratio is chosen
500  * to rescale image size to integral image dimensions in both directions.
501  */
502  virtual void Rescale(unsigned int width, unsigned int height){
503  dynptr_->Rescale(width, height);
504  }
505 
506  /** @brief Covariant virtual copy constructor used in #BIAS::Projection. */
507  virtual ProjectionParametersBase* Clone() const {
508  return new ProjectionParametersDynamicLoad(*this);
509  }
510 
511  /** @brief Set orientation from unit quaternion Q. */
512  virtual void SetQ(const BIAS::Quaternion<double>& Q)
513  { dynptr_->SetQ(Q); }
514 
515  /** @brief Set projection center. */
516  virtual void SetC(const BIAS::Vector3<double>& C)
517  { dynptr_->SetC(C); }
518 
519  /** @brief Set pose from unit quaternion Q and projection center C. */
520  virtual void SetQC(const BIAS::Quaternion<double>& Q,
521  const BIAS::Vector3<double>& C)
522  { dynptr_->SetQC(Q, C); }
523 
524  /** @brief Set pose from pose object. */
525  virtual void SetPose(const BIAS::Pose pose)
526  { dynptr_->SetPose(pose); }
527 
528  /** @brief Set orientation from rotation matrix R. */
529  virtual void SetR(const BIAS::RMatrix& R) {
530  dynptr_->SetR(R);
531  }
532 
533  /** @brief Set pose covariance matrix with respect to C, Q. */
534  virtual void SetCov(const Matrix<POSE_TYPE>& Cov)
535  { dynptr_->SetCov(Cov); }
536 
537  /** @brief Check of current projection center is valid. */
538  virtual inline bool CValid() const { return dynptr_->CValid(); }
539 
540  /** @brief Check if current orientation is valid. */
541  virtual inline bool QValid() const { return dynptr_->QValid(); }
542 
543  /** @brief Check if current pose is valid. */
544  virtual inline bool PoseValid() const
545  { return dynptr_->PoseValid(); }
546 
547  /** @brief Invalidate currently set pose. */
548  virtual inline void InvalidatePose()
549  { dynptr_->InvalidatePose(); }
550 
551  /** @brief Validate currently set pose. */
552  virtual void ValidatePose() {
553  dynptr_->ValidatePose();
554  }
555 
556  /** @brief Returns a fake KMatrix for the camera.
557 
558  @attention Stolen from PPSpherical, since this is a general issue.
559  THERE MAY BE PROBLEMS FOR OTHER THAN FISHEYE CAMERAS (UNTESTED)
560  If this implementation is not correct for your derived projection
561  parameters you have to reimplement it in the derived class.
562 
563  The FoV of the KMatrix is specified by maxangle (PI*80/180 for 160deg)
564  or the max angle, if this is <160deg.
565  @param resolution The resolution parameter influences the
566  Resolution of the perspective image that is represented by the camera.
567  0 - The perspective image has the same size as the this image
568  1 - The perspective image has the same resolution as this
569  image in the center (highest resolution)
570  2 - The perspective image has the same resolution as this
571  image near the border (lowest resolution)
572  @param imgsize returns the image size
573  @param maxangle maximum theta in rad, e.g. (PI*80/180 for 160deg fov)
574  @author streckel 05/2006 (moved here by koeser)
575  */
576  virtual BIAS::KMatrix GetFakeKMatrix(double& imgsize, int resolution = 0,
577  const double& maxangle = 1.4) const{
578  return dynptr_->GetFakeKMatrix(imgsize, resolution, maxangle);
579  }
580  virtual BIAS::KMatrix GetFakeKMatrix(int resolution = 0,
581  const double& maxangle = 1.4) const{
582  return dynptr_->GetFakeKMatrix(resolution, maxangle);
583 
584  }
585 
586  /** @brief Returns difference between two projections like |C1-C2|.
587  This function can be used to calculate inter-camera distance e.g.
588  for ordering purposes.
589  @author koeser 03/2006
590  */
591  virtual double ViewDifference(const ProjectionParametersBase *pPPB) const{
592  return dynptr_->ViewDifference(pPPB);
593  }
594 
595 #ifdef BIAS_HAVE_XML2
596  /** @brief specialization of XML block name function */
597  virtual int XMLGetClassName(std::string& TopLevelTag,
598  double& Version) const;
599 
600  /** @brief specialization of XML write function */
601  virtual int XMLOut(const xmlNodePtr Node, XMLIO& XMLObject) const;
602 
603  /** @brief specialization of XML read function */
604  virtual int XMLIn(const xmlNodePtr Node, XMLIO& XMLObject);
605 #endif
606 
607 
608  /** Worker function for Unscented Transform.
609  @author koeser
610  */
611  virtual int Transform_(const Vector<double>& src,
612  Vector<double>& dst) const{
613  return dynptr_->Transform_(src, dst);
614  }
615 
616 
617 
618 
619  friend std::ostream&
620  operator<<(std::ostream &os, const ProjectionParametersDynamicLoad& p);
621 
622  /// get base pointer to dynamically loaded object in order to handle it directly
624 
625  void SetClassName(std::string& name){
626  className_ = name;
627  }
628 
629  protected:
630  void InitFactory_();
631 
632  void *hndl_;
633  std::map<std::string, maker_t, std::less<std::string> > factory_;
635  std::string className_;
636  std::vector<std::string> libPaths_;
637  };
638 
639 
640 
641  //////////// inline code //////////////////
642  inline std::ostream& operator<<(std::ostream &os,
644  {
645  os << "ProjectionParametersDynamicLoad:" << std::endl;
646  os << *(p.dynptr_) << std::endl;
647  return os;
648  }
649 
650 
651 } // end namespace
652 
653 
654 #include <Base/Common/BIASpragmaEnd.hh>
655 
656 #endif //WIN32
657 
658 #endif
659 
virtual void SetR(const BIAS::RMatrix &R)
Set orientation from rotation matrix R.
can load exernally programmed child classes of ProjectionParametersBase
virtual bool QValid() const
Check if current orientation is valid.
virtual void SetQC(const BIAS::Quaternion< double > &Q, const BIAS::Vector3< double > &C)
Set pose from unit quaternion Q and projection center C.
virtual const unsigned int & GetImageHeight() const
Returns the image height.
virtual bool PoseValid() const
Check if current pose is valid.
virtual HomgPoint3D UnProjectToPoint(const HomgPoint2D &pos, double depth, bool IgnoreDistortion=false) const
calculates a 3D point in the global (not the rig) coordinate system, which belongs to the image posit...
virtual void SetPose(const BIAS::Pose pose)
Set pose from pose object.
virtual Vector3< double > UnProjectToPointLocal(const HomgPoint2D &pos, const double &depth, bool IgnoreDistortion=false) const
calculates a 3D point in the local camera coordinate system, which belongs to the image position pos ...
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
virtual BIAS::RMatrix GetR() const
Get orientation as rotation matrix R.
virtual BIAS::KMatrix GetFakeKMatrix(double &imgsize, int resolution=0, const double &maxangle=1.4) const
Returns a fake KMatrix for the camera.
ProjectionParametersDynamicLoad(const std::string &className, const unsigned int width=0, const unsigned int height=0)
virtual bool CValid() const
Check of current projection center is valid.
virtual void SetAspectratio(const double AspectRatio)
Set CCD aspect ratio (i.e.
virtual ProjectionParametersBase * Clone() const =0
Covariant virtual copy constructor used in BIAS::Projection.
virtual void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &pointOnRay, Vector3< double > &direction, bool IgnoreDistortion=false) const
calculates the viewing ray in the global coordinate frame from the camera center which belongs to the...
virtual BIAS::Quaternion< double > GetQ() const
Get orientation as unit quaternion.
virtual int Transform_(const Vector< double > &src, Vector< double > &dst) const
Worker function for Unscented Transform.
virtual BIAS::Vector< double > GetCQ() const
Return pose as 7 vector (first projection center C, then unit quaternion Q representing orientation)...
Slim class bundeling pose parametrization and associated covariance matrix.
virtual BIAS::Matrix3x4< double > GetExternals() const
Return cached 3x4 representation of external matrix [R|C].
virtual void SetPoseParametrization(const BIAS::PoseParametrization &pp)
Set pose from pose parametrization.
ProjectionParametersDynamicLoad & operator=(const ProjectionParametersDynamicLoad &P)
virtual ProjectionParametersBase * Clone() const
Covariant virtual copy constructor used in BIAS::Projection.
virtual int Project(const HomgPoint3D &X, HomgPoint2D &p2d, bool IgnoreDistortion=false) const
calculates the projection of a point in the world coordinate system to a pixel in the image plane of ...
virtual HomgPoint3D UnProjectToPoint(const HomgPoint2D &pos, const double depth, const ProjectionParametersBase &proj, bool IgnoreDistortion=false) const
3D rotation matrix
Definition: RMatrix.hh:49
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
Definition: XMLIO.hh:72
virtual BIAS::Matrix< POSE_TYPE > GetCov() const
Return pose covariance as 7x7 matrix with respect to C, Q.
virtual bool DoesPointProjectIntoImage(const HomgPoint3D &X, HomgPoint2D &x, bool IgnoreDistortion=false) const
Checks if 3D point projects into specified image and returns belonging 2D image point.
virtual void SetQ(const BIAS::Quaternion< double > &Q)
Set orientation from unit quaternion Q.
virtual int GetUnProjectionJacobian(const HomgPoint2D &x, Matrix2x2< double > &Jac, const bool homogenized=true) const
Get warp (local magnification/shear/...) when going from the real image to ideal image with focal len...
virtual void Rescale(unsigned int width, unsigned int height)
adapt internal parameters to new image size
virtual double GetAspectratio() const
Return aspectratio (i.e.
virtual void ValidatePose()
Validate currently set pose.
virtual void SetPrincipal(const double x, const double y)
Set principal point (in pixels relative to top left corner).
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
virtual void Rescale(double ratio, const double offset=0.0)
Adapt internal parameters to resampled image.
virtual const bool DoExtrinsicsDiffer(const ProjectionParametersBase *p) const
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
Definition: Array2D.hh:260
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
Can be used to run along the image border.
virtual void SetVideoSourceType(const std::string &name)
Set the camera source type.
virtual HomgPoint2D Project(const HomgPoint3D &X, bool IgnoreDistortion=false) const
calculates the projection of a point in the world coordinate system to a pixel in the image plane of ...
virtual const unsigned int & GetImageWidth() const
Returns the image width.
virtual void SetCov(const Matrix< POSE_TYPE > &Cov)
Set pose covariance matrix with respect to C, Q.
virtual BIAS::KMatrix GetFakeKMatrix(int resolution=0, const double &maxangle=1.4) const
virtual int GetPrincipal(double &PrincipalX, double &PrincipalY) const
Get principal point (in pixels relative to top left corner).
virtual BIAS::Vector3< double > GetC() const
Get projection center.
virtual void SetIdentifier(std::string name)
Set the identification string.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
Transforms 3d points between two different coodinate systems, e.g.
std::map< std::string, maker_t, std::less< std::string > > factory_
virtual const BIAS::Pose & GetPose() const
Return complete pose object.
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
ProjectionParametersDynamicLoad(const ProjectionParametersDynamicLoad &P)
virtual double ViewDifference(const ProjectionParametersBase *pPPB) const
Returns difference between two projections like |C1-C2|.
ProjectionParametersDynamicLoad(const unsigned int width=0, const unsigned int height=0)
virtual BIAS::PoseParametrization GetPoseParametrization() const
Return copy of pose parametrization object.
virtual void InvalidatePose()
Invalidate currently set pose.
virtual int GetMinimalAngularSamplingStep(double &minAngleStep)
Delivers the assumed minimal angular distance between two optical rays belonging to integer image coo...
virtual ProjectionParametersBase & operator=(const ProjectionParametersBase &p)
ProjectionParametersBase * GetDynPtr()
get base pointer to dynamically loaded object in order to handle it directly
virtual void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &pointOnRay, Vector3< double > &direction, const ProjectionParametersBase &proj, bool IgnoreDistortion=false) const
Calculates the view ray, which belongs to the given position on the image plane, using the given proj...