主要内容

estimateBoardCornersCamera

Estimate corners of calibration board in camera frame

Since R2026a. Replaces estimateCheckerboardCorners3d.

Description

Estimate corners of a checkerboard, ChArUco board, AprilGrid, or a board with a custom calibration pattern in the camera frame.

Supported Calibration Patterns

cornersCamera = estimateBoardCornersCamera("checkerboard",imagePoints,intrinsics,patternDims,squareSize) estimates the 3-D corners of a checkerboard in the camera frame using 2-D image points, imagePoints, camera intrinsics, intrinsics, the pattern’s dimensions, patternDims, and the pattern's square size, squareSize.

example

cornersCamera = estimateBoardCornersCamera("charuco-board",imagePoints,intrinsics,patternDims,checkerSize) estimates the 3-D corners of a ChArUco board in the camera frame using the checker size, checkerSize.

cornersCamera = estimateBoardCornersCamera("aprilgrid",imagePoints,intrinsics,patternDims,tagSize,tagSpacing) estimates the 3-D corners of an AprilGrid board in the camera frame using the tag size, tagSize, and tag spacing.

[cornersCamera,boardSize] = estimateBoardCornersCamera(___) additionally returns the board size boardSize.

[___] = estimateBoardCornersCamera(___,Padding=padding) specifies the padding along each side of the board.

Custom Calibration Patterns

cornersCamera = estimateBoardCornersCamera(imagePoints,worldPoints,intrinsics,originDistance,boardSize) estimates the 3-D board corners using the image points imagePoints, world points worldPoints, camera intrinsics intrinsics, origin distance originDistance, and board size boardSize.

Examples

collapse all

Load an image containing a checkerboard pattern into the workspace.

I = imread(fullfile(toolboxdir("lidar"),"lidardata","calibration","images","01.png"));

Load the camera intrinsics from a previously saved mat file.

cameraIntrinsicFile = fullfile(toolboxdir("lidar"),"lidardata","calibration","images","intrinsics.mat");
intrinsics = load(cameraIntrinsicFile).intrinsics;

Disable the warning for symmetric board usage. While symmetric boards are not recommended, the uniform padding in this case ensures symmetry does not affect the results.

currentState = warning;
warning("off","vision:calibrate:boardShouldBeAsymmetric")

Detect the checkerboard points.

[imagePoints,patternDims] = detectCheckerboardPoints(I,PartialDetections=false);

Restore the original warning state.

warning(currentState)

Visualize the detected checkerboard points.

figure
imshow(I)
hold on
plot(imagePoints(:,1),imagePoints(:,2),"ro",MarkerSize=3)

Figure contains an axes object. The hidden axes object contains 2 objects of type image, line. One or more of the lines displays its values using only markers

Specify the size of the checkerboard squares in millimeters.

squareSize = 100;

Specify the padding of the board in millimeters.

padding = [100 100 100 100];

Estimate the board corners in the camera frame.

cornersCamera = estimateBoardCornersCamera("checkerboard",imagePoints,...
    intrinsics,patternDims,squareSize,Padding=padding);

Undistort image for visualization.

J = undistortImage(I,intrinsics);

Project the corner points to the image.

cornersImage = projectLidarPointsOnImage(cornersCamera,intrinsics,rigidtform3d);

Visualize the estimated board corners in the undistorted image.

figure
imshow(J)
hold on
showShape("polygon",cornersImage,Color="red",LineWidth=2)

Figure contains an axes object. The hidden axes object contains an object of type image.

Load an image containing an AprilGrid board into the workspace.

I = imread("AprilGridCalibrationBoardImage.jpg");

Load the camera intrinsics from a previously saved mat file.

intrinsics = load("intrinsics.mat").intrinsics;

Define the parameters for AprilGrid detection.

patternDims = [8 11];
markerFamily = "tag36h11";
minTagId = 300;

Detect AprilGrid points in the image.

imagePoints = detectAprilGridPoints(I,patternDims,markerFamily,MinTagID=minTagId);

Visualize the detected points in the image.

figure;
imshow(I)
hold on
plot(imagePoints(:,1),imagePoints(:,2),"ro",MarkerSize=2)

Figure contains an axes object. The hidden axes object contains 2 objects of type image, line. One or more of the lines displays its values using only markers

Define the parameters to estimate the board corners in the camera frame.

tagSize = 21.5;
tagSpacing = 6.5;
padding = [56 18 53 27];

Estimate board corners in the camera frame.

cornersCamera = estimateBoardCornersCamera("aprilgrid",imagePoints,intrinsics, ...
    patternDims,tagSize,tagSpacing,Padding=padding);

Undistort image for visualization.

J = undistortImage(I,intrinsics);

Project the corner points to the image.

cornersImage = projectLidarPointsOnImage(cornersCamera,intrinsics,rigidtform3d);

Visualize the estimated board corners in the undistorted image.

figure
imshow(J)
hold on
showShape("polygon",cornersImage,Color="red",LineWidth=3)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Key point coordinates of calibration pattern in raw image, specified by an N-by-2 matrix or an N-by-2-by-NumImages matrix. Partial detections are supported, but must include at least four non-collinear points.

Camera intrinsic parameters, specified by a cameraIntrinsics object.

Pattern dimensions, specified as a 2-element vector. The pattern board dimensions are defined as:

  • Checkerboard — Number of squares along the short side and along the long side.

  • ChArUco board — Number of checkers along the vertical and horizontal directions of the pattern, with the origin checker positioned at the top-left of the board and the minimum marker ID assigned to the checker immediately to the right of the origin.

  • AprilGrid board — Number of tags along the vertical and horizontal directions of the pattern, with the origin tag that corresponds to the minimum tag ID, located at the bottom-left corner

For more details, see the Tips section.

Size of checkerboard square, specified as a scalar in millimeters. For details, see the Tips section.

Side length of ChArUco checker board square, specified as a positive scalar in millimeters. For details, see the Tips section.

Size of AprilTag, specified as a positive scalar in millimeters. For details, see the Tips section.

Space between two consecutive AprilTags, specified as a positive scalar in millimeters. For details, see the Tips section.

Generated world points, specified as an N-by-2 matrix in world coordinates. The matrix contains N points with coordinates in the form [x y].

Distance from the board edge to the origin point in millimeters, specified as a 2-element vector of the form [xDistance yDistance].

Calibration board size in millimeters, specified as a 2-element vector of the form [sizeDim1 sizeDim2]. For details, see the Tips section.

Padding along each side of the board in millimeters, specified as a 4-element row vector. For details, see the Tips section.

Output Arguments

collapse all

Estimated board corners in the camera frame, returned as a 4-by-3-by-numImages matrix. For each set of keypoints that correspond to an image, the corresponding 4-by-3 matrix contains the location (x,y,z) coordinates of the four board corners based on the 2-D image keypoints. If board corner estimation fails for a set of points that correspond to an image, the corresponding matrix contains NaN values.

Calibration board size in millimeters, returned as a 2-element vector of the form [sizeDim1 sizeDim2].

Tips

  • Labeled diagrams of Checkerboard, ChArUco, and AprilGrid calibration patterns.

    CheckerboardChArUcoAprilGrid

Version History

Introduced in R2026a

expand all