#include <camera.h>
Collaboration diagram for mimas::camera_calibration::Camera:
Public Types | |
typedef boost::numeric::ublas::matrix< double, boost::numeric::ublas::column_major > | Matrix |
Matrix definition. | |
typedef boost::numeric::ublas::vector< double > | Vector |
Vector definition. | |
typedef boost::numeric::ublas::triangular_matrix< double, boost::numeric::ublas::upper, boost::numeric::ublas::column_major > | TriangularMatrix |
Triangular matrix definition. | |
typedef boost::numeric::ublas::symmetric_matrix< double, boost::numeric::ublas::upper, boost::numeric::ublas::column_major > | SymmetricMatrix |
Symmetric matrix definition. | |
Public Member Functions | |
Camera () throw (mimasexception) | |
Constructor : instanciate ONE class. | |
~Camera () | |
Free the class. | |
void | calibrate (std::vector< Chessboard > &chess) throw (mimasexception) |
Calibrate the camera. | |
Matrix | getIntrinsicsInit () const |
Returns first approximation of the matrix of the intrinsic parameters. | |
Matrix | getIntrinsics () const |
Returns the optimized matrix of the intrinsic parameters. | |
Vector | getDistortion () const |
Returns the distortion. | |
bool | isOptimized () const |
Returns if the optimisation algorithm worked or not. | |
Static Public Member Functions | |
static void | fcn (int *m, int *, double *x, double *fvec, int *) |
Calculate the projection of the chessboard points according to the given values of the intrinsic matrix and the distortion coefficients, and return an array containing the error between the mesured point and the calculated one. | |
static void | findHomography (const Chessboard &chess, Matrix &homography) |
Find the homography. | |
static void | findHomographies (std::vector< Matrix > &homographies, std::vector< Chessboard > &chess) |
Find all the homographies. | |
static Matrix | initCalibration (std::vector< Matrix > &homographies, std::vector< Chessboard > &chess) throw (mimasexception) |
Find a first approximation of the intrinsic matrix. | |
static void | findExtrinsics (std::vector< Matrix > &extrinsics, std::vector< Matrix > &homographies, Matrix &intrinsics, int nbPictures) |
Find the extrinsic parameters. | |
Static Public Attributes | |
static Camera * | current_cam |
pointer to the current class. | |
Protected Member Functions | |
void | maxLikelyhood (Matrix &intrinsics, int nbPictures) throw (mimasexception) |
This function applies the Levenberg-Marquardt algorithm to the first approximation of the intrinsic matrix. |
The class can be used with a float or double template, depending on the precision required in the calculus.
Important : because of a limitation of a FORTRAN library used by the calibration algorithm, it's only possible to instanciate one class Camera at the same time.
Definition at line 57 of file camera.h.
typedef boost::numeric::ublas::matrix< double, boost::numeric::ublas::column_major > mimas::camera_calibration::Camera::Matrix |
typedef boost::numeric::ublas::vector< double > mimas::camera_calibration::Camera::Vector |
typedef boost::numeric::ublas::triangular_matrix< double, boost::numeric::ublas::upper, boost::numeric::ublas::column_major > mimas::camera_calibration::Camera::TriangularMatrix |
typedef boost::numeric::ublas::symmetric_matrix< double, boost::numeric::ublas::upper, boost::numeric::ublas::column_major > mimas::camera_calibration::Camera::SymmetricMatrix |
mimas::camera_calibration::Camera::Camera | ( | ) | throw (mimasexception) |
Constructor : instanciate ONE class.
mimas::camera_calibration::Camera::~Camera | ( | ) |
Free the class.
void mimas::camera_calibration::Camera::maxLikelyhood | ( | Matrix & | intrinsics, | |
int | nbPictures | |||
) | throw (mimasexception) [protected] |
This function applies the Levenberg-Marquardt algorithm to the first approximation of the intrinsic matrix.
void mimas::camera_calibration::Camera::calibrate | ( | std::vector< Chessboard > & | chess | ) | throw (mimasexception) |
Calibrate the camera.
This is the function one should call to get the calibration parameters.
To calibrate the camera, one should provide four points of the chessboard in the coordinate of the chessboard (the unit is the square), and the coordinates of the same points in the picture of the chessboard taken by the camera (the unit is the pixel).
A minimum of 4 images is required to compute the calibration, but you will need much more to get an accurate result.
chess | a vector of Chessboard classes, to know the images of the chessboard points by the camera. |
static void mimas::camera_calibration::Camera::fcn | ( | int * | m, | |
int * | , | |||
double * | x, | |||
double * | fvec, | |||
int * | ||||
) | [static] |
Calculate the projection of the chessboard points according to the given values of the intrinsic matrix and the distortion coefficients, and return an array containing the error between the mesured point and the calculated one.
This function is used by the MINPACK library (in FORTRAN) to minimize the error using the Levenberg-Marquardt algorithm.
m | the number of functions ie 4 * nbPictures (there are 4 points per picture) | |
x | an arrray containing the 5 intrinsic parameters and the 2 distortion parameters | |
fvec | an output array, containing the result of each function. |
static void mimas::camera_calibration::Camera::findHomography | ( | const Chessboard & | chess, | |
Matrix & | homography | |||
) | [static] |
Find the homography.
This function finds the homography between a set of $nb$ points and $nb$ images.
chess | a Chessboard class | |
homography | a 3*3 matrix, must be initialised. |
static void mimas::camera_calibration::Camera::findHomographies | ( | std::vector< Matrix > & | homographies, | |
std::vector< Chessboard > & | chess | |||
) | [static] |
Find all the homographies.
Given 4 points and their images for some pictures, this function calculates all the homographies (one by picture).
static Matrix mimas::camera_calibration::Camera::initCalibration | ( | std::vector< Matrix > & | homographies, | |
std::vector< Chessboard > & | chess | |||
) | throw (mimasexception) [static] |
Find a first approximation of the intrinsic matrix.
This function returns a first approximation of the intrinsics, in the ideal case where there is no noise in the pictures, and no distortion.
static void mimas::camera_calibration::Camera::findExtrinsics | ( | std::vector< Matrix > & | extrinsics, | |
std::vector< Matrix > & | homographies, | |||
Matrix & | intrinsics, | |||
int | nbPictures | |||
) | [static] |
Find the extrinsic parameters.
This functions finds the extrinsic parameters (i.e. the rotation and the translation) between each image of the chessboard and the chessboard itself.
Matrix mimas::camera_calibration::Camera::getIntrinsicsInit | ( | ) | const [inline] |
Matrix mimas::camera_calibration::Camera::getIntrinsics | ( | ) | const [inline] |
Vector mimas::camera_calibration::Camera::getDistortion | ( | ) | const [inline] |
bool mimas::camera_calibration::Camera::isOptimized | ( | ) | const [inline] |