Image Component Library (ICL)
|
#include <IntrinsicCalibrator.h>
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< Pos2D > | DetectedGrid |
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 |
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.
typedef math::FixedMatrix<double,1,2> icl::io::IntrinsicCalibrator::Pos2D |
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.
boardWidth | the width of the chessboard |
boardHeight | the height of the chessboard |
boardCount | the number of board for computations |
imageWidth | the imagewidth |
imageHeight | the imageheight |
Destructor.
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.
impoints | image coordinates |
worldpoints | coordinates for the first image, sorting depends on image coordinates |
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)
xd | distorted, normalized image coordinates |
k | distortion coefficients |
x | undistorted, 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.
x_kk | image coordinates |
X_kk | world coordinates |
fc | focal length |
cc | principal point |
kc | distortion coefficients |
alpha_c | the skew |
thresh_cond | number of iterations for optimization |
omckk | rotation vector |
Tckk | translation vector |
Rckk | rotation 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.
x_kk | image coordinates |
X_kk | world coordinates |
fc | focal length |
cc | principal point |
kc | distortion coefficients |
alpha_c | skew |
omckk | rotation 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
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).
m | homogeneous image coordinates |
M | homogeneous world coordinates |
H | Homography matrix |
Result icl::io::IntrinsicCalibrator::getResult | ( | ) | const [inline] |
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.
x | images coordinate |
X | world coordinates |
fc | focal length |
cc | principal point coordinates |
kc | distortion coefficients |
alpha_c,: | skew coefficient |
void icl::io::IntrinsicCalibrator::loadIntrinsics | ( | const std::string & | filename | ) |
loads intrincs from xml-file
filename | name 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.
x_k | Inputmatrix |
res | resultmatrix |
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.
x_kk | image coordinates |
fc | focal length |
cc | principal point |
kc | distortion coefficients |
alpha_c | skew |
xn | normalized 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.
impoints | image coordinates |
worldPoints | world coordinates |
params | parameters to be optimized |
static Result icl::io::IntrinsicCalibrator::optimize | ( | const CalibrationData & | data | ) | [static] |
computes the calibration for given CalibrationData
data | contains 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.
X | 3D world coordinates |
om | rotation vector |
T | translation vector |
f | focal length |
c | principal point |
k | distortion coefficients |
alpha | skew |
xp | Projected pixel coordinates (2xN matrix for N points) |
dxpdom | Derivative of xp with respect to om |
dxpdT | Derivative of xp with respect to T |
dxpdf | Derivative of xp with respect to f |
dxpdc | Derivative of xp with respect to c |
dxpdk | Derivative of xp with respect to k |
dxpdalpha | Derivative 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
boardWidth | the new width of the chessboard |
boardHeight | the new height of the chessboard |
boardCount | the new number of board for computations |
imageWidth | the new imagewidth |
imageHeight | the 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.
X | 3D structure in the world coordinates |
om | rotation vector |
T | translation vector |
Y | 3D coordinates of the structure points in the camera frame |
dYdom | Derivative of Y with respect to om |
dYdT | Derivative 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
filename | name of xml-file for saving |
Result icl::io::IntrinsicCalibrator::m_calres [private] |
struct for handling result of computation
Data* icl::io::IntrinsicCalibrator::m_data [private] |