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

This class represent the physical device which take the pictures. It is not related to a 3D position which is the role of the PointOfView class. The role of the class is to store only device related informations like intra parameters, radial and tangential distotion. This abstract class is not related to a type of camera ( fish eyes... ) More...

#include <Camera.h>

Inheritance diagram for OpencvSfM::Camera:
OpencvSfM::CameraPinhole OpencvSfM::CameraPinholeDistor

List of all members.

Public Member Functions

virtual uchar getNbMissingParams () const
virtual const std::vector
< PointOfView * > 
getRelatedViews () const
int getImgWidth () const
int getImgHeight () const
virtual std::vector< cv::Vec4d > convertFromImageTo3Dray (std::vector< cv::Vec3d > points)=0
virtual std::vector< cv::Vec2d > pixelToNormImageCoordinates (std::vector< cv::Vec2d > points) const =0
virtual std::vector< cv::Vec2d > normImageToPixelCoordinates (std::vector< cv::Vec2d > points) const =0
virtual cv::Mat getIntraMatrix () const
virtual void updateIntrinsic (double *values, uchar nbVal, bool add_to_intra)
virtual double getFocal () const =0
virtual void write (cv::FileStorage &fs) const =0

Static Public Member Functions

static cv::Ptr< Cameraread (const cv::FileNode &node)

Protected Member Functions

 Camera (int img_w=640, int img_h=480)

Protected Attributes

int img_width
 Width of the images taken by this camera.
int img_height
 Height of the images taken by this camera.
std::vector< PointOfView * > pointsOfView_
 vector of the differents positions of the camera.

Friends

class PointOfView

Detailed Description

This class represent the physical device which take the pictures. It is not related to a 3D position which is the role of the PointOfView class. The role of the class is to store only device related informations like intra parameters, radial and tangential distotion. This abstract class is not related to a type of camera ( fish eyes... )

This class can be used to store device related informations like intra parameters, radial and tangential distortion. If we use the so-called pinhole camera model, 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} \]

Additionnal radial and tangeancial distortion are modelized like this:

\[ \begin{array}{l} \vspace{10pt} x'' = x' \dfrac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2( r^2 + 2 x'^2 ) \\ \vspace{10pt} y'' = y' \dfrac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 ( r^2 + 2 y'^2 ) + 2 p_2 x' y' \\ \text{where} \quad r^2 = x'^2 + y'^2 \\ u = f_x*x'' + c_x \\ v = f_y*y'' + c_y \end{array} \]

radial_dist_ can be used to store $k_1$ to $k_6$ tangential_dist_ can be used to store $p_1$ and $p_2$

So this class is devoted to the conversion between 2D points from pixel image coordinates and 2D points in normalized image coordinates, or ray projection using intra parameters.

Definition at line 48 of file Camera.h.


Constructor & Destructor Documentation

OpencvSfM::Camera::Camera ( int  img_w = 640,
int  img_h = 480 
) [protected]

As this class is virtual, we can't create a new empty camera...

Parameters:
img_wwidth of images the camera produce
img_hheight of images the camera produce

Definition at line 10 of file Camera.cpp.


Member Function Documentation

virtual std::vector<cv::Vec4d> OpencvSfM::Camera::convertFromImageTo3Dray ( std::vector< cv::Vec3d >  points) [pure virtual]

This method can transform points from image to 3D rays ( homogeneous coordinates )

Implemented in OpencvSfM::CameraPinholeDistor, and OpencvSfM::CameraPinhole.

virtual double OpencvSfM::Camera::getFocal ( ) const [pure virtual]

This method is useful to get the focal from Intrinsic matrix:

Returns:
focal lenght

Implemented in OpencvSfM::CameraPinhole.

int OpencvSfM::Camera::getImgHeight ( ) const [inline]

get the height of the images taken by this camera

Definition at line 84 of file Camera.h.

int OpencvSfM::Camera::getImgWidth ( ) const [inline]

get the width of the images taken by this camera

Definition at line 80 of file Camera.h.

virtual cv::Mat OpencvSfM::Camera::getIntraMatrix ( ) const [inline, virtual]

This method return the intra parameters of the camera

Returns:
Matrix K of intra parameters

Reimplemented in OpencvSfM::CameraPinhole.

Definition at line 108 of file Camera.h.

virtual uchar OpencvSfM::Camera::getNbMissingParams ( ) const [inline, virtual]

use this function to know which parameters are missing

Returns:
numbers of parameters needed for this camera

Reimplemented in OpencvSfM::CameraPinholeDistor, and OpencvSfM::CameraPinhole.

Definition at line 69 of file Camera.h.

virtual const std::vector<PointOfView*> OpencvSfM::Camera::getRelatedViews ( ) const [inline, virtual]

use this function to know which parameters are missing

Returns:
numbers of parameters needed for this camera

Definition at line 74 of file Camera.h.

virtual std::vector<cv::Vec2d> OpencvSfM::Camera::normImageToPixelCoordinates ( std::vector< cv::Vec2d >  points) const [pure virtual]

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

Parameters:
points2D points in normalized image homogeneous coordinates.
Returns:
2D points in pixel image coordinates.

Implemented in OpencvSfM::CameraPinholeDistor, and OpencvSfM::CameraPinhole.

virtual std::vector<cv::Vec2d> OpencvSfM::Camera::pixelToNormImageCoordinates ( std::vector< cv::Vec2d >  points) const [pure virtual]

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

Parameters:
points2D points in pixel image homogeneous coordinates.
Returns:
2D points in normalized image homogeneous coordinates.

Implemented in OpencvSfM::CameraPinholeDistor, and OpencvSfM::CameraPinhole.

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

Create a new camera from a YAML file.

Parameters:
nodePreviously opened YAML file node

Reimplemented in OpencvSfM::CameraPinhole, and OpencvSfM::CameraPinholeDistor.

Definition at line 20 of file Camera.cpp.

virtual void OpencvSfM::Camera::updateIntrinsic ( double *  values,
uchar  nbVal,
bool  add_to_intra 
) [inline, virtual]

This method modify the intra parameters of the camera

Parameters:
valuesarray of intra parameters (order corresponds to SBA) K( 0,0 ) -> values[0] K( 2,0 ) -> values[1], K( 2,1 ) -> values[2], K( 1,1 )/K( 0,0 ) -> values[3] K( 1,0 ) -> values[4]
nbValnb values into array...
add_to_intraif true, the vector is the delta to apply to each intra values

Reimplemented in OpencvSfM::CameraPinholeDistor, and OpencvSfM::CameraPinhole.

Definition at line 122 of file Camera.h.

virtual void OpencvSfM::Camera::write ( cv::FileStorage &  fs) const [pure virtual]

Save the camera intra parameters into a YAML file.

Parameters:
fsPreviously opened YAML file node

Implemented in OpencvSfM::CameraPinhole, and OpencvSfM::CameraPinholeDistor.


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