Main Content

estimateCheckerboardCorners3d

Estimate world frame coordinates of checkerboard corner points in image

Since R2020b

Description

imageCorners3d = estimateCheckerboardCorners3d(I,cameraIntrinsic,checkerSize) estimates the world frame coordinates of the corner points of a checkerboard in an image, I, by using the camera intrinsic parameters cameraIntrinsic and the size of the checkerboard squares checkerSize.

example

[imageCorners3d,boardDimensions] = estimateCheckerboardCorners3d(I,cameraIntrinsic,checkerSize) additionally returns the checkerboard dimensions boardDimensions.

[imageCorners3d,boardDimensions,imagesUsed] = estimateCheckerboardCorners3d(imageFileNames,cameraIntrinsic,checkerSize) estimates the world frame coordinates of the corner points of a checkerboard from a set of image files, imageFileNames. The function returns a logical vector that indicates in which images it detected a checkerboard, imagesUsed, in addition to output arguments from previous syntaxes.

[___] = estimateCheckerboardCorners3d(imageArray,cameraIntrinsic,checkerSize) estimates the world frame coordinates of the corner points of a checkerboard from an array of images, imageArray.

[___] = estimateCheckerboardCorners3d(___,Name,Value) specifies options using one or more name-value pair arguments in addition to any combination of arguments from previous syntaxes. For example, 'MinCornerMetric',0.2 sets the threshold for the checkerboard corner metric to 0.2.

Examples

collapse all

Detect a checkerboard in an image using the estimateCheckerboardCorners3d function and estimate the world frame coordinates of the checkerboard corners.

Read the image into the workspace.

Image = imread("CheckerboardImage.png");

Load the camera parameters into the workspace.

intrinsic = load("calibration.mat");

Set the size of the checkerboard squares in millimeters.

squareSize = 200;

Estimate the checkerboard corners.

boardCorners = estimateCheckerboardCorners3d(Image, ...
    intrinsic.cameraParams,squareSize)
boardCorners = 4×3

    1.2840   -0.5216    8.8913
    2.8614    0.5774    8.3401
    1.8230    2.0470    8.2984
    0.2455    0.9480    8.8496

Plot the corners on the input image.

imPts = projectLidarPointsOnImage(boardCorners, ...
    intrinsic.cameraParams,rigidtform3d);
J = undistortImage(Image,intrinsic.cameraParams);
imshow(J)
hold on
plot(imPts(:,1),imPts(:,2),".r","MarkerSize",30)
title("Detected Checkerboard Corners")
hold off

Input Arguments

collapse all

Image for detection, specified as an H-by-W-by-C array where:

  • H — Height of the image in pixels

  • W — Width of the image in pixels

  • C — Number of color channels

Data Types: single | double | int16 | uint8 | uint16

Image file names, specified as a character vector or cell array of character vectors If specifying more than one file name, you must use a cell array of character vectors.

Data Types: char | cell

Set of images, specified as an H-by-W-by-C-by-N array where:

  • H — Height of the tallest image in the array

  • W — Width of the widest image in the array

  • C — Number of color channels

  • N — Number of images in the array

Data Types: single | double | int16 | uint8 | uint16

Camera intrinsic parameters, specified as a cameraIntrinsics object.

Size of a checkerboard square, specified as a scalar in millimeters. This value specifies the length of each side of a checkerboard square.

Data Types: single | double

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: 'MinCornerMetric',0.2 sets the threshold for the checkerboard corner metric to 0.2.

Padding along each side of checkerboard, specified as the comma-separated pair consisting of 'Padding' and a four-element row vector of nonnegative values in millimeters.

The figure shows how the elements of the vector pad the sides.

Checkerboard Padding

Order of padding vector elements on the checkerboard

Data Types: single | double

Threshold for the checkerboard corner metric, specified as the comma-separated pair consisting of 'MinCornerMetric' and a nonnegative scalar. Using a higher threshold value can reduce the number of false detections in a noisy or highly textured image.

Data Types: single | double

Display function progress in a progress bar, specified as the comma-separated pair consisting of 'ShowProgressBar' and a logical false or true.

Data Types: logical

Output Arguments

collapse all

Estimated location of checkerboard corners, returned as a 4-by-3 matrix or 4-by-3-by-P array. For one image, the function returns the 3-D world frame coordinates of the four checkerboard corners. Each row represents the x-, y- , z-axis coordinates of a corner point in meters. For multiple images, the coordinates are returned as a 4-by-3-by-P array, where P is the number of images in which a checkerboard was detected.

Checkerboard dimensions, returned as a two-element row vector. The elements represent the width and length of the checkerboard respectively, in millimeters. The dimensions of the checkerboard are expressed in terms of the number of squares. The function calculates the dimensions of the checkerboard by multiplying the size of the checkerboard squares, checkerSize, by the number of detected squares along a side.

Pattern detection flag, returned as an N-by-1 logical array. N is the number of images in the first input argument. A value of 1 (true) indicates that the function detected a checkerboard pattern in the corresponding image. A value of 0 (false) indicates that the function did not detect a checkerboard pattern in the corresponding image.

Limitations

  • Partial detection of checkerboard is not supported.

Version History

Introduced in R2020b