Main Content

estimateFisheyeParameters

Calibrate fisheye camera

Description

example

[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 fisheye 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.

Examples

collapse all

Use calibration images to detect a checkerboard calibration pattern. Calibrate the camera using corners extracted from the pattern and visualize the results of the calibration.

Load calibration images using an image datastore.

calibrationImages = imageDatastore("calibImages");
imageFileNames = calibrationImages.Files;

Detect the calibration pattern from the images. The PartialDetections name-value argument is set to true by default to allow detection of partial checkerboards.

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

Collect the calibration images in which checkerboards were detected.

usedImageFileNames = imageFileNames(imagesUsed);
images = imageDatastore(usedImageFileNames);

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
showReprojectionErrors(params);

Visualize the camera extrinsics.

figure
showExtrinsics(params);

drawnow

Plot the detected and reprojected points.

figure 
imshow(I); 
hold on
plot(imagePoints(:,1,10),imagePoints(:,2,10),"go");
plot(params.ReprojectedPoints(:,1,10),params.ReprojectedPoints(:,2,10),"r+");
legend("Detected Points","Reprojected Points");
hold off

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 pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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 numImages-by-1 logical array. numImages 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.

References

[1] Scaramuzza, D., A. Martinelli, and R. Siegwart. "A Toolbox for Easy Calibrating Omnidirectional 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.

Version History

Introduced in R2017b