Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
icl::io::IntrinsicCalibrator Class Reference

#include <IntrinsicCalibrator.h>

Inheritance diagram for icl::io::IntrinsicCalibrator:
icl::utils::Uncopyable

List of all members.

Classes

struct  CalibrationData
struct  Result
 Simple struct for handle result of computation of intrinsics. More...

Public Types

typedef math::FixedMatrix
< double, 1, 2 > 
Pos2D
typedef utils::Array2D< Pos2DDetectedGrid

Public Member Functions

 IntrinsicCalibrator (unsigned int boardWidth=6, unsigned int boardHeight=9, unsigned int boardCount=8, unsigned int imageWidth=640, unsigned int imageHeight=480)
 Constructs a new object of this class for computation of intrinc parameters.
 ~IntrinsicCalibrator ()
 Destructor.
Result calibrate (const math::DynMatrix< icl64f > &impoints, const math::DynMatrix< icl64f > &worldpoints)
 calibrates the camera
void saveIntrinsics (const std::string &filename)
 saves computed/current intrinsics to xml-file
void loadIntrinsics (const std::string &filename)
 loads intrincs from xml-file
void resetData (unsigned int boardWidth, unsigned int boardHeight, unsigned int boardCount, unsigned int imageWidth, unsigned int imageHeight)
 resets data to compute new intrinsics with
Result getResult () const
 return the result of computation

Static Public Member Functions

static Result optimize (const CalibrationData &data)
 computes the calibration for given CalibrationData

Private Member Functions

void rigid_motion (const math::DynMatrix< icl64f > &X, const math::DynMatrix< icl64f > &om, const math::DynMatrix< icl64f > &T, math::DynMatrix< icl64f > &Y, math::DynMatrix< icl64f > &dYdom, math::DynMatrix< icl64f > &dYdT)
 Computes the rigid motion transformation Y = R*X+T.
void project_points2 (const math::DynMatrix< icl64f > &X, const math::DynMatrix< icl64f > &om, const math::DynMatrix< icl64f > &T, const math::DynMatrix< icl64f > &f, const math::DynMatrix< icl64f > &c, const math::DynMatrix< icl64f > &k, const double alpha, math::DynMatrix< icl64f > &xp, math::DynMatrix< icl64f > &dxpdom, math::DynMatrix< icl64f > &dxpdT, math::DynMatrix< icl64f > &dxpdf, math::DynMatrix< icl64f > &dxpdc, math::DynMatrix< icl64f > &dxpdk, math::DynMatrix< icl64f > &dxpdalpha)
 Projects a 3D structure onto the image plane.
void comp_distortion_oulu (const math::DynMatrix< icl64f > xd, const math::DynMatrix< icl64f > k, math::DynMatrix< icl64f > &x)
 Compensates for radial and tangential distortion (Model From Oulu university)
void compute_homography (const math::DynMatrix< icl64f > &m, const math::DynMatrix< icl64f > &M, math::DynMatrix< icl64f > &H)
 Computes the planar homography between the point coordinates on the plane (M) and the image point coordinates (m).
void optimize (const math::DynMatrix< icl64f > &impoints, const math::DynMatrix< icl64f > &worldPoints, double *params)
 Levenberg-Marquardt sparse algorithm optimizes all parameters.
void init_intrinsic_param (const math::DynMatrix< icl64f > &x, const math::DynMatrix< icl64f > &X, math::DynMatrix< icl64f > &fc, math::DynMatrix< icl64f > &cc, math::DynMatrix< icl64f > &kc, double &alpha_c)
 Initialization of the intrinsic parameters.
void comp_ext_calib (const math::DynMatrix< icl64f > &x_kk, const math::DynMatrix< icl64f > &X_kk, const math::DynMatrix< icl64f > &fc, const math::DynMatrix< icl64f > &cc, const math::DynMatrix< icl64f > &kc, const double alpha_c, const double thresh_cond, math::DynMatrix< icl64f > &omckk, math::DynMatrix< icl64f > &Tckk, math::DynMatrix< icl64f > &Rckk)
 Computes the extrinsic parameters.
void normalize_pixel (const math::DynMatrix< icl64f > x_kk, const math::DynMatrix< icl64f > fc, const math::DynMatrix< icl64f > cc, const math::DynMatrix< icl64f > kc, const double alpha_c, math::DynMatrix< icl64f > &xn)
 Computes the normalized coordinates xn given the pixel coordinates x_kk and the intrinsic camera parameters fc, cc and kc.
void mean (const math::DynMatrix< icl64f > &x_k, math::DynMatrix< icl64f > &res)
 Computes the mean of each col of x_k.
void rodrigues (const math::DynMatrix< icl64f > &in, math::DynMatrix< icl64f > &out, math::DynMatrix< icl64f > &dout)
 Computes the rodrigues transformation and derivative.
void compute_extrinsic_init (const math::DynMatrix< icl64f > &x_kk, const math::DynMatrix< icl64f > &X_kk, const math::DynMatrix< icl64f > &fc, const math::DynMatrix< icl64f > &cc, const math::DynMatrix< icl64f > &kc, const double &alpha_c, math::DynMatrix< icl64f > &omckk, math::DynMatrix< icl64f > &Tckk, math::DynMatrix< icl64f > &Rckk)
 Computes extrinsic initial parameters.
void compute_extrinsic_refine (const math::DynMatrix< icl64f > &omc_init, const math::DynMatrix< icl64f > &Tc_init, const math::DynMatrix< icl64f > &x_kk, const math::DynMatrix< icl64f > &X_kk, const math::DynMatrix< icl64f > &fc, const math::DynMatrix< icl64f > &cc, const math::DynMatrix< icl64f > &kc, const double alpha_c, const int MaxIter, double thresh_cond, math::DynMatrix< icl64f > &omckk, math::DynMatrix< icl64f > &Tckk, math::DynMatrix< icl64f > &Rckk, math::DynMatrix< icl64f > &JJ)
 optimizes precomputed extrinsic parameters

Private Attributes

Data * m_data
Result m_calres
 struct for handling result of computation

Detailed Description

This class implements the image undistortion procedure. It is a reimplementation from the matlab toolbox Pass in data where world and image points corresponds to each other in layout or use the optimze call where world points are generated automatically and layout of image points must be rowwise.


Member Typedef Documentation


Constructor & Destructor Documentation

icl::io::IntrinsicCalibrator::IntrinsicCalibrator ( unsigned int  boardWidth = 6,
unsigned int  boardHeight = 9,
unsigned int  boardCount = 8,
unsigned int  imageWidth = 640,
unsigned int  imageHeight = 480 
)

Constructs a new object of this class for computation of intrinc parameters.

Parameters:
boardWidththe width of the chessboard
boardHeightthe height of the chessboard
boardCountthe number of board for computations
imageWidththe imagewidth
imageHeightthe imageheight

Destructor.


Member Function Documentation

Result icl::io::IntrinsicCalibrator::calibrate ( const math::DynMatrix< icl64f > &  impoints,
const math::DynMatrix< icl64f > &  worldpoints 
)

calibrates the camera

Since for each image the worldcoordinates are/look exactly the same, just pass the worldcoordinates for the first image. This will be used for all computations.

Parameters:
impointsimage coordinates
worldpointscoordinates for the first image, sorting depends on image coordinates

Compensates for radial and tangential distortion (Model From Oulu university)

Parameters:
xddistorted, normalized image coordinates
kdistortion coefficients
xundistorted, normalized image coordinates
void icl::io::IntrinsicCalibrator::comp_ext_calib ( const math::DynMatrix< icl64f > &  x_kk,
const math::DynMatrix< icl64f > &  X_kk,
const math::DynMatrix< icl64f > &  fc,
const math::DynMatrix< icl64f > &  cc,
const math::DynMatrix< icl64f > &  kc,
const double  alpha_c,
const double  thresh_cond,
math::DynMatrix< icl64f > &  omckk,
math::DynMatrix< icl64f > &  Tckk,
math::DynMatrix< icl64f > &  Rckk 
) [private]

Computes the extrinsic parameters.

Parameters:
x_kkimage coordinates
X_kkworld coordinates
fcfocal length
ccprincipal point
kcdistortion coefficients
alpha_cthe skew
thresh_condnumber of iterations for optimization
omckkrotation vector
Tckktranslation vector
Rckkrotation matrix
void icl::io::IntrinsicCalibrator::compute_extrinsic_init ( const math::DynMatrix< icl64f > &  x_kk,
const math::DynMatrix< icl64f > &  X_kk,
const math::DynMatrix< icl64f > &  fc,
const math::DynMatrix< icl64f > &  cc,
const math::DynMatrix< icl64f > &  kc,
const double &  alpha_c,
math::DynMatrix< icl64f > &  omckk,
math::DynMatrix< icl64f > &  Tckk,
math::DynMatrix< icl64f > &  Rckk 
) [private]

Computes extrinsic initial parameters.

Parameters:
x_kkimage coordinates
X_kkworld coordinates
fcfocal length
ccprincipal point
kcdistortion coefficients
alpha_cskew
omckkrotation vector
Tckk,:translation vector
Rckk,:rotation matrix
void icl::io::IntrinsicCalibrator::compute_extrinsic_refine ( const math::DynMatrix< icl64f > &  omc_init,
const math::DynMatrix< icl64f > &  Tc_init,
const math::DynMatrix< icl64f > &  x_kk,
const math::DynMatrix< icl64f > &  X_kk,
const math::DynMatrix< icl64f > &  fc,
const math::DynMatrix< icl64f > &  cc,
const math::DynMatrix< icl64f > &  kc,
const double  alpha_c,
const int  MaxIter,
double  thresh_cond,
math::DynMatrix< icl64f > &  omckk,
math::DynMatrix< icl64f > &  Tckk,
math::DynMatrix< icl64f > &  Rckk,
math::DynMatrix< icl64f > &  JJ 
) [private]

optimizes precomputed extrinsic parameters

Computes the planar homography between the point coordinates on the plane (M) and the image point coordinates (m).

Parameters:
mhomogeneous image coordinates
Mhomogeneous world coordinates
HHomography matrix

return the result of computation

void icl::io::IntrinsicCalibrator::init_intrinsic_param ( const math::DynMatrix< icl64f > &  x,
const math::DynMatrix< icl64f > &  X,
math::DynMatrix< icl64f > &  fc,
math::DynMatrix< icl64f > &  cc,
math::DynMatrix< icl64f > &  kc,
double &  alpha_c 
) [private]

Initialization of the intrinsic parameters.

Parameters:
ximages coordinate
Xworld coordinates
fcfocal length
ccprincipal point coordinates
kcdistortion coefficients
alpha_c,:skew coefficient
void icl::io::IntrinsicCalibrator::loadIntrinsics ( const std::string &  filename)

loads intrincs from xml-file

Parameters:
filenamename of xml-file to load
void icl::io::IntrinsicCalibrator::mean ( const math::DynMatrix< icl64f > &  x_k,
math::DynMatrix< icl64f > &  res 
) [private]

Computes the mean of each col of x_k.

If x_k is is rowvector the mean of the rowvector is computed.

Parameters:
x_kInputmatrix
resresultmatrix
void icl::io::IntrinsicCalibrator::normalize_pixel ( const math::DynMatrix< icl64f x_kk,
const math::DynMatrix< icl64f fc,
const math::DynMatrix< icl64f cc,
const math::DynMatrix< icl64f kc,
const double  alpha_c,
math::DynMatrix< icl64f > &  xn 
) [private]

Computes the normalized coordinates xn given the pixel coordinates x_kk and the intrinsic camera parameters fc, cc and kc.

Parameters:
x_kkimage coordinates
fcfocal length
ccprincipal point
kcdistortion coefficients
alpha_cskew
xnnormalized image coordinates
void icl::io::IntrinsicCalibrator::optimize ( const math::DynMatrix< icl64f > &  impoints,
const math::DynMatrix< icl64f > &  worldPoints,
double *  params 
) [private]

Levenberg-Marquardt sparse algorithm optimizes all parameters.

Parameters:
impointsimage coordinates
worldPointsworld coordinates
paramsparameters to be optimized

computes the calibration for given CalibrationData

Parameters:
datacontains detected grids for calibration
void icl::io::IntrinsicCalibrator::project_points2 ( const math::DynMatrix< icl64f > &  X,
const math::DynMatrix< icl64f > &  om,
const math::DynMatrix< icl64f > &  T,
const math::DynMatrix< icl64f > &  f,
const math::DynMatrix< icl64f > &  c,
const math::DynMatrix< icl64f > &  k,
const double  alpha,
math::DynMatrix< icl64f > &  xp,
math::DynMatrix< icl64f > &  dxpdom,
math::DynMatrix< icl64f > &  dxpdT,
math::DynMatrix< icl64f > &  dxpdf,
math::DynMatrix< icl64f > &  dxpdc,
math::DynMatrix< icl64f > &  dxpdk,
math::DynMatrix< icl64f > &  dxpdalpha 
) [private]

Projects a 3D structure onto the image plane.

Parameters:
X3D world coordinates
omrotation vector
Ttranslation vector
ffocal length
cprincipal point
kdistortion coefficients
alphaskew
xpProjected pixel coordinates (2xN matrix for N points)
dxpdomDerivative of xp with respect to om
dxpdTDerivative of xp with respect to T
dxpdfDerivative of xp with respect to f
dxpdcDerivative of xp with respect to c
dxpdkDerivative of xp with respect to k
dxpdalphaDerivative of xp with respect to alpha
void icl::io::IntrinsicCalibrator::resetData ( unsigned int  boardWidth,
unsigned int  boardHeight,
unsigned int  boardCount,
unsigned int  imageWidth,
unsigned int  imageHeight 
)

resets data to compute new intrinsics with

Parameters:
boardWidththe new width of the chessboard
boardHeightthe new height of the chessboard
boardCountthe new number of board for computations
imageWidththe new imagewidth
imageHeightthe new imageheight
void icl::io::IntrinsicCalibrator::rigid_motion ( const math::DynMatrix< icl64f > &  X,
const math::DynMatrix< icl64f > &  om,
const math::DynMatrix< icl64f > &  T,
math::DynMatrix< icl64f > &  Y,
math::DynMatrix< icl64f > &  dYdom,
math::DynMatrix< icl64f > &  dYdT 
) [private]

Computes the rigid motion transformation Y = R*X+T.

Parameters:
X3D structure in the world coordinates
omrotation vector
Ttranslation vector
Y3D coordinates of the structure points in the camera frame
dYdomDerivative of Y with respect to om
dYdTDerivative of Y with respect to T
void icl::io::IntrinsicCalibrator::rodrigues ( const math::DynMatrix< icl64f > &  in,
math::DynMatrix< icl64f > &  out,
math::DynMatrix< icl64f > &  dout 
) [private]

Computes the rodrigues transformation and derivative.

void icl::io::IntrinsicCalibrator::saveIntrinsics ( const std::string &  filename)

saves computed/current intrinsics to xml-file

Parameters:
filenamename of xml-file for saving

Member Data Documentation

struct for handling result of computation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines