cv.calibrateCamera - MATLAB File Help
cv.calibrateCamera

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern

[cameraMatrix, distCoeffs, reprojErr] = cv.calibrateCamera(objectPoints, imagePoints, imageSize)
[cameraMatrix, distCoeffs, reprojErr, rvecs, tvecs, stdDevsIntrinsics, stdDevsExtrinsics, perViewErrors] = cv.calibrateCamera(...)
[...] = cv.calibrateCamera(..., 'OptionName', optionValue, ...)

Input

Output

Options

The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on [Zhang2000] and [BoughuetMCT]. The coordinates of 3D object points and their corresponding 2D projections in each view must be specified. That may be achieved by using an object with a known geometry and easily detectable feature points. Such an object is called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as a calibration rig (see cv.findChessboardCorners). Currently, initialization of intrinsic parameters (when UseIntrinsicGuess is not set) is only implemented for planar calibration patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also be used as long as initial CameraMatrix is provided.

The algorithm performs the following steps:

  1. Compute the initial intrinsic parameters (the option only available for planar calibration patterns) or read them from the input parameters. The distortion coefficients are all set to zeros initially unless some of 'FixK?' are specified.
  2. Estimate the initial camera pose as if the intrinsic parameters have been already known. This is done using cv.solvePnP.
  3. Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error, that is, the total sum of squared distances between the observed feature points imagePoints and the projected (using the current estimates for camera parameters and the poses) object points objectPoints. See cv.projectPoints for details.

Note

If you use a non-square (=non-NxN) grid and cv.findChessboardCorners for calibration, and cv.calibrateCamera returns bad values (zero distortion coefficients, an image center very far from (w/2-0.5,h/2-0.5), and/or large differences between fx and fy (ratios of 10:1 or more), then you have probably used patternSize=[rows,cols] instead of using patternSize=[cols,rows] in cv.findChessboardCorners.

References

[Zhang2000]:

Zhengyou Zhang. "A flexible new technique for camera calibration". IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(11):1330-1334, 2000.

[BoughuetMCT]:

Jean-Yves Bouguet. "Camera Calibration Toolbox for MATLAB" [eb/ol], 2004. Camera Calibration Toolbox

[Brown71]:

Brown, D. C. "Close-range camera calibration", Photogrammetric Engineering 37 (1971): 855-866.

See also