Back to Adaptive Vision Library website

You are here: Start » Function Reference » Computer Vision » Camera Calibration » CalibrateCamera_LineScan

CalibrateCamera_LineScan


Header: AVL.h
Namespace: avl
Module: Calibration

Finds the line scan camera intrinsic parameters from annotated image coordinates.

Applications: Camera calibration, image to world coordinates transformations.

Syntax

C++
C#
 
void avl::CalibrateCamera_LineScan
(
	const atl::Array<avl::AnnotatedPoint2D>& inImageGrid,
	float inGridSpacing,
	int inImageWidth,
	avl::LensDistortionModelType::Type inDistortionType,
	float inImagePointsStandardDeviation,
	atl::Optional<float> inFocalLength,
	avl::LineScanCameraModel& outCameraModel,
	float& outApproxScaleRatio,
	atl::Optional<float&> outRmsError = atl::NIL,
	atl::Optional<float&> outMaxReprojectionError = atl::NIL,
	atl::Optional<atl::Array<avl::Segment2D>&> outReprojectionErrorSegments = atl::NIL
)

Parameters

Name Type Range Default Description
inImageGrid const Array<AnnotatedPoint2D>& Annotated calibration grid
inGridSpacing float 0.000001 - Real-world distance between adjacent grid points.
inImageWidth int 1 - Image width, used for initial estimation of principal point.
inDistortionType LensDistortionModelType::Type Polynomial Lens distortion model
inImagePointsStandardDeviation float 0.0 - 0.1f Assumed uncertainty of inImagePoints. Used for robust optimization.
inFocalLength Optional<float> NIL Specify a fixed focal length, in pixels. In order to calculate the inFocalLength from camera parameters one needs to divide the lens focal length [mm] by sensor pitch [mm/pix].
outCameraModel LineScanCameraModel&
outApproxScaleRatio float& Approximate scale ratio between Y and X. Useful for camera/encoder trigger rate configuration. When greater than 1, the image is stretched in Y dimension, when less than 1 it is compressed.
outRmsError Optional<float&> NIL Final reprojection RMS error, in pixels.
outMaxReprojectionError Optional<float&> NIL Maximum reprojection error among all points.
outReprojectionErrorSegments Optional<Array<Segment2D>&> NIL Array of segments connecting input image points to grid reprojections.

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outRmsError, outMaxReprojectionError, outReprojectionErrorSegments.

Read more about Optional Outputs.

Description

The filter estimates intrinsic parameters of whole line scan camera system, which consist of a camera and a moving conveyor belt. Such approach, in contrast with area scan camera calibration, is necessary as the moving element of line scan camera system is tightly bound within the image acquisition geometry. This allows for handling distortions caused by:

  • intrinsic lens distortions
  • image shear caused by deviation from right angle between conveyor belt motion and the camera line
  • nonuniform image scaling caused by deviation from ideal encoder trigger period
  • 1D perspective effects caused by deviation from right angle between camera optical axis and the imaged plane

Calibration uses a planar calibration grid to perform robust minimization of RMS reprojection error - the square root of averaged squared distances between grid points as observed on the image and their associated grid coordinates projected onto image plane using estimated parameters.

The calibration routine cannot estimate focal length by itself, however it can be set to a fixed value via inFocalLength. The inFocalLength is measured in pixels, it can be calculated from the sensor and lens parameters:

where f_pix - focal length measured in pixels, f_lens - focal length of lens measured in millimeters, pp - sensor pixel pitch measured in millimeters per pixel, d - camera binning or/and image downscaling factor

The inFocalLength can also be obtained from angle of view:

where f_pix - focal length measured in pixels, w - image width, alpha - angle of view

Only the divisional and polynomial lens distortion models are supported for line scan cameras. The divisional supports most use cases and has predictable behaviour even when calibration data is sparse. Polynomial model may be more accurate but it needs a larger dataset of high quality calibration points across the whole image.

The filter provides a few methods for judging the feasibility of calculated solution.

  • The outRmsError is the final RMS reprojection error. The main contributor to that value is the random noise in inImageGrid points positions. Model mismatch will also result in increased outRmsError.
  • The outMaxReprojectionError is the maximum reprojection error, can be used to judge if there are outliers in the calibration data.
  • The outReprojectionErrorSegments consists of segments connecting input image points to reprojected world points, and thus it can be readily used for visualization of gross errors. The XY scatter plot of residual vectors (obtained by using SegmentVector on the outReprojectionErrorSegments) is a good insight into the residuals distribution, which in ideal case should follow a 2D gaussian distribution centered around point (0,0).

Hints

  • High accuracy camera calibration needs a considerable amount of high quality calibration points, especially when using more complicated models. Calibration image should contain hundreds of calibration points spanning the area of interest. The calibration grids should be as flat and stiff as possible (cardboard is not a proper backing material, thick glass is perfect). Take care of proper conditions when taking the calibration images: minimize motion blur by proper lighting, prevent reflections from the calibration surface (ideally use diffusion lighting).
  • When the focal length of the camera is not provided via inFocalLength, the calculated model will lack that value. Despite that, some operations will still work properly, such as distortion removal, or basic image to world plane calibration (CalibrateWorldPlane_* filters).

Examples

Left: calibration grid as captured by the line scan camera. Right: rectified image with shear distortion eliminated.

Remarks

Note, that the calibration routine assumes that the camera line spans the image along its width (i.e. consecutive image rows correspond to consecutive camera acquisitions).

Errors

List of possible exceptions:

Error type Description
DomainError Empty input grid
DomainError inGridSpacing needs to be positive
DomainError Thin prism lens distortion is not supported for line scan cameras.

See Also

  • CalibrateCamera_Pinhole – Finds the camera intrinsic parameters from the input arrays of annotated image coordinates. Uses pinhole camera model (perspective camera).
  • CalibrateCamera_Telecentric – Finds the telecentric camera intrinsic parameters from the input arrays of annotated image coordinates.