FUNCTION REFERENCE

detectCheckerboardPoints

Detect checkerboard pattern corners in images.

Detect checkerboard pattern corners in images.

Syntax

[imagePoints, boardSize] = detectCheckerboardPoints(I)

Syntax

[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames)

Syntax

[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(images)

Syntax

[...] = detectCheckerboardPoints(..., 'PartialDetections', tf, 'HighDistortion', tf)

I is a grayscale or truecolor image (double, single, logical, uint8, uint16 or int16); imageFileNames is a cell array or string array of image files; images is an H-by-W-by-N grayscale stack (N other than 3: H-by-W-by-3 is one truecolor image), or a 4-D H-by-W-by-1-by-N grayscale or H-by-W-by-3-by-N truecolor stack. imagePoints are the inner corners as [x y] in pixels (the centre of the first pixel is (1,1)), sub-pixel accurate, M-by-2 for one image and M-by-2-by-K for the K images used, with M = prod(boardSize - 1). boardSize is [height width] in squares. Point order is generateCheckerboardPoints's: the origin is the lower-right corner of the top-left square, which is black; x runs along the longer side of the board (the side with more squares), y is x turned 90 degrees clockwise on the image, and y varies fastest. Use a board with an even number of squares along one side and an odd number along the other so the orientation is unique. imagesUsed is an N-by-1 logical vector, true where the board was found; when sizes differ the most common board size is kept. No board gives imagePoints = [] and boardSize = [0 0].

Method: Hessian saddle response on the image smoothed with sigma 1.2, a ring test (four alternating dark/bright sectors with straight edges), growth of a corner grid from a 3-by-3 seed by whole rows and columns, alternating cell colours (each cell against the cells next to it, so uneven lighting across the board is allowed). The search runs on the image and on copies reduced 2, 4 and 8 times (while the smaller side keeps 150 pixels), which finds boards in soft and high-resolution images; the grid with the most corners wins. Then sub-pixel refinement on the full-size image by gradient orthogonality (as OpenCV's cornerSubPix) with a window half-width of 0.3 of the smallest corner spacing (2 to 48 pixels; smaller for a corner near the image border).

Example

I = ones(180, 240); I(21:160, 21:220) = kron(mod(repmat((0:6)', 1, 10) + repmat(0:9, 7, 1), 2), ones(20)); [p, b] = detectCheckerboardPoints(I); b   % [7 10]

Example

I = ones(180, 240); I(21:160, 21:220) = kron(mod(repmat((0:6)', 1, 10) + repmat(0:9, 7, 1), 2), ones(20)); p = detectCheckerboardPoints(I); p(1:2, :)   % [40.5 40.5; 40.5 60.5]

Differences from MATLAB: only whole boards are returned: corners the grid cannot reach are left out rather than given as NaN, so 'PartialDetections' true (the default) and false both behave like false. 'HighDistortion' is accepted and changes nothing. 'MinCornerMetric' and the stereo forms (two image sets) are not supported yet. Boards need at least 3-by-3 inner corners (4-by-4 squares) and squares at least about 10 pixels wide. Large or soft boards are found on the reduced copies (at most 8 times reduced): checked with 640-by-480 test images enlarged up to 12 times (squares up to about 400 pixels) and with Gaussian blur up to sigma 4 pixels plus noise; stronger blur at that size (sigma 6) loses most boards.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.