Main Content


Calibrate fisheye camera



[fisheyeParams,imagesUsed,estimationErrors] = estimateFisheyeParameters(imagePoints,worldPoints,imageSize) returns a fisheyeParameters object containing estimates for the intrinsic and extrinsic parameters of a fisheye camera. The function also returns the images you used to estimate the fisheye parameters and the standard estimation errors for the single camera calibration.

[___] = estimateFisheyeParameters(___,Name,Value) configures the fisheyeParams object properties specified by one or more Name,Value pair arguments, using the previous syntax. Unspecified properties have their default values.


collapse all

Use calibration images to detect a checkerboard calibration pattern. Then calibrate the camera using corneres extracted from the pattern and visualize the results.

Gather a set of calibration images.

images = imageDatastore('calibImages');
imageFileNames = images.Files;

Detect the calibration pattern from the images. The 'PartialDetections' Name-Value argument is set to true by default allowing detection of partial checkerboards.

[imagePoints,boardSize] = detectCheckerboardPoints(imageFileNames, 'HighDistortion', true);

Generate world coordinates for the corners of the checkerboard squares.

squareSize = 20; % millimeters
worldPoints = generateCheckerboardPoints(boardSize,squareSize);

Estimate the fisheye camera calibration parameters based on the image and world points.

I = readimage(images,10); 
imageSize = [size(I,1) size(I,2)];
params = estimateFisheyeParameters(imagePoints,worldPoints,imageSize);

Visualize the calibration accuracy.


Figure contains an axes object. The axes object with title Mean Reprojection Error per Image contains 3 objects of type bar, line. This object represents Overall Mean Error: 1.67 pixels.

Visualize the camera extrinsics.


Figure contains an axes object. The axes object with title Extrinsic Parameters Visualization contains 25 objects of type patch, text, line.


Plot the detected and reprojected points.

hold on
legend('Detected Points','Reprojected Points');
hold off

Figure contains an axes object. The axes object contains 3 objects of type image, line. These objects represent Detected Points, Reprojected Points.

Input Arguments

collapse all

Key points of calibration pattern, specified as an M-by-2-by-numImages array of [x,y] intrinsic image coordinates. The number of images, numImages, must be greater than 2. The number of keypoint coordinates in each pattern, M, must be greater than 3. To include partially detected patterns in the estimate, use [NaN,NaN] as x-y coordinates for missing keypoints.

Data Types: single | double

Key points of calibration pattern in world coordinates, specified as an M-by-2 matrix of M [x,y] world coordinates. Because the pattern must be planar, the z-coordinates are zero.

Data Types: single | double

Image size, specified as an [mrows ncols] vector.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'WorldUnits','mm' sets the world point units to millimeters.

Estimate the axes alignment, specified as the comma-separated pair consisting of 'EstimateAlignment' and false or true. Set to true if the optical axis of the fisheye lens is not perpendicular to the image plane.

World point units, specified as the comma-separated pair consisting of 'WorldUnits' and a character vector or string scalar. This argument is used simply to store the unit type and does not affect any calculations.

Output Arguments

collapse all

Fisheye camera parameters, returned as a fisheyeParameters object.

Images used to the estimate camera parameters, returned as a P-by-1 logical array. P corresponds to the number of images. A logical true value indicates the index of an image used to estimate the camera parameters.

Standard errors of estimated parameters, returned as a fisheyeCalibrationErrors object.


[1] Scaramuzza, D., A. Martinelli, and R. Siegwart. "A Toolbox for Easy Calibrating Omindirectional Cameras." Proceedings to IEEE International Conference on Intelligent Robots and Systems (IROS 2006). Beijing, China, October 7–15, 2006.

[2] Urban, S., J. Leitloff, and S. Hinz. "Improved Wide-Angle, Fisheye and Omnidirectional Camera Calibration." ISPRS Journal of Photogrammetry and Remove Sensing. Vol. 108, 2015, pp.72–79.

Introduced in R2017b