FUNCTION REFERENCE

estimateCameraParameters

Calibrate a single camera from views of a planar pattern.

Calibrate a single camera from views of a planar pattern.

Syntax

params = estimateCameraParameters(imagePoints, worldPoints)

Syntax

[params, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, Name, Value, ...)

imagePoints is M-by-2-by-P: the [x y] pixel positions (the centre of the first pixel is (1,1)) of the M pattern points in each of P >= 2 views, as detectCheckerboardPoints returns them; worldPoints is the M-by-2 [x y] pattern points on the plane z = 0 (generateCheckerboardPoints). params is a cameraParameters with FocalLength, PrincipalPoint, Skew, RadialDistortion, TangentialDistortion, RotationVectors and TranslationVectors (one row per view used), WorldPoints, ReprojectionErrors (reprojected minus detected points, M-by-2-by-P) and MeanReprojectionError. Partially detected patterns: a point not detected in a view is [NaN NaN] in that view; it is left out of the fit, and its ReprojectionErrors rows are NaN (MeanReprojectionError leaves them out). imagesUsed is P-by-1 logical, false for a view with fewer than 4 points or without a homography (a warning names such views); the result arrays cover the used views only, and at least 2 are needed. estimationErrors is a cameraCalibrationErrors object: IntrinsicsErrors (an intrinsicsEstimationErrors with SkewError, FocalLengthError, PrincipalPointError, RadialDistortionError and TangentialDistortionError) and ExtrinsicsErrors (an extrinsicsEstimationErrors with RotationVectorsError and TranslationVectorsError, one row per used view), the standard errors of the estimates (0 for parameters not estimated); displayErrors prints them. Names: ImageSize ([mrows ncols], default []); WorldUnits ('mm'); EstimateSkew (false); NumRadialDistortionCoefficients (2 or 3, default 2); EstimateTangentialDistortion (false); InitialK (a 3-by-3 [fx s cx; 0 fy cy; 0 0 1] start for the intrinsics instead of the closed form) or InitialIntrinsicMatrix (the same as its transpose, the earlier form); InitialRadialDistortion (a start for the radial coefficients, NumRadialDistortionCoefficients elements; default zeros). The views must tilt the pattern in different directions: parallel poses (pattern planes within about 1 degree of each other) are degenerate and give an error.

Method: Zhang's method: a homography per view (normalised DLT), closed-form intrinsics and extrinsics, then Levenberg-Marquardt over all parameters minimising the reprojection error (distortion starts at zero). With 2 to 4 views, or when the closed form gives no camera, the fit is also started from the principal point at the image centre (the centroid of the points without ImageSize) with focal lengths from the homographies, and the fit with the smaller error is kept (with InitialK only that start is used). Standard errors are sqrt(diag(s2 * inv(J'*J))) at the solution, J the Jacobian of the reprojection residuals, s2 = sum of squared residuals / (2 * number of points - number of parameters).

Example

w = generateCheckerboardPoints([7 10], 25); c = cameraIntrinsics([800 790], [322 238], [480 640]); r = [0.3 0 0; 0 0.3 0; 0.2 -0.2 0.1]; ip = zeros(54, 2, 3); for k = 1:3, ip(:, :, k) = worldToImage(c, rotationVectorToMatrix(r(k, :)), [-100 -60 500], w); end; params = estimateCameraParameters(ip, w, 'ImageSize', [480 640]); round(params.FocalLength)   % [800 790]

Example

w = generateCheckerboardPoints([7 10], 25); c = cameraIntrinsics([800 790], [322 238], [480 640]); r = [0.3 0 0; 0 0.3 0; 0.2 -0.2 0.1]; ip = zeros(54, 2, 3); for k = 1:3, ip(:, :, k) = worldToImage(c, rotationVectorToMatrix(r(k, :)), [-100 -60 500], w); end; ip(1:5, :, 2) = NaN; [params, used] = estimateCameraParameters(ip, w, 'InitialK', [800 0 322; 0 790 238; 0 0 1]); used'   % [1 1 1]

Differences from MATLAB: stereo pairs, fisheye models, EstimateSkew together with fewer than 3 views and more than 100 views are not supported yet. Points with only one coordinate NaN, or Inf, are an error.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.