3DiVi Face SDK  3.24.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
pbio::CameraCalibrator Class Reference

Interface object for camera calibration and correction of image distortion. More...

#include <CameraCalibrator.h>

Classes

struct  CalibrationSettings
 Сalibration process settings. More...
 

Public Types

typedef LightSmartPtr
< CameraCalibrator >::tPtr 
Ptr
 Alias for the type of a smart pointer to CameraCalibrator.
 

Public Member Functions

void initCalibration (const CalibrationSettings settings)
 Initialize the calibration process. All previous accepted patterns will be removed. More...
 
void addImage (const RawImage image, bool *pattern_found, bool *pattern_accepted, std::vector< Point > *pattern_points)
 Search a pattern in the image and store it. More...
 
float getPatternSpaceCoverProgress () const
 Evaluate covering of the pattern space to get more accurate calibration. More...
 
std::vector< PointgetTip ()
 Get a tip where to put a pattern in the image to get a better pattern space coverage. More...
 
bool calibrate (const int max_used_patterns_count, float *reprojection_error)
 Calibrate the camera. More...
 
IRawImage::Ptr undistort (const RawImage image, const float alpha) const
 Correct the image distortion using the calibrated or loaded camera parameters. More...
 
void saveCameraParameters (std::ostream &binary_stream) const
 Save the calibrated camera parameters to binary_stream. The format is platform-independent. More...
 
void saveCameraParameters (pbio::stl_wraps::WrapOStream &binary_stream) const
 Save the calibrated camera parameters to binary_stream. The format is platform-independent. More...
 
void loadCameraParameters (std::istream &binary_stream)
 Load the calibrated camera parameters from binary_stream. The format is platform-independent. More...
 
void loadCameraParameters (pbio::stl_wraps::WrapIStream &binary_stream)
 Load the calibrated camera parameters from binary_stream. The format is platform-independent. More...
 

Detailed Description

Interface object for camera calibration and correction of image distortion.

Member Function Documentation

void pbio::CameraCalibrator::addImage ( const RawImage  image,
bool *  pattern_found,
bool *  pattern_accepted,
std::vector< Point > *  pattern_points 
)
inline

Search a pattern in the image and store it.

Parameters
[in]imageAn image or a videoframe.
[out]pattern_foundThe pattern was successfully found in a given image. Can be NULL.
[out]pattern_acceptedThe found pattern was accepted (i.e., it differs significantly from the patterns already accepted). Can be NULL.
[out]pattern_pointsPoints of a detected pattern. Can be NULL.
bool pbio::CameraCalibrator::calibrate ( const int  max_used_patterns_count,
float *  reprojection_error 
)
inline

Calibrate the camera.

Parameters
[in]max_used_patterns_countMaximum number of patterns to use for calculation. If more patterns are accepted, the subset covering the pattern space best will be used. The recommended value is 50.
[out]reprojection_errorAverage reprojection error. Normal values are about 1 or lower.
Returns
true, if the calibration was successful, otherwise false.
float pbio::CameraCalibrator::getPatternSpaceCoverProgress ( ) const
inline

Evaluate covering of the pattern space to get more accurate calibration.

Returns
A real number from 0 to 1.
std::vector< Point > pbio::CameraCalibrator::getTip ( )
inline

Get a tip where to put a pattern in the image to get a better pattern space coverage.

Returns
An empty vector if the tip is not ready, or a vector of pattern points.
void pbio::CameraCalibrator::initCalibration ( const CalibrationSettings  settings)
inline

Initialize the calibration process. All previous accepted patterns will be removed.

Parameters
[in]settingsCalibration process settings.
void pbio::CameraCalibrator::loadCameraParameters ( std::istream &  binary_stream)
inline

Load the calibrated camera parameters from binary_stream. The format is platform-independent.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the std::ios_base::binary flag.
void pbio::CameraCalibrator::loadCameraParameters ( pbio::stl_wraps::WrapIStream &  binary_stream)
inline

Load the calibrated camera parameters from binary_stream. The format is platform-independent.

Parameters
[in]binary_streamInput stream object. The file stream (std::ifstream) must be opened with the std::ios_base::binary flag.
void pbio::CameraCalibrator::saveCameraParameters ( std::ostream &  binary_stream) const
inline

Save the calibrated camera parameters to binary_stream. The format is platform-independent.

Parameters
[out]binary_streamOutput stream object. The file stream (std::ofstream) must be opened with the std::ios_base::binary flag.
void pbio::CameraCalibrator::saveCameraParameters ( pbio::stl_wraps::WrapOStream &  binary_stream) const
inline

Save the calibrated camera parameters to binary_stream. The format is platform-independent.

Parameters
[out]binary_streamOutput stream object. The file stream (std::ofstream) must be opened with the std::ios_base::binary flag.
IRawImage::Ptr pbio::CameraCalibrator::undistort ( const RawImage  image,
const float  alpha 
) const
inline

Correct the image distortion using the calibrated or loaded camera parameters.

Parameters
[in]imageAn image or a videoframe. The size can differ from the size of the images used for calibration. I.e. you can calibrate a camera once with one resolution and then calibrate the distortion of images from the same camera with any resolution.
[in]alphaA real value from 0 (the result image contains only valid pixels (no black areas)) to 1 (all pixels from the original image are stored in the result image (no source image pixels are lost)). Intermediate values yield an intermediate result between those two extreme cases.
Returns
Undistorted image of the same size and type as the source image.