Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
icl::io::IntrinsicCalibrator Class Reference

#include <IntrinsicCalibrator.h>

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

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. More...
 
 ~IntrinsicCalibrator ()
 Destructor. More...
 
Result calibrate (const math::DynMatrix< icl64f > &impoints, const math::DynMatrix< icl64f > &worldpoints)
 calibrates the camera More...
 
void saveIntrinsics (const std::string &filename)
 saves computed/current intrinsics to xml-file More...
 
void loadIntrinsics (const std::string &filename)
 loads intrincs from xml-file More...
 
void resetData (unsigned int boardWidth, unsigned int boardHeight, unsigned int boardCount, unsigned int imageWidth, unsigned int imageHeight)
 resets data to compute new intrinsics with More...
 
Result getResult () const
 return the result of computation More...
 

Static Public Member Functions

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

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. More...
 
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. More...
 
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) More...
 
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). More...
 
void optimize (const math::DynMatrix< icl64f > &impoints, const math::DynMatrix< icl64f > &worldPoints, double *params)
 Levenberg-Marquardt sparse algorithm optimizes all parameters. More...
 
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. More...
 
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. More...
 
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. More...
 
void mean (const math::DynMatrix< icl64f > &x_k, math::DynMatrix< icl64f > &res)
 Computes the mean of each col of x_k. More...
 
void rodrigues (const math::DynMatrix< icl64f > &in, math::DynMatrix< icl64f > &out, math::DynMatrix< icl64f > &dout)
 Computes the rodrigues transformation and derivative. More...
 
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. More...
 
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 More...
 

Private Attributes

Data * m_data
 
Result m_calres
 struct for handling result of computation More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

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

◆ DetectedGrid

◆ Pos2D

Constructor & Destructor Documentation

◆ IntrinsicCalibrator()

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

◆ ~IntrinsicCalibrator()

icl::io::IntrinsicCalibrator::~IntrinsicCalibrator ( )

Destructor.

Member Function Documentation

◆ calibrate()

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

◆ comp_distortion_oulu()

void icl::io::IntrinsicCalibrator::comp_distortion_oulu ( const math::DynMatrix< icl64f xd,
const math::DynMatrix< icl64f k,
math::DynMatrix< icl64f > &  x 
)
private

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

Parameters
xddistorted, normalized image coordinates
kdistortion coefficients
xundistorted, normalized image coordinates

◆ comp_ext_calib()

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

◆ compute_extrinsic_init()

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
Tckktranslation vector
Rckkrotation matrix

◆ compute_extrinsic_refine()

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

◆ compute_homography()

void icl::io::IntrinsicCalibrator::compute_homography ( const math::DynMatrix< icl64f > &  m,
const math::DynMatrix< icl64f > &  M,
math::DynMatrix< icl64f > &  H 
)
private

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

◆ getResult()

Result icl::io::IntrinsicCalibrator::getResult ( ) const
inline

return the result of computation

◆ init_intrinsic_param()

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_cskew coefficient

◆ loadIntrinsics()

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

loads intrincs from xml-file

Parameters
filenamename of xml-file to load

◆ mean()

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

◆ normalize_pixel()

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

◆ optimize() [1/2]

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

◆ optimize() [2/2]

static Result icl::io::IntrinsicCalibrator::optimize ( const CalibrationData data)
static

computes the calibration for given CalibrationData

Parameters
datacontains detected grids for calibration

◆ project_points2()

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

◆ resetData()

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

◆ rigid_motion()

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

◆ rodrigues()

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.

◆ saveIntrinsics()

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

◆ m_calres

Result icl::io::IntrinsicCalibrator::m_calres
private

struct for handling result of computation

◆ m_data

Data* icl::io::IntrinsicCalibrator::m_data
private

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