bazar  1.3.1
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members

Calibrates one or more cameras from homographies and 2D/3D correspondances. More...

#include <CamCalibration.h>

Classes

struct  s_struct_camera
 Structure specifying a single camera.
struct  s_struct_homography
 Structure specifying one homography of a single camera.
struct  s_struct_intrinsic
 Structure specifying a camera's intrinsic parameters.
struct  s_struct_optimal
 The optimal structure.
struct  s_struct_plane
 Structure specifying 2D-to-2D correspondances.
struct  s_struct_points
 Transfer structure for AddHomography(). More...
struct  s_struct_solution
 A candidate solution created by the probabilistic filter.

Public Member Functions

 CamCalibration ()
 Constructor of the CamCalibration class.
 ~CamCalibration ()
 Deconstructor of the CamCalibration class.
void AddCamera (int width, int height)
 Add a camera.
bool AddHomography (int c)
 Add an empty homography (without data) to camera c.
bool AddHomography (int c, std::vector< CamCalibration::s_struct_points > p, CvMat *ready)
 Add a homography with data to camera c.
bool StoreHomographiesToFile (char *file_name)
 Stores initial homography structure to file.
bool LoadHomographiesFromFile (char *file_name)
 Loads initial homography structure from file.
bool Calibrate (int p_HomographyNum, int p_PreFilter, int p_Solutions, double p_PreFilter_a, double p_PreFilter_b, double p_PreFilter_c, double p_InitialGuess_a, double p_InitialGuess_b, double p_InitialGuess_c, int p_Iterations, double p_Epsilon, double p_PostFilter)
 Starts the camera calibration process.
void PrintOptimizedResultsToFile1 ()
 Prints resulting matrices seperated to 3 files.
void PrintOptimizedResultsToFile2 (char *file_descriptor, bool create_png=false, char *sequence_descriptor="", char *png_descriptor="", int c_start=0, int h_start=0)
 Prints resulting projection matrices to many separated files.
void PlotPointsToImagesAfterOptimization ()
void ClearAll ()

Static Public Member Functions

static void ExtractRotationTranslationFrom3x4Matrix (CvMat *RotTrans, CvMat *Rot, CvMat *Trans)
 Decomposes RotTrans into Rot and Trans.
static void ComposeRotationTranslationTo3x4Matrix (CvMat *RotTrans, CvMat *Rot, CvMat *Trans)
 Composes Rot and Trans to RotTrans.
static void Mat3x4Mul (CvMat *m_A, CvMat *m_B, CvMat *m_C)
 Multiplies 3x4 matrices m_A and m_B to m_C.
static void Mat3x4Inverse (CvMat *m_A, CvMat *m_B)
 Inverts 3x4 matrix m_A and stores result to m_B.
static void HomogenousNormalizeVector (CvMat *mat)
 Divides mat by its last element.

Friends

struct ProjObs

Detailed Description

Calibrates one or more cameras from homographies and 2D/3D correspondances.

Implements functions to calibrate a set of cameras at one time using planar 2D-2D correspondances. Provides functions to output the resulting matrices including intrinsic and extrinsic camera parameters as well as statistical functions.

See singlecalib.cpp for a single camera simple example, or multicam.cpp for a complete example.

Author
Andreas Geiger
Computer Vision Laboratory, http://cvlab.epfl.ch/
Swiss Federal Institute of Technology, Lausanne
Date
20.02.2006
Examples:
fullcalib.cpp, multicam.cpp, multigl.cpp, and singlecalib.cpp.

Definition at line 37 of file CamCalibration.h.

Constructor & Destructor Documentation

CamCalibration::CamCalibration ( )

Constructor of the CamCalibration class.

Definition at line 84 of file CamCalibration.cpp.

CamCalibration::~CamCalibration ( )

Deconstructor of the CamCalibration class.

The class should be destroyed with the deconstructor after having done its job.

Definition at line 91 of file CamCalibration.cpp.

References ClearAll().

Member Function Documentation

void CamCalibration::AddCamera ( int  width,
int  height 
)

Add a camera.

This function adds a camera with the specified width and height to the CamCalibration class. Before adding a homography you should create the camera. The first added camera is numbered 0, the following with increasing numbers.

Examples:
fullcalib.cpp, multicam.cpp, multigl.cpp, and singlecalib.cpp.

Definition at line 105 of file CamCalibration.cpp.

Referenced by geom_calib_start(), geometric_calibration(), LoadHomographiesFromFile(), and main().

bool CamCalibration::AddHomography ( int  c)

Add an empty homography (without data) to camera c.

This adds an empty homography to the camera specified by c. If the camera does not exist this function returns false, otherwise true. This function should be used if the homographie is not available (i.e. due to too much noise in the picture).

Examples:
fullcalib.cpp, multicam.cpp, multigl.cpp, and singlecalib.cpp.

Definition at line 109 of file CamCalibration.cpp.

Referenced by add_detected_homography(), geom_calib_idle(), geometric_calibration(), and LoadHomographiesFromFile().

bool CamCalibration::AddHomography ( int  c,
std::vector< CamCalibration::s_struct_points p,
CvMat *  ready 
)

Add a homography with data to camera c.

This adds a homography to the camera specified by c. If the camera does not exist this function returns false, otherwise true. The parameter p specifies the array of correspondances described above, n is the corresponcance number and ready specifies a matrix with the homography in OpenCV format. If ready equals NULL the homography is calculated internally by the class. Nevertheless it is recommanded to provide the homography here!

Definition at line 125 of file CamCalibration.cpp.

References cvmSet().

bool CamCalibration::Calibrate ( int  p_HomographyNum,
int  p_PreFilter,
int  p_Solutions,
double  p_PreFilter_a,
double  p_PreFilter_b,
double  p_PreFilter_c,
double  p_InitialGuess_a,
double  p_InitialGuess_b,
double  p_InitialGuess_c,
int  p_Iterations,
double  p_Epsilon,
double  p_PostFilter 
)

Starts the camera calibration process.

After adding all cameras and homographies this function will estimate the intrinsic and extrinsic parameters of the cameras as well as the rotation and translation of the image pattern at every time step. You have to specify a number of parameters here:

  • p_HomographyNum : Maximal number of homographies to use for optimization.
  • p_PreFilter: Filtering method to use: 0=Greedy, 1=Padding, 2=Probabilistic
  • p_PreFilter_a: For Padding filter: Specifies ratio, for Probabilistic filter: specifies weight 1
  • p_PreFilter_b: For Probabilistic filter: specifies weight 2
  • p_PreFilter_c: For Probabilistic filter: specifies weight 3
  • p_InitialGuess_a: Specifies alpha
  • p_InitialGuess_b: Specifies beta
  • p_InitialGuess_c: Specifies gamma
  • p_Iterations: Specifies maximal number of Levenberg-Marquardt iterations
  • p_Epsilon: Specifies maximal accuracy of Levenberg-Marquardt optimization
  • p_PostFilter: Specifies post filter threshold tau

Note: For a more detailed parameter description have a look at the report attached to this project!

Examples:
fullcalib.cpp, multicam.cpp, multigl.cpp, and singlecalib.cpp.

Definition at line 579 of file CamCalibration.cpp.

Referenced by geom_calib_idle(), geometric_calibration(), and main().

void CamCalibration::ClearAll ( )

Definition at line 95 of file CamCalibration.cpp.

Referenced by ~CamCalibration().

void CamCalibration::ComposeRotationTranslationTo3x4Matrix ( CvMat *  RotTrans,
CvMat *  Rot,
CvMat *  Trans 
)
static

Composes Rot and Trans to RotTrans.

Note: By definition, the translation vector is inversed.

Definition at line 780 of file CamCalibration.cpp.

References cvmGet(), and cvmSet().

Referenced by Mat3x4Inverse().

void CamCalibration::ExtractRotationTranslationFrom3x4Matrix ( CvMat *  RotTrans,
CvMat *  Rot,
CvMat *  Trans 
)
static

Decomposes RotTrans into Rot and Trans.

Note: By definition, the translation vector is inversed.

Definition at line 761 of file CamCalibration.cpp.

References cvmGet(), and cvmSet().

Referenced by PoseObs::eval_func(), ProjObs::eval_func(), CamAugmentation::LoadOptimalStructureFromFile(), and Mat3x4Inverse().

void CamCalibration::HomogenousNormalizeVector ( CvMat *  mat)
static

Divides mat by its last element.

Definition at line 662 of file CamCalibration.cpp.

References cvmGet(), and cvmSet().

Referenced by PoseObs::eval_func(), ProjObs::eval_func(), and PlotPointsToImagesAfterOptimization().

bool CamCalibration::LoadHomographiesFromFile ( char *  file_name)

Loads initial homography structure from file.

Loads the whole homography structure from a file specified by file_name. Recovers the homographies you saved with StoreHomographiesToFile().

Definition at line 209 of file CamCalibration.cpp.

References AddCamera(), AddHomography(), and homography::cvmSet().

void CamCalibration::Mat3x4Inverse ( CvMat *  m_A,
CvMat *  m_B 
)
static

Inverts 3x4 matrix m_A and stores result to m_B.

Definition at line 821 of file CamCalibration.cpp.

References ComposeRotationTranslationTo3x4Matrix(), and ExtractRotationTranslationFrom3x4Matrix().

void CamCalibration::Mat3x4Mul ( CvMat *  m_A,
CvMat *  m_B,
CvMat *  m_C 
)
static
void CamCalibration::PlotPointsToImagesAfterOptimization ( )

!!!!!!!!!!!!!!

Definition at line 1859 of file CamCalibration.cpp.

References cvmGet(), cvPoint(), HomogenousNormalizeVector(), and Mat3x4Mul().

void CamCalibration::PrintOptimizedResultsToFile1 ( )

Prints resulting matrices seperated to 3 files.

The output files are:

  • "camera_c" : Contains the resulting camera calibration matrices (intrinsic parameters)
  • "camera_r_t" : Contains the resulting camera rotation/translation matrices. These matrices transform a point from the reference system to the specified camera coordinate system.
  • "view_r_t" : Contains the resulting view rotation/translation matrices. These matrices transform a point from the specified view coordinate system to the reference system.

Note: A projection matrix can be built by applying the following matrix multiplication: camera_c*camera_r_t*view_r_t

Examples:
fullcalib.cpp, multicam.cpp, multigl.cpp, and singlecalib.cpp.

Definition at line 2357 of file CamCalibration.cpp.

References showmatrix_file().

Referenced by geom_calib_idle(), geometric_calibration(), and main().

void CamCalibration::PrintOptimizedResultsToFile2 ( char *  file_descriptor,
bool  create_png = false,
char *  sequence_descriptor = "",
char *  png_descriptor = "",
int  c_start = 0,
int  h_start = 0 
)

Prints resulting projection matrices to many separated files.

This function calculates a projection matrix for each view-to-camera combination available and stores the result to separated files (1 file per matrix). You have to specify a file_descripter, which contains 2x "%04d" or similar. The first indicates the camera number, the second stands for the view number. A possible example is given by: "cam%04d\\img%04d.tdir".
Please note that if you use directories (like this example demonstrates), they are NOT created, but have to exist before. Otherwise the results will not be saved.
If you want to create png files into a new directory, simply enable the create_png flag and set the corresponding parameters. The directories have to exist before, for image creation, too.

Definition at line 2395 of file CamCalibration.cpp.

References cvmGet(), Mat3x4Mul(), and showmatrix_file().

bool CamCalibration::StoreHomographiesToFile ( char *  file_name)

Stores initial homography structure to file.

Stores the whole homography structure to a file specified by file_name. This function is useful, if the aquiring system you use takes time and you want to tune parameters without waiting each time you run the optimization.

Definition at line 162 of file CamCalibration.cpp.

References cvmGet(), and homography::cvmGet().

Friends And Related Function Documentation

friend struct ProjObs
friend

Definition at line 840 of file CamCalibration.h.


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