Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Projection.cpp
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 #include <Geometry/Projection.hh>
27 #include <Geometry/ProjectionParametersFactory.hh>
28 #include <Geometry/ProjectionParametersZoom.hh>
29 #include <Geometry/ProjectionParametersZoom.hh>
30 #include <Base/Common/FileHandling.hh>
31 #include <iostream>
32 
33 using namespace BIAS;
34 using namespace std;
35 
36 
39  vecParameters_.clear();
40 }
41 
44  BIASASSERT(vecParameters_.empty());
45  vecParameters_.push_back(p.Clone());
46 }
47 
50  BIASASSERT(vecParameters_.empty());
51  (*this) = p;
52 }
53 
56  for (unsigned int i=0; i<vecParameters_.size(); i++)
57  delete vecParameters_[i];
58  vecParameters_.clear();
59 }
60 
61 
62 int Projection::Load(const string& filename) {
63  bool silent = true;
64 #ifdef BIAS_HAVE_XML2
65  if (XMLRead(filename)==0) return 0;
66  if (ReadFromCamParamFile(filename, silent)==0) return 0;
67 #endif
68  if (ReadFromBBC(filename, silent)==0) {
69  cout << "Read projection from BBC freed data: "<< *this <<endl;
70  return 0;
71  }
72 
73  PMatrix P;
74  if (P.Load(filename)) {
75  double x = P.GetK()[0][2];
76  double y = P.GetK()[1][2];
77  int width = 8*(int)(rint(x+2.0)/4);
78  int height = 8*(int)(rint(y+2.0)/4);
79  cout<<"Read from PMatrix, image size is UNKNOWN, GUESSING: "<<width
80  <<"x"<<height<<endl;
82  PP.SetP(P);
83  PP.SetImageSize(width,height);
84  vecParameters_.clear();
85  vecParameters_.push_back(PP.Clone());
86  return 0;
87  }
88 
89  BIASERR("unable to load projection from file : "<<filename<<" cwd="<<FileHandling::GetCwd() );
90 #ifndef BIAS_HAVE_XML2
91  BIASERR("Missing XML support in BIAS, can only read BBC FreeD-data.");
92 #endif
93 
94  return -1;
95 }
96 
97 
98 #ifdef BIAS_HAVE_XML2
99  int Projection::ReadFromCamParamFile(const string& filename,
100  const bool silent ) {
101 
102  // read datafile
103  vector<CameraData> vcd;
104  if (ProjectionParametersIO::ReadRigData(filename, vcd, silent) != 0)
105  return -1;
106  return InitFromCameraData(vcd);
107  }
108 #endif // BIAS_HAVE_XML2
109 
110  int Projection::ReadFromBBC(const string& filename,
111  const bool silent) {
112  // read datafile
113  vector<CameraData> vcd;
114  vcd.resize(1);
115  if (ProjectionParametersIO::ReadFromBBC(filename, vcd[0], 0.0, 0.0,
116  silent)!=0) return -1;
117  return InitFromCameraData(vcd);
118  }
119 
120  int Projection::InitFromCameraData(const vector<CameraData>& vcd) {
121  // initialize parameter vector
122  vecParameters_.clear();
123 
125  for (unsigned int i=0; i<vcd.size(); i++) {
126  vecParameters_.push_back(factory.Create(vcd[i]));
127  }
128 
129  return 0;
130  }
131 
132 
134  const KMatrix& K,
135  int width, int height,
137  const vector<double>&
138  UndistortionCoefficients)
139  {
142  ppp->SetDistortionType(radDistType);
143  ppp->SetFocalLengthAndAspect(K.GetFx(), K.GetFy()/K.GetFx());
144  switch(radDistType){
145  case DISTYPE_NONE:
146  break;
147  case DISTYPE_RADIAL:
148  BIASASSERT(UndistortionCoefficients.size() == 2);
149  ppp->SetUndistortion(UndistortionCoefficients[0],
150  UndistortionCoefficients[1]);
151  break;
152  case DISTYPE_DEF:
153  BIASASSERT(UndistortionCoefficients.size() == 4);
154  ppp->SetUndistortion(UndistortionCoefficients[0],
155  UndistortionCoefficients[1],
156  UndistortionCoefficients[2],
157  UndistortionCoefficients[3]);
158  break;
159  case DISTYPE_BROWN:
160  BIASASSERT(UndistortionCoefficients.size() == 5);
161  ppp->SetUndistortionBrown(UndistortionCoefficients[0],
162  UndistortionCoefficients[1],
163  UndistortionCoefficients[2],
164  UndistortionCoefficients[3],
165  UndistortionCoefficients[4]);
166  break;
167  case DISTYPE_INVERSE_RAD:
168  BIASASSERT(UndistortionCoefficients.size() == 4);
169  ppp->SetUndistortionInverseRad(UndistortionCoefficients[0],
170  UndistortionCoefficients[1],
171  UndistortionCoefficients[2],
172  UndistortionCoefficients[3]);
173  break;
174  case DISTYPE_RAD3:
175  BIASASSERT(UndistortionCoefficients.size() == 3);
176  ppp->SetUndistortionRad3(UndistortionCoefficients[0],
177  UndistortionCoefficients[1],
178  UndistortionCoefficients[2]);
179  break;
180  case DISTYPE_INVRAD3:
181  BIASASSERT(UndistortionCoefficients.size() == 3);
182  ppp->SetUndistortionInverseRad3(UndistortionCoefficients[0],
183  UndistortionCoefficients[1],
184  UndistortionCoefficients[2]);
185  break;
186  }
187  ppp->SetImageSize(width, height);
188  ppp->SetPrincipal(K.GetHx(), K.GetHy());
189  ppp->SetPose(pose);
190  vecParameters_.push_back((ProjectionParametersBase*)ppp);
191  }
192 
193 
195  ProjectionParametersBase* p = ppb->Clone();
196  vecParameters_.push_back(p);
197  }
198 
200  ProjectionParametersBase* p = ppb->Clone();
201  // if we add the first camera, set it as it is
202  if(vecParameters_.size() == 0)
203  vecParameters_.push_back(p);
204  //if it is the nth camera calc offset to last previously camera in rig
205  else{
206  Pose newPose;
207  newPose.BecomeRelativeTransform(p->GetPose(),
208  vecParameters_[0]->GetPose());
209 
210  p->SetPose(newPose);
211  //add camera
212  vecParameters_.push_back(p);
213  }
214 
215  }
216 
217 
219  const unsigned int width, const int height,
220  const double principalX, const double principalY,
221  const double radius,
222  const double aspect)
223  {
226 
227  // externals
228  pps->SetPose(pose);
229 
230  // internals
231  pps->SetImageSize(width, height);
232  pps->SetPrincipal( principalX, principalY );
233  pps->SetRadius(radius);
234  pps->SetAspectratio(aspect);
235  vector<double> AngleCorrX, AngleCorrY;
236 
237  // angular undistortion, ideal to deformed angle
238  AngleCorrX.push_back(0.0);
239  AngleCorrY.push_back(0.0);
240  AngleCorrX.push_back(M_PI_2); // identity
241  AngleCorrY.push_back(M_PI_2); // almost true for Ibak project fisheye lense
242  pps->SetUndistortion(AngleCorrX, AngleCorrY, radius);
243 
244  // update data, create new PPS and delete it in destructor of Projection
245  vecParameters_.push_back( (ProjectionParametersBase*)pps );
246  }
247 
248 
249 
250  HomgPoint2D Projection::Project(const HomgPoint3D &X, unsigned int cam,
251  bool IgnoreDistortion) const
252  {
253  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
254  if (cam==0) {
255  Vector3<double> x;
256  vecParameters_[cam]->GetExternals().Mult(X, x);
257  return vecParameters_[cam]->ProjectLocal(x, IgnoreDistortion);
258  } else {
259  HomgPoint3D Xl = vecParameters_[0]->GetPose().GlobalToLocal(X);
260  return vecParameters_[cam]->Project(Xl, IgnoreDistortion);
261  }
262  BIASERR("To be implemented");
263  BIASABORT;
264  HomgPoint2D h(0,0,0);
265  return h;
266  }
267 
268  const bool Projection::
270 
271  if(p.vecParameters_.size() != vecParameters_.size())
272  return true;
273  if(p.vecParameters_.size() == 0 || vecParameters_.size() == 0)
274  return true;
275 
276  bool theyDiffer = false;
277  for(unsigned int i=0; i<vecParameters_.size() && !theyDiffer; i++)
278  theyDiffer = vecParameters_[i]->DoExtrinsicsDiffer(p.vecParameters_[i]);
279 
280  return theyDiffer;
281  }
282 
283 
284  const bool Projection::
286 
287  if(p.vecParameters_.size() != vecParameters_.size())
288  return true;
289  if(p.vecParameters_.size() == 0 || vecParameters_.size() == 0)
290  return true;
291 
292  bool theyDiffer = false;
293  for(unsigned int i=0; i<vecParameters_.size() && !theyDiffer; i++ )
294  theyDiffer = vecParameters_[i]->DoIntrinsicsDiffer(p.vecParameters_[i]);
295 
296  return theyDiffer;
297  }
298 
299  bool Projection::
301  HomgPoint2D& x,
302  unsigned int cam,
303  bool IgnoreDistortion) const
304  {
305  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
306  if(cam!=0) {
307  //point in rigs coordinate frame
308  HomgPoint3D Xr = vecParameters_[0]->GetPose().GlobalToLocal(X);
309 
310  //point in cam coordinate frame
311  HomgPoint3D Xl = vecParameters_[cam]->GetPose().GlobalToLocal(Xr);
312  Xl.Homogenize();
313 
314  return vecParameters_[cam]->DoesPointProjectIntoImageLocal(Xl.GetEuclidean(),x,IgnoreDistortion);
315  }
316 
317  return vecParameters_[cam]->DoesPointProjectIntoImage(X, x,
318  IgnoreDistortion);
319  }
320 
321 
322 
324  Vector3<double>& origin,
325  Vector3<double>& rayDir,
326  unsigned int cam,
327  bool IgnoreDistortion) const
328  {
329  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
330  Vector3<double> x;
331  UnProjectToRayLocal(pos, origin, x, 0, cam, IgnoreDistortion);
332  GetR().Mult(x, rayDir);
333  origin += vecParameters_[cam]->GetC();
334  }
335 
336 
338  Vector3<double>& rayDir,
339  unsigned int cam,
340  bool IgnoreDistortion) const
341  {
342  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
343  Vector3<double> x, tmp;
344  UnProjectToRayLocal(pos, tmp, x, 0, cam, IgnoreDistortion);
345  GetR().Mult(x, rayDir);
346  }
347 
348 
350  double depth,
351  unsigned int cam,
352  bool IgnoreDistortion) const
353  {
354  Vector3<double> opticalray, p;
355  UnProjectToRay(pos, p, opticalray, cam, IgnoreDistortion);
356  if(opticalray.NormL2()==0.0) {
357 #ifdef BIAS_DEBUG
358  BIASERR("returned ray has zero length!");
359 #endif
360  return Vector3<double> (0,0,0);
361  }
362  opticalray.Normalize();
363  return (GetAbsoluteC(cam) + depth*opticalray);
364  }
365 
366 
369  const double& depth,
370  unsigned int camSystem,
371  unsigned int cam,
372  bool IgnoreDistortion) const
373  {
374  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
375  BIASASSERT(vecParameters_.size()>camSystem && vecParameters_[camSystem]);
376 
377  Vector3<double> x=
378  vecParameters_[cam]->UnProjectToPointLocal(pos,
379  depth,
380  IgnoreDistortion);
381  if(camSystem != cam) {
382  HomgPoint3D xHomg(x);
383  HomgPoint3D xHomgRig;
384  HomgPoint3D xHomgTarget;
385  Pose CamRigPose = vecParameters_[cam]->GetPose();
386 
387  xHomgRig = CamRigPose.LocalToGlobal(xHomg);
388  if(cam==0) {
389  xHomgRig.GetEuclidean(x);
390  } else {
391  Pose TargetRigPose = vecParameters_[camSystem]->GetPose();
392  xHomg = TargetRigPose.GlobalToLocal(xHomgRig);
393  xHomg.GetEuclidean(x);
394  }
395 
396  }
397 
398  return x;
399  }
400 
401 
404  const double& /*depth*/, unsigned int camSystem,
405  unsigned int cam, bool IgnoreDistortion,
406  bool Normalize) const
407  {
408  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
409  if (camSystem != cam) {
410  BIASERR("Not implemented.");
411  BIASABORT;
412  }
413  return vecParameters_[cam]->UnProjectCovLocal(pos, cov2D,
414  IgnoreDistortion, Normalize);
415  }
416 
417 
418 
420  Vector3<double>& origin,
421  Vector3<double>& rayDir,
422  unsigned int camSystem,
423  unsigned int cam,
424  bool IgnoreDistortion) const
425  {
426  BIASASSERT(vecParameters_.size()>camSystem && vecParameters_[camSystem]);
427  BIASASSERT(vecParameters_.size()>cam && vecParameters_[cam]);
428 
429  Vector3<double> x, p;
430  vecParameters_[cam]->UnProjectLocal(pos, p, x, IgnoreDistortion);
431 
432  if(camSystem != cam) {
433  //the relative rotation to rig of the system we GOT the ray direction in
434  RMatrix ROrigin = GetR(cam);
435  x = ROrigin * x; //x is now in the rig coordinate system
436 
437  Vector3<double> COrigin = GetC(cam);
438  p = COrigin + ROrigin * p; // p is now in rig coordinate system
439 
440  if(camSystem!=0) {
441  //the relative rotation to rig of the system we WANT to have
442  // the direction in
443  RMatrix RTarget = GetR(camSystem);
444 
445  x = RTarget.Transpose() * x;
446  //x is now in the local target coordinate system
447 
448  Vector3<double> CTarget = GetC(camSystem);
449  p = RTarget.Transpose() * p - RTarget.Transpose() * CTarget;
450  }
451  }
452 
453  origin = p;
454  rayDir = x;
455  }
456 
457 
458 
459 #ifdef BIAS_HAVE_XML2
460 
461  int Projection::XMLGetClassName(string& TopLevelTag,
462  double& Version) const{
463  TopLevelTag = "Projection";
464  Version = 0.1;
465  return 0;
466  }
467 
468  int Projection::XMLOut(const xmlNodePtr Node, XMLIO& XMLObject) const{
469 
470  xmlNodePtr theNode;
471  string TopLevelName;
472  double Version;
473  if(identifier_.size()>0) {
474  theNode = XMLObject.addChildNode(Node, "Identifier");
475  XMLObject.addContent(theNode, identifier_);
476  }
477  std::vector<ProjectionParametersBase* >::const_iterator it;
478  for (it=vecParameters_.begin(); it!=vecParameters_.end(); it++) {
479  (**it).XMLGetClassName(TopLevelName, Version);
480  theNode = XMLObject.addChildNode(Node, TopLevelName);
481  XMLObject.addAttribute(theNode, "Version", Version);
482  (*it)->XMLOut(theNode, XMLObject);
483  }
484 
485  return 0;
486  }
487 
488 
489  int Projection::XMLIn(const xmlNodePtr Node, XMLIO& XMLObject){
490 
491  //delete old cameras
492  for (unsigned int i=0; i<vecParameters_.size(); i++)
493  delete vecParameters_[i];
494  vecParameters_.clear();
495 
496  string TopLevelName;
497  xmlNodePtr childNode;
498  childNode = XMLObject.getFirstChild(Node);
499  if (childNode == NULL) return 0; // it is ok to read an empty Proj.
500  while (childNode!=NULL) {
501  string nodename = XMLObject.getNodeName(childNode);
502  if (nodename.compare("Identifier")==0) {
503  identifier_ = XMLObject.getNodeContentString(childNode);
504  } else {
506  ProjectionParametersBase *pp = factory.Create(nodename);
507  if(pp->XMLIn(childNode, XMLObject)!=0)
508  return -1;
509  vecParameters_.push_back(pp);
510  }
511  childNode = XMLObject.getNextChild(childNode);
512  }
513  if (vecParameters_.size()>0) {
514  return 0;
515  } else {
516  return -1;
517  }
518  }
519 
520 #endif // BIAS_HAVE_XML2
521 
522 
524  Projection::GetQ(unsigned int cam) const
525  {
526  BIASASSERT(cam<vecParameters_.size() && vecParameters_[cam]);
527  return vecParameters_[cam]->GetQ();
528  }
529 
530 
void AddRelativeCamera(ProjectionParametersBase *ppb)
Add a camera to the projection,the coordinates of the pose are given in relative Coordinates, first cam is origin.
Definition: Projection.cpp:194
void addAttribute(const xmlNodePtr Node, const std::string &AttributeName, bool AttributeValue)
Add an attribute to a node.
Definition: XMLIO.cpp:156
void BecomeRelativeTransform(const CoordinateTransform3D &newLocal, const CoordinateTransform3D &newGlobal)
Changes this coordinate transformation so that parameter newLocal becomes the local coordinate frame ...
virtual void SetPrincipal(const double x, const double y)
Set principal point (in pixels relative to top left corner).
void GetEuclidean(Vector3< HOMGPOINT3D_TYPE > &dest) const
calculate affine coordinates of this and write them to dest affine coordinates are projective coordin...
Definition: HomgPoint3D.hh:336
int ReadFromBBC(const std::string &filename, const bool silent=false)
read BBC&#39;s FreeD data from file and constructs a perspective projection (may have radial distortion) ...
Definition: Projection.cpp:110
KMATRIX_TYPE GetFy() const
Definition: KMatrix.cpp:77
xmlNodePtr getNextChild()
Get the next child of the parent specified in the last getFirstChild() call, the class remembers the ...
Definition: XMLIO.cpp:466
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
virtual int Load(const std::string &filename)
convenience wrapper which tries to read different formats
Definition: Projection.cpp:62
void SetDistortionType(BIAS_ProjParaPersp_DISTORTION_TYPE distype)
Set type of distortion parameters.
Matrix3x3< double > UnProjectToCovLocal(const HomgPoint2D &pos, const Matrix3x3< double > &cov2D, const double &depth, unsigned int camSystem=0, unsigned int cam=0, bool IgnoreDistortion=false, bool Normalize=false) const
calculate 3D point and associated covariance by unprojection
Definition: Projection.cpp:403
bool Load(const std::string &filename)
overload Load because it has to invalidate decomposition! JW 09/2003
Definition: PMatrix.hh:348
virtual int XMLIn(const xmlNodePtr Node, XMLIO &XMLObject)
specialization of XML read function for BIAS::Projection.
Definition: Projection.cpp:489
virtual const bool DoExtrinsicsDiffer(const BIAS::Projection &p) const
Checks whether extrinsic parameters are different.
Definition: Projection.cpp:269
ProjectionParametersBase * Create(const std::string &className)
Creates a projection parameters object by a class name.
int InitFromCameraData(const std::vector< CameraData > &vcd)
initializes projection from cameradata object
Definition: Projection.cpp:120
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual void SetPrincipal(const double x, const double y)
Set principal point in pixels relative to top left corner, virtual overload to recalculate K_...
virtual void SetImageSize(const unsigned int w, const unsigned int h)
Set image dimensions (in pixels).
virtual ProjectionParametersBase * Clone() const =0
Covariant virtual copy constructor used in BIAS::Projection.
void Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint3D.hh:308
static int ReadRigData(const std::string &filename, std::vector< CameraData > &vcd, const bool silent=false)
Read a rig parameter file and store the data in (*this) the Camera-, Center-, RMatrix-, and KMatrix-Vectors are reset from the file.
std::vector< ProjectionParametersBase * > vecParameters_
the intrinsics (like K, ...) of the camera usually only one only in rig mode there may be many...
Definition: Projection.hh:496
virtual ~Projection()
destructor for initialization with a ProjectionParametersBase object
Definition: Projection.cpp:55
virtual void SetP(const PMatrix &P)
set from P
void CreateSpherical(const Pose &pose, const unsigned int width, const int height, const double principalX, const double principalY, const double radius, const double aspect=1.0)
push_back a new sperical cam to this
Definition: Projection.cpp:218
static std::string GetCwd()
Return current working directory as string.
HomgPoint3D GlobalToLocal(const HomgPoint3D &X_G) const
Transform point from world frame to local coordinate frame.
virtual int XMLIn(const xmlNodePtr Node, XMLIO &XMLObject)
Specialization of XML read function.
BIAS::Quaternion< double > GetQ(unsigned int cam=0) const
return rotation quaternion of camera with index cam if cam&gt;0 this is a relative pose in the coordinat...
Definition: Projection.cpp:524
void SetRadius(const double r)
Set radius of spherical image in pixels.
virtual void SetPose(const BIAS::Pose pose)
Set pose from pose object.
3D rotation matrix
Definition: RMatrix.hh:49
void UnProjectToRayLocal(const HomgPoint2D &pos, Vector3< double > &origin, Vector3< double > &rayDir, unsigned int camSystem=0, unsigned int cam=0, bool IgnoreDistortion=false) const
calculates a 3D ray in a local camera coordinate system specified by camSystem, which belongs to the ...
Definition: Projection.cpp:419
Represents 3d pose transformations, parametrized as Euclidean translation and unit quaternion orienta...
Definition: Pose.hh:73
void addContent(const xmlNodePtr Node, const std::string &Content)
Add content to a node.
Definition: XMLIO.cpp:254
KMATRIX_TYPE GetHy() const
Definition: KMatrix.cpp:86
virtual int XMLGetClassName(std::string &TopLevelTag, double &Version) const
specialization of XML block name function for BIAS::Projection.
Definition: Projection.cpp:461
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
Definition: XMLIO.hh:72
void UnProjectToRay(const HomgPoint2D &pos, Vector3< double > &origin, Vector3< double > &rayDir, unsigned int cam=0, bool IgnoreDistortion=false) const
calculates the viewing ray in the global coordinate frame (not the rig) from the camera center which ...
Definition: Projection.cpp:323
xmlNodePtr addChildNode(const xmlNodePtr ParentNode, const std::string &NewNodeName)
Add a child node to an incoming node with the given name.
Definition: XMLIO.cpp:131
This class hides the underlying projection model, like projection matrix, spherical camera...
Definition: Projection.hh:70
void SetUndistortionInverseRad(double kc1, double kc2, double kc3, double kc4)
virtual ProjectionParametersPerspective * Clone() const
covariant virtual copy constructor for use in Projection
void SetUndistortionInverseRad3(double kc1, double kc2, double kc3)
void Mult(const T &scalar, Vector3< T > &dest) const
Definition: Vector3.hh:332
xmlNodePtr getFirstChild(const xmlNodePtr ParentNode)
Get the first child of a given parent, or NULL for no childs.
Definition: XMLIO.cpp:452
KMATRIX_TYPE GetFx() const
Definition: KMatrix.cpp:74
void AddAbsoluteCamera(ProjectionParametersBase *ppb)
Add a camera to the projection,the coordinates of the pose are given in absolute Coordinates, they are transformed to relative coordinates to the first camera internally.
Definition: Projection.cpp:199
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual int XMLOut(const xmlNodePtr Node, XMLIO &XMLObject) const
specialization of XML write function for BIAS::Projection.
Definition: Projection.cpp:468
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
KMATRIX_TYPE GetHx() const
Definition: KMatrix.cpp:83
virtual bool DoesPointProjectIntoImage(const BIAS::HomgPoint3D &X, BIAS::HomgPoint2D &x, unsigned int cam=0, bool IgnoreDistortion=false) const
Checks if 3D point projects into specified image and returns belonging 2D image point.
Definition: Projection.cpp:300
virtual const bool DoIntrinsicsDiffer(const BIAS::Projection &p) const
Checks whether intrinsic parameters are different.
Definition: Projection.cpp:285
void SetUndistortionRad3(double kc1, double kc2, double kc3)
HomgPoint3D LocalToGlobal(const HomgPoint3D &X_L) const
Transform point from local frame to world coordinate frame.
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
Definition: Matrix3x3.cpp:167
Vector3< double > UnProjectToPoint(const HomgPoint2D &pos, double depth, unsigned int cam=0, bool IgnoreDistortion=false) const
calculates a 3D point in the global (not the rig) coordinate system, which belongs to the image posit...
Definition: Projection.cpp:349
void SetUndistortionBrown(double kc1, double kc2, double kc3, double kc4, double r0)
Set the lens undistortion parameters including the root of the polynomial.
int SetUndistortion(const std::vector< double > &undistAngles, const std::vector< double > &distAngles, const double radius)
Set undistortion polynomial from corresponding undistorted and distorted azimuth angles (in rad) and ...
std::string getNodeName(const xmlNodePtr Node) const
Get the name of a given Node.
Definition: XMLIO.cpp:543
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
virtual void SetAspectratio(const double AspectRatio)
Set CCD aspect ratio (i.e.
void CreatePerspective(const BIAS::Pose &pose, const BIAS::KMatrix &K, int width, int height, BIAS_ProjParaPersp_DISTORTION_TYPE radDistType=DISTYPE_DEF, const std::vector< double > &UndistortionCoefficients=std::vector< double >(4, 0.0))
Create a perspective camera and add to projection.
Definition: Projection.cpp:133
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
void SetFocalLengthAndAspect(double f, double AspectRatio)
Set the current camera focal length in pixel and the a spect ratio.
Projection()
constructor
Definition: Projection.cpp:38
virtual HomgPoint2D Project(const HomgPoint3D &X, unsigned int cam=0, bool IgnoreDistortion=false) const
returns the 2d projection of X in camera cam, where X is given in the global coordinate frame (not th...
Definition: Projection.cpp:250
Camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
virtual const BIAS::Pose & GetPose() const
Return complete pose object.
Vector3< T > & Normalize()
normalize this vector to length 1
Definition: Vector3.hh:663
static int ReadFromBBC(const std::string &filename, CameraData &cd, const double &addppx=0.0, const double &addppy=0.0, const bool silent=false)
read bbc&#39;s freeD date from a file
std::string getNodeContentString(const xmlNodePtr Node) const
Get the content of a given Node.
Definition: XMLIO.cpp:554
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)
Definition: Vector3.hh:633
Vector3< double > UnProjectToPointLocal(const HomgPoint2D &pos, const double &depth, unsigned int camSystem=0, unsigned int cam=0, bool IgnoreDistortion=false) const
calculates a 3D point in a local camera coordinate system specified by camSystem, which belongs to th...
Definition: Projection.cpp:368
int ReadFromCamParamFile(const std::string &filename, const bool silent=false)
Reads a camera data XML file and constructs the ProjectionParametersBase-pointer, using the Projectio...
Definition: Projection.cpp:99
int GetK(KMatrix &K)
calibration matrix
Definition: PMatrix.cpp:220