Skip to content

Class libCalibGeom::CameraModelBase

Constructors and destructors

CameraModelBase()

CameraModelBase(const ImageSize imageSize,const ImageRegion validRegion = ImageRegion())

Returns:

void

~CameraModelBase()

~CameraModelBase()

Returns:

void

Public member functions

getName()

const std::stringgetName() const =0

Returns the name of the camera model.

Returns:

const std::string

config()

CameraModelConfigconfig() const

Returns the parameters needed to reconstruct this model layout.

Returns:

CameraModelConfig

getNParams()

intgetNParams() const =0

Returns the total number of parameters.

Returns:

int

getParameterNames()

const std::vector< ParameterSpec > &getParameterNames() const =0

Returns the specifications for all parameters.

Returns:

const std::vector< ParameterSpec > &

hasParam()

boolhasParam(const std::string &name) const =0

Checks if a parameter with the given name exists.

Returns:

bool

param()

ParameterConstReferenceparam(const int idx) const =0

Returns a constant reference to a parameter by index.

Returns:

ParameterConstReference

param()

ParameterConstReferenceparam(const std::string name) const =0

Returns a constant reference to a parameter by name.

Returns:

ParameterConstReference

param()

ParameterReferenceparam(const int idx)=0

Returns a mutable reference to a parameter by index.

Returns:

ParameterReference

param()

ParameterReferenceparam(const std::string name)=0

Returns a mutable reference to a parameter by name.

Returns:

ParameterReference

parameterValues()

std::vector< double >parameterValues() const =0

Returns the parameter values in optimizer order.

Returns:

std::vector< double >

setParameterValues()

voidsetParameterValues(const std::vector< double > &values)=0

Replaces the parameter values from optimizer-order storage.

Returns:

void

getConstantParamIds()

std::vector< int >getConstantParamIds() const =0

Returns the indices of constant (fixed) parameters.

Returns:

std::vector< int >

isCentral()

boolisCentral() const =0

Returns whether the model is central.

Central models have a single ray origin at (0, 0, 0) for all pixels. Non-central models may expose per-pixel ray origins via unprojectRay() and getRayMaps().

Returns:

bool

projectPoint()

boolprojectPoint(const double X, const double Y, const double Z, double &u, double &v) const =0

Projects a 3D point into image coordinates (u, v).

Parameters:

XX-coordinate in camera frame.
YY-coordinate in camera frame.
ZZ-coordinate in camera frame.
uResulting horizontal image coordinate.
vResulting vertical image coordinate.

Returns:

boolTrue if the point is projectable (e.g. not behind camera).

unprojectPoint()

boolunprojectPoint(const double &u, const double &v, double &X, double &Y, double &Z) const =0

Unprojects an image point (u, v) into a 3D direction.

For central models, the resulting vector (X, Y, Z) is a unit bearing vector in camera coordinates. For models that expose richer ray geometry, this method still returns the normalized ray direction only; use unprojectRay() when the ray origin also matters.

Parameters:

uHorizontal image coordinate.
vVertical image coordinate.
XX component of direction.
YY component of direction.
ZZ component of direction.

Returns:

boolTrue if unprojection was successful.

unprojectRay()

boolunprojectRay(const double &u, const double &v, Point3 &origin, Point3 &direction) const =0

Unprojects an image point (u, v) into a full 3D ray.

For central models, the ray origin is (0, 0, 0) and the direction is a unit bearing vector. Models with non-zero per-pixel ray origins should override this function to return the full ray geometry.

Parameters:

uHorizontal image coordinate.
vVertical image coordinate.
originRay origin in camera coordinates.
directionUnit ray direction in camera coordinates.

Returns:

boolTrue if unprojection was successful.

getUndistortionMaps()

voidgetUndistortionMaps(Image< float > &mapU, Image< float > &mapV, Matrix< double, 3, 3 > &K) const =0

Computes undistortion maps and the new camera matrix.

The returned maps define a source-image remap induced by a default virtual linear camera. For each output pixel, K maps the pixel to a point on the virtual camera plane at Z==1, which in turn defines the corresponding virtual camera ray. The maps contain the source-image lookup coordinates produced by projecting that ray through the camera model.

For central models this rectification is exact. For non-central models, a single depth-independent 2D remap is only an approximation, so the result should be interpreted as a convenient best-fit rectification.

Parameters:

mapUMap for u-coordinates.
mapVMap for v-coordinates.
KNew camera matrix.

Returns:

void

getUnprojectionMaps()

voidgetUnprojectionMaps(Image< float > &mapX, Image< float > &mapY, Image< float > &mapZ) const =0

Computes 3-channel bearing-vector maps.

The returned maps store the unit ray direction (X, Y, Z) associated with each pixel.

For non-central models, these maps describe direction only and do not encode any per-pixel ray origin. Use getRayMaps() for the full geometry.

Parameters:

mapXMap for X-components.
mapYMap for Y-components.
mapZMap for Z-components.

Returns:

void

getRayMaps()

voidgetRayMaps(Image< float > &mapOx, Image< float > &mapOy, Image< float > &mapOz, Image< float > &mapDx, Image< float > &mapDy, Image< float > &mapDz) const =0

Computes per-pixel ray origin and direction maps.

Central models return zero origin everywhere and a unit bearing vector in the direction maps. Models with per-pixel ray origins can override this to expose the full ray geometry.

Parameters:

mapOxMap for ray-origin X-coordinates.
mapOyMap for ray-origin Y-coordinates.
mapOzMap for ray-origin Z-coordinates.
mapDxMap for ray-direction X-coordinates.
mapDyMap for ray-direction Y-coordinates.
mapDzMap for ray-direction Z-coordinates.

Returns:

void

defaultInitializationMethod()

InitializationMethoddefaultInitializationMethod() const =0

Returns the default initialization method for this camera model.

Returns:

InitializationMethod

initialize()

boolinitialize(const std::vector< std::vector< Point3 >> &worldPoints, const std::vector< std::vector< Point2 >> &imagePoints, std::vector< Rotation > &Rc, std::vector< Translation > &Tc, const InitializationMethod method)=0

Initializes the model from calibration observations.

Returns:

bool

newCostFunction()

std::unique_ptr< ceres::CostFunction >newCostFunction(const Point2 &imagePoint) const =0

Creates a Ceres CostFunction for optimizing Reprojection Error.

Parameters:

imagePointThe detected 2D point.

Returns:

std::unique_ptr< ceres::CostFunction >

newCostFunction()

std::unique_ptr< ceres::CostFunction >newCostFunction(const Point2 &imagePoint, const Matrix< double, 2, 2 > &W) const =0

Creates a Ceres CostFunction with uncertainty weighting.

Parameters:

imagePointThe detected 2D point.
WWeight matrix.

Returns:

std::unique_ptr< ceres::CostFunction >

clone()

std::unique_ptr< CameraModelBase >clone() const =0

Clones the camera model.

Returns:

std::unique_ptr< CameraModelBase >

regularizationFunction()

std::unique_ptr< ceres::CostFunction >regularizationFunction(const int nResiduals) const =0

Creates a regularization cost function.

Parameters:

nResidualsNumber of residuals to regularize over.

Returns:

std::unique_ptr< ceres::CostFunction >

toString()

std::stringtoString() const =0

Returns a string representation of the model parameters.

Returns:

std::string

Public data members

imageSize

ImageSizeimageSize

Pixel dimensions of the sensor.

validRegion

ImageRegionvalidRegion

Polygon describing the image region in which the camera model can be assumed valid. Usually corresponds to convex hull of observed feature point locations.

Friends

Friend: internal::OptimizationParameterStorage

Protected Functions

CameraModelBase()

CameraModelBase()

Returns:

void