GSoC2011SfM  0.1
Google Summer of Code 2011: Structure from motion
Public Member Functions | Static Public Member Functions | Protected Attributes
OpencvSfM::PointOfView Class Reference

This class represent the 3D position of the device which take the pictures. The role of the class is to store everything related to the filed of view: picture, 3D position, points, matches and 3D points. More...

#include <PointOfView.h>

List of all members.

Public Member Functions

 PointOfView (cv::Ptr< Camera > device, cv::Mat rotation=cv::Mat::eye(3, 3, CV_64F), cv::Vec3d translation=cv::Vec3d(0.0, 0.0, 0.0))
 PointOfView (cv::Mat projection_matrix)
 PointOfView (const PointOfView &ref)
virtual ~PointOfView (void)
cv::Ptr< CameragetIntraParameters () const
uchar getNbMissingParams () const
virtual std::vector< cv::Vec2d > project3DPointsIntoImage (std::vector< TrackOfPoints > points) const
virtual std::vector< cv::Vec2d > project3DPointsIntoImage (std::vector< cv::Vec3d > points) const
virtual cv::Vec2d project3DPointIntoImage (cv::Vec3d point) const
virtual bool pointInFrontOfCamera (cv::Vec4d point) const
virtual cv::Mat getProjectionMatrix () const
cv::Mat getRotationMatrix () const
virtual void setRotationMatrix (cv::Mat newRot)
cv::Mat getTranslationVector () const
void setTranslationVector (cv::Mat newVect)
void rotationAroundX (double angle)
void rotationAroundY (double angle)
void rotationAroundZ (double angle)
void print (std::ostream &flux) const

Static Public Member Functions

static cv::Ptr< PointOfViewread (const cv::FileNode &node)
static void write (cv::FileStorage &fs, const PointOfView &points)

Protected Attributes

cv::Mat rotation_
 Rotation matrix R ( data is stored into projection_matrix_ )
cv::Mat translation_
 Translation vector t ( Matrix instead of vector because data is stored into projection_matrix_ )
cv::Mat projection_matrix_
 redundancy but speed improvement
cv::Ptr< Cameradevice_
 intra parameters and distortion coefs
unsigned char config_
 This attribut is used to know what we should estimate... If equal to 0, nothing should be estimated...

Detailed Description

This class represent the 3D position of the device which take the pictures. The role of the class is to store everything related to the filed of view: picture, 3D position, points, matches and 3D points.

We use the so-called pinhole camera model. That is, a scene view is formed by projecting 3D points into the image plane using a perspective transformation. Usual notation says that a point [ u,v ] from an image is related to the point [ X,Y,Z ] using the following notation :

\[ s \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix}f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} r_{11} & r_{12} & r_{13} & t_1 \\ r_{21} & r_{22} & r_{23} & t_2 \\ r_{31} & r_{32} & r_{33} & t_3 \end{bmatrix} \begin{bmatrix} X \\ Y \\ Z \\ 1 \end{bmatrix} \]

This leads to the following relation between local coordinates and global ones:

\[ \begin{array}{l} \vspace{10pt} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = R \begin{bmatrix} X \\ Y \\ Z \end{bmatrix} + t \\ x' = x/z \\ y' = y/z \vspace{10pt} \end{array} \]

Definition at line 44 of file PointOfView.h.


Constructor & Destructor Documentation

OpencvSfM::PointOfView::PointOfView ( cv::Ptr< Camera device,
cv::Mat  rotation = cv::Mat::eye( 3, 3, CV_64F ),
cv::Vec3d  translation = cv::Vec3d( 0.0,0.0,0.0 ) 
)

To create a point of view, we need two things : a camera, and a point ( with orientation ). Here we give an address of a Camera, and the file name of the picture. If we have more informations, we can use the last parameters...

Parameters:
deviceaddress of existing Camera. This camera can be calibrated or not...
rotationMatrix of the known rotation ( optional )...
translationVector of the known translation ( optional )...

Definition at line 33 of file PointOfView.cpp.

Referenced by read().

OpencvSfM::PointOfView::PointOfView ( cv::Mat  projection_matrix)

To create a point of view using a projection matrix. (will create a Pinhole Camera without distortion parameters) We will extract intra, rotation and translation from this projection matrix.

Parameters:
projection_matrixProjection matrix of the camera

Definition at line 72 of file PointOfView.cpp.

OpencvSfM::PointOfView::PointOfView ( const PointOfView ref)

Copy constructor

Definition at line 55 of file PointOfView.cpp.

OpencvSfM::PointOfView::~PointOfView ( void  ) [virtual]

Destructor of PointOfView, release all vectors... TODO: define how we should release the vectors...

Definition at line 113 of file PointOfView.cpp.


Member Function Documentation

cv::Ptr<Camera> OpencvSfM::PointOfView::getIntraParameters ( ) const [inline]

use this function to get acces to the camera parameters

Returns:
camera matrix

Definition at line 84 of file PointOfView.h.

Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().

uchar OpencvSfM::PointOfView::getNbMissingParams ( ) const

use this function to know which parameters are missing

Returns:
numbers of parameters needed for this camera

Definition at line 132 of file PointOfView.cpp.

cv::Mat OpencvSfM::PointOfView::getProjectionMatrix ( ) const [virtual]

This method return the intra parameters of the camera

Returns:
Matrix K of intra parameters

Definition at line 252 of file PointOfView.cpp.

cv::Mat OpencvSfM::PointOfView::getRotationMatrix ( ) const [inline]

Use this method to get the rotation matrix of this camera

Returns:
rotation matrix of this camera

Definition at line 126 of file PointOfView.h.

Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().

cv::Mat OpencvSfM::PointOfView::getTranslationVector ( ) const [inline]

Use this method to get the translation vector of this camera

Returns:
translation vector of this camera

Definition at line 145 of file PointOfView.h.

Referenced by OpencvSfM::Visualizer::addCamera(), and OpencvSfM::EuclideanEstimator::addNewPointOfView().

bool OpencvSfM::PointOfView::pointInFrontOfCamera ( cv::Vec4d  point) const [virtual]

This method test is 3D point is in front of Camera ( can be view with the camera )

Parameters:
point3D point in world coordinates ( homogeneous, that is 4 values ).
Returns:
true if point can be seen with this point of view

Definition at line 241 of file PointOfView.cpp.

void OpencvSfM::PointOfView::print ( std::ostream &  flux) const

This operator overload allow us to print easily a point of view:

Definition at line 294 of file PointOfView.cpp.

cv::Vec2d OpencvSfM::PointOfView::project3DPointIntoImage ( cv::Vec3d  point) const [virtual]

This method can convert 3D point from world coordinates to 2D point in pixel image coordinates

Parameters:
point3D point in world coordinates.
Returns:
2D point in pixel image coordinates.

Definition at line 142 of file PointOfView.cpp.

std::vector< cv::Vec2d > OpencvSfM::PointOfView::project3DPointsIntoImage ( std::vector< TrackOfPoints points) const [virtual]

This method can convert 3D points from world coordinates to 2D points in pixel image coordinates

Parameters:
points3D points in world coordinates.
Returns:
2D points in pixel image coordinates.

Definition at line 203 of file PointOfView.cpp.

std::vector< cv::Vec2d > OpencvSfM::PointOfView::project3DPointsIntoImage ( std::vector< cv::Vec3d >  points) const [virtual]

This method can convert 3D points from world coordinates to 2D points in pixel image coordinates

Parameters:
points3D points in world coordinates.
Returns:
2D points in pixel image coordinates.

Definition at line 170 of file PointOfView.cpp.

cv::Ptr< PointOfView > OpencvSfM::PointOfView::read ( const cv::FileNode &  node) [static]

Create a new camera's point of view from a YAML file.

Parameters:
nodePreviously opened YAML file node

Definition at line 258 of file PointOfView.cpp.

void OpencvSfM::PointOfView::rotationAroundX ( double  angle) [inline]

Rotate this camera around X axis

Parameters:
angleof rotation

Definition at line 163 of file PointOfView.h.

void OpencvSfM::PointOfView::rotationAroundY ( double  angle) [inline]

Rotate this camera around Y axis

Parameters:
angleof rotation

Definition at line 173 of file PointOfView.h.

void OpencvSfM::PointOfView::rotationAroundZ ( double  angle) [inline]

Rotate this camera around Z axis

Parameters:
angleof rotation

Definition at line 183 of file PointOfView.h.

virtual void OpencvSfM::PointOfView::setRotationMatrix ( cv::Mat  newRot) [inline, virtual]

Use this method to change the rotation matrix of this camera

Parameters:
newRotnew rotation matrix

Definition at line 134 of file PointOfView.h.

void OpencvSfM::PointOfView::setTranslationVector ( cv::Mat  newVect) [inline]

Use this method to change the translation vector of this camera

Parameters:
newVectnew translation vector

Definition at line 153 of file PointOfView.h.

void OpencvSfM::PointOfView::write ( cv::FileStorage &  fs,
const PointOfView points 
) [static]

Save the camera's point of view into a YAML file.

Parameters:
fsPreviously opened YAML file node
pointssequence to save...

Definition at line 286 of file PointOfView.cpp.


The documentation for this class was generated from the following files:
 All Classes Functions Variables