GSoC2011SfM  0.1
Google Summer of Code 2011: Structure from motion
Public Member Functions | Static Public Member Functions | Protected Attributes
OpencvSfM::CameraPinhole 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 intra parameters ( without radial distortion ) More...

#include <CameraPinhole.h>

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

List of all members.

Public Member Functions

 CameraPinhole (cv::Mat intra_params=cv::Mat::eye(3, 3, CV_64F), int img_w=640, int img_h=480, unsigned char wantedEstimation=FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM)
 CameraPinhole (const std::vector< std::vector< cv::Point3f > > &objectPoints, const std::vector< std::vector< cv::Point2f > > &imagePoints, cv::Size imageSize, double aspectRatio=1., int img_w=640, int img_h=480, unsigned char wantedEstimation=FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM)
virtual uchar getNbMissingParams () const
virtual void updateIntrinsic (double *values, uchar nbVal, bool add_to_intra)
void updateIntrinsicMatrix (cv::Mat newParams, unsigned char intraValues=FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM)
virtual std::vector< cv::Vec4d > convertFromImageTo3Dray (std::vector< cv::Vec3d > points)
virtual std::vector< cv::Vec2d > pixelToNormImageCoordinates (std::vector< cv::Vec2d > points) const
virtual std::vector< cv::Vec2d > normImageToPixelCoordinates (std::vector< cv::Vec2d > points) const
virtual cv::Mat getIntraMatrix () const
virtual double getFocal () const
virtual void write (cv::FileStorage &fs) const

Static Public Member Functions

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

Protected Attributes

cv::Mat intra_params_
 store intra parameters( 3*3 matrix ). This matrix contains focal informations, principal point coordinates and skew of axis
cv::Mat inv_intra_params_
 This is the inverse transformation of intra_params_. Used to speed up calculus...
unsigned char estimation_needed_

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 intra parameters ( without radial distortion )

So this class is devoted to the conversion between 3D points ( using camera coordinate ) and 2D points ( using image coordinate ) using the methods convertFromImageTo3Dray or convertFrom3DToImage

Definition at line 24 of file CameraPinhole.h.


Constructor & Destructor Documentation

OpencvSfM::CameraPinhole::CameraPinhole ( cv::Mat  intra_params = cv::Mat::eye( 3, 3, CV_64F ),
int  img_w = 640,
int  img_h = 480,
unsigned char  wantedEstimation = FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM 
)

Constructor with ( or not ) intra parameters.

Parameters:
intra_paramsmatrix of intra parameters ( 3*3 )
img_wwidth of images the camera produce
img_hheight of images the camera produce
wantedEstimationvalues which need an estimation

Definition at line 12 of file CameraPinhole.cpp.

Referenced by read().

OpencvSfM::CameraPinhole::CameraPinhole ( const std::vector< std::vector< cv::Point3f > > &  objectPoints,
const std::vector< std::vector< cv::Point2f > > &  imagePoints,
cv::Size  imageSize,
double  aspectRatio = 1.,
int  img_w = 640,
int  img_h = 480,
unsigned char  wantedEstimation = FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM 
)

Constructor where initial camera matrix is computed from the 3D-2D point correspondences. Currently, the function only supports planar calibration patterns, i.e. patterns where each object point has z-coordinate =0.

Parameters:
objectPointsThe vector of vectors of the object points. See http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html#cv-calibratecamera
imagePointsThe vector of vectors of the corresponding image points. See http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html#cv-calibratecamera
imageSizeThe image size in pixels; used to initialize the principal point
aspectRatioIf it is zero or negative, both $f_x$ and $f_y$ are estimated independently. Otherwise $f_x=f_y * aspectRatio$
img_wwidth of images the camera produce
img_hheight of images the camera produce
wantedEstimationvalues which need an estimation

Definition at line 24 of file CameraPinhole.cpp.


Member Function Documentation

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

This method can transform points from image to 3D rays

Implements OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 112 of file CameraPinhole.cpp.

double OpencvSfM::CameraPinhole::getFocal ( ) const [virtual]

This method retrive the focal from Intrinsic matrix. It's not using pixel reference but using camera reference!

Returns:
focal lenght

Implements OpencvSfM::Camera.

Definition at line 167 of file CameraPinhole.cpp.

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

This method return the intra parameters of the camera

Returns:
Matrix K of intra parameters

Reimplemented from OpencvSfM::Camera.

Definition at line 108 of file CameraPinhole.h.

Referenced by OpencvSfM::CameraPinholeDistor::read().

uchar OpencvSfM::CameraPinhole::getNbMissingParams ( ) const [virtual]

use this function to know which parameters are missing

Returns:
numbers of parameters needed for this camera

Reimplemented from OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 42 of file CameraPinhole.cpp.

vector< Vec2d > OpencvSfM::CameraPinhole::normImageToPixelCoordinates ( std::vector< cv::Vec2d >  points) const [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.

Implements OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 148 of file CameraPinhole.cpp.

vector< Vec2d > OpencvSfM::CameraPinhole::pixelToNormImageCoordinates ( std::vector< cv::Vec2d >  points) const [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.

Implements OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 118 of file CameraPinhole.cpp.

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

Create a new camera from a YAML file.

Parameters:
nodePreviously opened YAML file node

Reimplemented from OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 199 of file CameraPinhole.cpp.

Referenced by OpencvSfM::PointOfView::read().

void OpencvSfM::CameraPinhole::updateIntrinsic ( double *  values,
uchar  nbVal,
bool  add_to_intra 
) [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 from OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 54 of file CameraPinhole.cpp.

void OpencvSfM::CameraPinhole::updateIntrinsicMatrix ( cv::Mat  newParams,
unsigned char  intraValues = FOCAL_PARAM|SKEW_PARAM|PRINCIPAL_POINT_PARAM 
)

this method can be used to update the intra parameters.

Parameters:
newParamsmatrix of new parameters ( 3*3 )
intraValuesvalues which are useful in matrix

Definition at line 81 of file CameraPinhole.cpp.

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

Save the camera intra parameters into a YAML file.

Parameters:
fsPreviously opened YAML file node

Implements OpencvSfM::Camera.

Reimplemented in OpencvSfM::CameraPinholeDistor.

Definition at line 219 of file CameraPinhole.cpp.


Member Data Documentation

This attribut is used to know what we should estimate... Example: if equal to 0, nothing should be estimated... If equal to 3, focal and skew should be estimated ( FOCAL_PARAM + SKEW_PARAM )

Definition at line 34 of file CameraPinhole.h.

Referenced by CameraPinhole(), getNbMissingParams(), OpencvSfM::CameraPinholeDistor::getNbMissingParams(), OpencvSfM::CameraPinholeDistor::updateDistortionParameters(), and write().


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