g2o
Public Member Functions | List of all members
g2o::EdgeProjectP2MC_Intrinsics Class Reference

#include <types_sba.h>

Inheritance diagram for g2o::EdgeProjectP2MC_Intrinsics:
Inheritance graph
[legend]
Collaboration diagram for g2o::EdgeProjectP2MC_Intrinsics:
Collaboration graph
[legend]

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgeProjectP2MC_Intrinsics ()
 
virtual bool read (std::istream &is)
 read the vertex from a stream, i.e., the internal state of the vertex More...
 
virtual bool write (std::ostream &os) const
 write the vertex to a stream More...
 
void computeError ()
 
virtual void linearizeOplus ()
 Jacobian for monocular projection with intrinsics calibration. More...
 
- Public Member Functions inherited from g2o::BaseMultiEdge< 2, Vector2D >
 BaseMultiEdge ()
 
virtual void linearizeOplus (JacobianWorkspace &jacobianWorkspace)
 
virtual void resize (size_t size)
 
virtual bool allVerticesFixed () const
 
virtual void constructQuadraticForm ()
 
virtual void mapHessianMemory (double *d, int i, int j, bool rowMajor)
 
- Public Member Functions inherited from g2o::BaseEdge< D, Vector2D >
 BaseEdge ()
 
virtual ~BaseEdge ()
 
virtual double chi2 () const
 computes the chi2 based on the cached error value, only valid after computeError has been called. More...
 
virtual const double * errorData () const
 returns the error vector cached after calling the computeError; More...
 
virtual double * errorData ()
 
const ErrorVectorerror () const
 
ErrorVectorerror ()
 
EIGEN_STRONG_INLINE const InformationTypeinformation () const
 information matrix of the constraint More...
 
EIGEN_STRONG_INLINE InformationTypeinformation ()
 
EIGEN_STRONG_INLINE void setInformation (const InformationType &information)
 
virtual const double * informationData () const
 returns the memory of the information matrix, usable for example with a Eigen::Map<MatrixXD> More...
 
virtual double * informationData ()
 
EIGEN_STRONG_INLINE const Measurementmeasurement () const
 accessor functions for the measurement represented by the edge More...
 
virtual void setMeasurement (const Measurement &m)
 
virtual int rank () const
 
virtual void initialEstimate (const OptimizableGraph::VertexSet &, OptimizableGraph::Vertex *)
 
- Public Member Functions inherited from g2o::OptimizableGraph::Edge
 Edge ()
 
virtual ~Edge ()
 
virtual Edgeclone () const
 
virtual bool setMeasurementData (const double *m)
 
virtual bool getMeasurementData (double *m) const
 
virtual int measurementDimension () const
 
virtual bool setMeasurementFromState ()
 
RobustKernelrobustKernel () const
 if NOT NULL, error of this edge will be robustifed with the kernel More...
 
void setRobustKernel (RobustKernel *ptr)
 
virtual double initialEstimatePossible (const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)
 
int level () const
 returns the level of the edge More...
 
void setLevel (int l)
 sets the level of the edge More...
 
int dimension () const
 returns the dimensions of the error function More...
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createFrom())
 
 G2O_ATTRIBUTE_DEPRECATED (virtual Vertex *createTo())
 
virtual VertexcreateVertex (int)
 
long long internalId () const
 the internal ID of the edge More...
 
OptimizableGraphgraph ()
 
const OptimizableGraphgraph () const
 
bool setParameterId (int argNum, int paramId)
 
const Parameterparameter (int argNo) const
 
size_t numParameters () const
 
void resizeParameters (size_t newSize)
 
- Public Member Functions inherited from g2o::HyperGraph::Edge
 Edge (int id=InvalidId)
 creates and empty edge with no vertices More...
 
const VertexContainervertices () const
 
VertexContainervertices ()
 
const Vertexvertex (size_t i) const
 
Vertexvertex (size_t i)
 
void setVertex (size_t i, Vertex *v)
 
int id () const
 
void setId (int id)
 
virtual HyperGraphElementType elementType () const
 
int numUndefinedVertices () const
 
- Public Member Functions inherited from g2o::HyperGraph::HyperGraphElement
virtual ~HyperGraphElement ()
 
HyperGraphElementclone () const
 
- Public Member Functions inherited from g2o::HyperGraph::DataContainer
 DataContainer ()
 
virtual ~DataContainer ()
 
const DatauserData () const
 the user data associated with this vertex More...
 
DatauserData ()
 
void setUserData (Data *obs)
 
void addUserData (Data *obs)
 

Additional Inherited Members

- Public Types inherited from g2o::BaseMultiEdge< 2, Vector2D >
typedef BaseEdge< D, Vector2D >::Measurement Measurement
 
typedef MatrixXD::MapType JacobianType
 
typedef BaseEdge< D, Vector2D >::ErrorVector ErrorVector
 
typedef BaseEdge< D, Vector2D >::InformationType InformationType
 
typedef Eigen::Map< MatrixXD, MatrixXD::Flags &Eigen::AlignedBit?Eigen::Aligned:Eigen::Unaligned > HessianBlockType
 
- Public Types inherited from g2o::BaseEdge< D, Vector2D >
typedef Vector2D Measurement
 
typedef Eigen::Matrix< double, D, 1, Eigen::ColMajor > ErrorVector
 
typedef Eigen::Matrix< double, D, D, Eigen::ColMajor > InformationType
 
- Static Public Attributes inherited from g2o::BaseMultiEdge< 2, Vector2D >
static const int Dimension
 
- Static Public Attributes inherited from g2o::BaseEdge< D, Vector2D >
static const int Dimension
 
- Protected Member Functions inherited from g2o::BaseMultiEdge< 2, Vector2D >
void computeQuadraticForm (const InformationType &omega, const ErrorVector &weightedError)
 
- Protected Member Functions inherited from g2o::BaseEdge< D, Vector2D >
InformationType robustInformation (const Vector3D &rho)
 
- Protected Member Functions inherited from g2o::OptimizableGraph::Edge
template<typename ParameterType >
bool installParameter (ParameterType *&p, size_t argNo, int paramId=-1)
 
template<typename CacheType >
void resolveCache (CacheType *&cache, OptimizableGraph::Vertex *, const std::string &_type, const ParameterVector &parameters)
 
bool resolveParameters ()
 
virtual bool resolveCaches ()
 
- Protected Attributes inherited from g2o::BaseMultiEdge< 2, Vector2D >
std::vector< HessianHelper > _hessian
 
std::vector< JacobianType, Eigen::aligned_allocator< JacobianType > > _jacobianOplus
 jacobians of the edge (w.r.t. oplus) More...
 
- Protected Attributes inherited from g2o::BaseEdge< D, Vector2D >
Measurement _measurement
 
InformationType _information
 
ErrorVector _error
 
- Protected Attributes inherited from g2o::OptimizableGraph::Edge
int _dimension
 
int _level
 
RobustKernel_robustKernel
 
long long _internalId
 
std::vector< int > _cacheIds
 
std::vector< std::string > _parameterTypes
 
std::vector< Parameter ** > _parameters
 
std::vector< int > _parameterIds
 
- Protected Attributes inherited from g2o::HyperGraph::Edge
VertexContainer _vertices
 
int _id
 unique id More...
 
- Protected Attributes inherited from g2o::HyperGraph::DataContainer
Data_userData
 

Detailed Description

Definition at line 254 of file types_sba.h.

Constructor & Destructor Documentation

g2o::EdgeProjectP2MC_Intrinsics::EdgeProjectP2MC_Intrinsics ( )

Definition at line 409 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::information(), and g2o::BaseMultiEdge< 2, Vector2D >::resize().

409  :
410  BaseMultiEdge<2, Vector2D>()
411  {
412  information().setIdentity();
413  resize(3);
414  }
virtual void resize(size_t size)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67

Member Function Documentation

void g2o::EdgeProjectP2MC_Intrinsics::computeError ( )
inlinevirtual

Implements g2o::OptimizableGraph::Edge.

Definition at line 263 of file types_sba.h.

References g2o::BaseVertex< D, T >::estimate(), and g2o::SBACam::w2i.

264  {
265  // from <Point> to <Cam>, the intrinsics in KCam should be already set!
266  const VertexSBAPointXYZ *point = static_cast<const VertexSBAPointXYZ*>(_vertices[0]);
267  VertexCam *cam = static_cast<VertexCam*>(_vertices[1]);
268  // calculate the projection
269  const Vector3D &pt = point->estimate();
270  Vector4D ppt(pt(0),pt(1),pt(2),1.0);
271  Vector3D p = cam->estimate().w2i * ppt;
272  Vector2D perr = p.head<2>()/p(2);
273  _error = perr - _measurement;
274  }
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
Eigen::Matrix< double, 3, 1, Eigen::ColMajor > Vector3D
Definition: eigen_types.h:46
Eigen::Matrix< double, 4, 1, Eigen::ColMajor > Vector4D
Definition: eigen_types.h:47
VertexContainer _vertices
Definition: hyper_graph.h:202
void g2o::EdgeProjectP2MC_Intrinsics::linearizeOplus ( )
virtual

Jacobian for monocular projection with intrinsics calibration.

Reimplemented from g2o::BaseMultiEdge< 2, Vector2D >.

Definition at line 419 of file types_sba.cpp.

References g2o::BaseMultiEdge< 2, Vector2D >::_jacobianOplus, g2o::HyperGraph::Edge::_vertices, g2o::SBACam::dRdx, g2o::SBACam::dRdy, g2o::SBACam::dRdz, g2o::BaseVertex< D, T >::estimate(), g2o_isnan, g2o::SBACam::Kcam, g2o::SE3Quat::translation(), and g2o::SBACam::w2n.

420  {
421  _jacobianOplus[0].resize(2,3);
422  _jacobianOplus[1].resize(2,6);
423  _jacobianOplus[2].resize(2,4);
424  VertexCam *vc = static_cast<VertexCam *>(_vertices[1]);
425  const SBACam &cam = vc->estimate();
426 
427  VertexSBAPointXYZ *vp = static_cast<VertexSBAPointXYZ *>(_vertices[0]);
428 
429  //VertexIntrinsics *intr = static_cast<VertexIntrinsics *>(_vertices[2]);
430 
431  Vector4D pt, trans;
432  pt.head<3>() = vp->estimate();
433  pt(3) = 1.0;
434  trans.head<3>() = cam.translation();
435  trans(3) = 1.0;
436 
437  // first get the world point in camera coords
438  Eigen::Matrix<double,3,1,Eigen::ColMajor> pc = cam.w2n * pt;
439 
440  // Jacobians wrt camera parameters
441  // set d(quat-x) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
442  double px = pc(0);
443  double py = pc(1);
444  double pz = pc(2);
445  double ipz2 = 1.0/(pz*pz);
446  if (g2o_isnan(ipz2) ) {
447  std::cout << "[SetJac] infinite jac" << std::endl;
448  abort();
449  }
450 
451  double ipz2fx = ipz2*cam.Kcam(0,0); // Fx
452  double ipz2fy = ipz2*cam.Kcam(1,1); // Fy
453 
454  Eigen::Matrix<double,3,1,Eigen::ColMajor> pwt;
455 
456  // check for local vars
457  pwt = (pt-trans).head<3>(); // transform translations, use differential rotation
458 
459  // dx
460  Eigen::Matrix<double,3,1,Eigen::ColMajor> dp = cam.dRdx * pwt; // dR'/dq * [pw - t]
461  _jacobianOplus[1](0,3) = (pz*dp(0) - px*dp(2))*ipz2fx;
462  _jacobianOplus[1](1,3) = (pz*dp(1) - py*dp(2))*ipz2fy;
463  // dy
464  dp = cam.dRdy * pwt; // dR'/dq * [pw - t]
465  _jacobianOplus[1](0,4) = (pz*dp(0) - px*dp(2))*ipz2fx;
466  _jacobianOplus[1](1,4) = (pz*dp(1) - py*dp(2))*ipz2fy;
467  // dz
468  dp = cam.dRdz * pwt; // dR'/dq * [pw - t]
469  _jacobianOplus[1](0,5) = (pz*dp(0) - px*dp(2))*ipz2fx;
470  _jacobianOplus[1](1,5) = (pz*dp(1) - py*dp(2))*ipz2fy;
471 
472  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
473  dp = -cam.w2n.col(0); // dpc / dx
474  _jacobianOplus[1](0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
475  _jacobianOplus[1](1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
476  dp = -cam.w2n.col(1); // dpc / dy
477  _jacobianOplus[1](0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
478  _jacobianOplus[1](1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
479  dp = -cam.w2n.col(2); // dpc / dz
480  _jacobianOplus[1](0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
481  _jacobianOplus[1](1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
482 
483  // Jacobians wrt point parameters
484  // set d(t) values [ pz*dpx/dx - px*dpz/dx ] / pz^2
485  dp = cam.w2n.col(0); // dpc / dx
486  _jacobianOplus[0](0,0) = (pz*dp(0) - px*dp(2))*ipz2fx;
487  _jacobianOplus[0](1,0) = (pz*dp(1) - py*dp(2))*ipz2fy;
488  dp = cam.w2n.col(1); // dpc / dy
489  _jacobianOplus[0](0,1) = (pz*dp(0) - px*dp(2))*ipz2fx;
490  _jacobianOplus[0](1,1) = (pz*dp(1) - py*dp(2))*ipz2fy;
491  dp = cam.w2n.col(2); // dpc / dz
492  _jacobianOplus[0](0,2) = (pz*dp(0) - px*dp(2))*ipz2fx;
493  _jacobianOplus[0](1,2) = (pz*dp(1) - py*dp(2))*ipz2fy;
494 
495  // Jacobians w.r.t the intrinsics
496  _jacobianOplus[2].setZero();
497  _jacobianOplus[2](0,0) = px/pz; // dx/dfx
498  _jacobianOplus[2](1,1) = py/pz; // dy/dfy
499  _jacobianOplus[2](0,2) = 1.; // dx/dcx
500  _jacobianOplus[2](1,3) = 1.; // dy/dcy
501  }
Eigen::Matrix< double, 4, 1, Eigen::ColMajor > Vector4D
Definition: eigen_types.h:47
#define g2o_isnan(x)
Definition: macros.h:99
std::vector< JacobianType, Eigen::aligned_allocator< JacobianType > > _jacobianOplus
jacobians of the edge (w.r.t. oplus)
VertexContainer _vertices
Definition: hyper_graph.h:202
bool g2o::EdgeProjectP2MC_Intrinsics::read ( std::istream &  is)
virtual

read the vertex from a stream, i.e., the internal state of the vertex

Implements g2o::OptimizableGraph::Edge.

Definition at line 503 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::information(), and g2o::BaseEdge< D, Vector2D >::setMeasurement().

504  {
505  // measured keypoint
506  Vector2D meas;
507  for (int i=0; i<2; i++)
508  is >> meas[i];
509  setMeasurement(meas);
510  // information matrix is the identity for features, could be changed to allow arbitrary covariances
511  information().setIdentity();
512  return true;
513  }
Eigen::Matrix< double, 2, 1, Eigen::ColMajor > Vector2D
Definition: eigen_types.h:45
virtual void setMeasurement(const Measurement &m)
Definition: base_edge.h:76
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Definition: base_edge.h:67
bool g2o::EdgeProjectP2MC_Intrinsics::write ( std::ostream &  os) const
virtual

write the vertex to a stream

Implements g2o::OptimizableGraph::Edge.

Definition at line 515 of file types_sba.cpp.

References g2o::BaseEdge< D, Vector2D >::measurement().

516  {
517  for (int i=0; i<2; i++)
518  os << measurement()[i] << " ";
519  return os.good();
520  }
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
Definition: base_edge.h:75

The documentation for this class was generated from the following files: