21 #ifndef __BIAS_ProjectionParametersBase_hh__
22 #define __BIAS_ProjectionParametersBase_hh__
24 #include <bias_config.h>
28 #include <Geometry/Pose.hh>
30 #include <Base/Common/BIASpragmaStart.hh>
32 #include <Base/Common/CompareFloatingPoint.hh>
33 #include <Base/Math/Vector3.hh>
34 #include <Base/Math/Matrix3x4.hh>
35 #include <Base/Math/Matrix4x4.hh>
36 #include <Base/Geometry/HomgPoint2D.hh>
37 #include <Base/Geometry/Quaternion.hh>
38 #include <Base/Debug/Exception.hh>
39 #include <Geometry/PMatrix.hh>
40 #include <MathAlgo/UnscentedTransform.hh>
42 #include <Base/Debug/Debug.hh>
44 # include <Base/Common/XMLBase.hh>
47 #include <Geometry/RMatrix.hh>
83 const unsigned int height = 0);
173 double& minPhi,
double& maxPhi,
double& centerPhi,
174 double& minTheta,
double& maxTheta);
182 BIASERR(
"To be implemented in specialized child class!");
199 bool IgnoreDistortion =
false)
const;
209 bool IgnoreDistortion =
false)
const
211 BIASERR(
"To be implemented in specialized child class!");
222 bool IgnoreDistortion =
false)
const {
224 GetExternals().
Mult(X, x);
225 return ProjectLocal(x, IgnoreDistortion);
238 bool IgnoreDistortion =
false)
const {
240 GetExternals().
Mult(X, x);
241 return ProjectLocal(x, p2d, IgnoreDistortion);
253 bool IgnoreDistortion =
false)
const = 0;
268 bool IgnoreDistortion =
false)
const = 0;
288 bool ignoreDistortion =
false)
const = 0;
298 const double& depth = 1.0,
299 bool IgnoreDistortion =
false)
const = 0;
308 bool IgnoreDistortion =
false,
bool Normalize =
false);
330 UnProjectLocal(pos, point, dir, ignoreDistortion);
332 R.
Mult(dir, direction);
333 R.
Mult(point, origin);
355 UnProjectLocal(pos, point, dir, ignoreDistortion);
357 R.
Mult(dir, direction);
380 bool ignoreDistortion=
false)
const
385 R.
Mult(dir, direction);
386 R.
Mult(point, origin);
396 bool IgnoreDistortion =
false)
const;
401 bool IgnoreDistortion =
false)
const;
409 UnProjectToPointLocal(
const HomgPoint2D& pos,
const double& depth,
410 bool IgnoreDistortion =
false)
const;
438 virtual int GetUnProjectionJacobian(
const HomgPoint2D& x,
440 const bool homogenized =
true)
const;
467 BIASWARN(
"Projection is not valid");
468 BEXCEPTION(
"ProjectionParametersBase::GetC(): Extrinsics are invalid.");
477 BIASWARN(
"Projection is not valid");
478 BEXCEPTION(
"ProjectionParametersBase::GetQ(): Extrinsics are invalid.");
491 CQ[0] = C[0]; CQ[1] = C[1]; CQ[2] = C[2];
492 CQ[3] = Q[0]; CQ[4] = Q[1]; CQ[5] = Q[2]; CQ[6] = Q[3];
501 return Pose_.GetCovariance();
525 return Pose_.GetPoseParameters();
530 { Pose_.Set(pp); QValid_ = CValid_ =
true; }
541 return Pose_.GetMatrix3x4();
545 virtual inline int GetImageSize(
unsigned int& Width,
unsigned int& Height)
const {
578 return videoSourceType_;
587 virtual inline int GetPrincipal(
double& PrincipalX,
double& PrincipalY)
const {
588 PrincipalX = principalX_;
589 PrincipalY = principalY_;
598 aspectratio_ = AspectRatio;
610 const unsigned int h) {
621 virtual void SetVideoSourceType(
const std::string &name);
630 virtual void Rescale(
double ratio,
const double offset = 0.0);
638 virtual void Rescale(
unsigned int width,
unsigned int height);
645 { Pose_.SetQ(Q); QValid_ =
true; }
649 { Pose_.SetC(C); CValid_ =
true; }
654 { Pose_.Set(Q,C); QValid_ = CValid_ =
true; }
658 { Pose_ = pose; QValid_ = CValid_ =
true; }
670 { Pose_.SetCovariance(Cov); }
673 virtual inline bool CValid()
const {
return CValid_; }
676 virtual inline bool QValid()
const {
return QValid_; }
680 {
return (CValid_ && QValid_); }
684 { CValid_ = QValid_ =
false; }
712 virtual BIAS::KMatrix GetFakeKMatrix(
double& imgsize,
int resolution = 0,
713 const double& maxangle = 1.4)
const;
715 const double& maxangle = 1.4)
const;
724 #ifdef BIAS_HAVE_XML2
726 virtual int XMLGetClassName(std::string& TopLevelTag,
727 double& Version)
const;
730 virtual int XMLOut(
const xmlNodePtr Node,
XMLIO& XMLObject)
const;
733 virtual int XMLIn(
const xmlNodePtr Node,
XMLIO& XMLObject);
752 return Pose_.LookAt(eye, center, up);
761 return Pose_.LookAt(GetC(), center, up);
771 return Pose_.LookAtGL(eye, center, up);
780 return Pose_.LookAtGL(GetC(), center, up);
816 else os<<
"C: invalid"<<std::endl;
818 else os<<
"Q: invalid"<<std::endl;
827 #include <Base/Common/BIASpragmaEnd.hh>
virtual BIAS::Vector3< double > GetC() const
Get projection center.
virtual void SetCov(const Matrix< POSE_TYPE > &Cov)
Set pose covariance matrix with respect to C, Q.
virtual void SetPrincipal(const double x, const double y)
Set principal point (in pixels relative to top left corner).
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
virtual BIAS::Vector< double > GetCQ() const
Return pose as 7 vector (first projection center C, then unit quaternion Q representing orientation)...
const bool LookAtGL(const Vector3< double > &eye, const Vector3< double > ¢er, const Vector3< double > &up)
Looks at given point, similar to gluLookAt.
virtual void SetR(const BIAS::RMatrix &R)
Set orientation from rotation matrix R.
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 const unsigned int & GetImageHeight() const
Returns the image height.
const bool LookAtGL(const Vector3< double > ¢er, const Vector3< double > &up)
Looks at given point, similar to gluLookAt.
virtual int GetPrincipal(double &PrincipalX, double &PrincipalY) const
Get principal point (in pixels relative to top left corner).
virtual void SetIdentifier(std::string name)
Set the identification string.
virtual BIAS::Matrix< POSE_TYPE > GetCov() const
Return pose covariance as 7x7 matrix with respect to C, Q.
virtual BIAS::Matrix3x4< double > GetExternals() const
Return cached 3x4 representation of external matrix [R|C].
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
virtual std::string GetIdentifier() const
Slim class bundeling pose parametrization and associated covariance matrix.
Down-, Upsampling routines and Resize.
std::string videoSourceType_
virtual void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &origin, 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...
virtual void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &origin, Vector3< double > &direction, bool ignoreDistortion=false) const
Calculates the view ray, which belongs to the given position on the image plane, in global coordinate...
virtual const unsigned int & GetImageWidth() const
Returns the image width.
int GetQuaternion(Quaternion< ROTATION_MATRIX_TYPE > &quat) const
Calculates quaternion representation for this rotation matrix.
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 void SetPose(const BIAS::Pose pose)
Set pose from pose object.
bool ustIgnoreDistortion_
std::string identifier_
Multifunctional identifier.
virtual void SetQ(const BIAS::Quaternion< double > &Q)
Set orientation from unit quaternion Q.
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
void Mult(const Vector3< T > &argvec, Vector3< T > &destvec) const
matrix - vector multiplicate this matrix with Vector3, storing the result in destvec calculates: dest...
virtual bool DoesPointProjectIntoImageLocal(const Vector3< double > &localX, HomgPoint2D &x, bool IgnoreDistortion=false) const
Checks if 3D point projects into specified image and returns belonging 2D image point.
virtual bool PoseValid() const
Check if current pose is valid.
virtual double GetAspectratio() const
Return aspectratio (i.e.
virtual BIAS::PoseParametrization GetPoseParametrization() const
Return copy of pose parametrization object.
void Mult(const T &scalar, Vector3< T > &dest) const
unsigned int height_
height of image in pixels
virtual bool QValid() const
Check if current orientation is valid.
virtual void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &direction, bool ignoreDistortion=false) const
Calculates the view ray, which belongs to the given position on the image plane, in global coordinate...
virtual bool CValid() const
Check of current projection center is valid.
virtual void UnProjectLocal(const HomgPoint2D &pos, Vector3< double > &origin, Vector3< double > &direction, bool ignoreDistortion=false) const =0
Calculates the view ray, which belongs to the given position on the image plane, in local coordinates...
Base class with interface for xml output.
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
virtual std::string GetVideoSourceType() const
Can be used to run along the image border.
virtual int GetImageSize(unsigned int &Width, unsigned int &Height) const
Obtain image dimensions.
unsigned int width_
width of image in pixels
double x
If using BorderPixel methods these are the coordinates of the pixel.
bool ustTransformIntoImage_
unscented transform worker variables
const bool LookAt(const Vector3< double > ¢er, const Vector3< double > &up)
Looks at given point, similar to gluLookAt.
const bool LookAt(const Vector3< double > &eye, const Vector3< double > ¢er, const Vector3< double > &up)
Looks at given point, similar to gluLookAt.
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
class BIASGeometry_EXPORT ProjectionParametersBase
double principalX_
principal point in pixel coordinates (one for all zoom settings)
double aspectratio_
aspect ratio of the camera CCD
virtual void ValidatePose()
Validate currently set pose.
virtual void SetAspectratio(const double AspectRatio)
Set CCD aspect ratio (i.e.
virtual void SetQC(const BIAS::Quaternion< double > &Q, const BIAS::Vector3< double > &C)
Set pose from unit quaternion Q and projection center C.
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual BIAS::Quaternion< double > GetQ() const
Get orientation as unit quaternion.
virtual const BIAS::Pose & GetPose() const
Return complete pose object.
virtual int GetMinimalAngularSamplingStep(double &minAngleStep)
Delivers the assumed minimal angular distance between two optical rays belonging to integer image coo...
virtual void SetPoseParametrization(const BIAS::PoseParametrization &pp)
Set pose from pose parametrization.
virtual void SetC(const BIAS::Vector3< double > &C)
Set projection center.
bool QValid_
validity flag for orientation and position
PixelIterator(const double &xx, const double &yy)
virtual ProjectionParametersBase & operator=(const ProjectionParametersBase &p)
virtual void InvalidatePose()
Invalidate currently set pose.