Print a standard 8 x 8 chessboard for camera calibration and you have built an ambiguity into the dataset before the first shutter fires: rotate that board 180 degrees and the image is pixel-for-pixel identical, so no detector can tell one orientation from the other. Calibration procedures therefore ask for an odd number of squares along one side and an even number along the other. This explainer gives the parity math behind that rule, the corner-count arithmetic, a lens and sensor sizing example at 1.5 m, code that draws an odd-by-even board in MATLAB, and the checks to run before you trust a board — for monocular, stereo and LiDAR-camera rigs alike.
Why does a calibration checkerboard need odd by even squares?
Because a board with an odd count on one side and an even count on the other has no 180-degree rotational symmetry: every interior corner then has a square-pattern neighborhood that exists nowhere else on the board, so a detector can index each corner consistently from any viewing angle.
Number the squares by row i and column j, and give square (i, j) the color (i + j) mod 2 — that one line is the whole checkerboard. With m rows and n columns, a 180-degree rotation carries square (i, j) to position (m + 1 - i, n + 1 - j). The rotated pattern equals the original exactly when m + n is even, and only then.
An interior corner is where four squares meet, and the 2 x 2 color block around it follows the same parity. When m + n is even, a corner at one end of a diagonal and its partner at the other end sit inside identical 2 x 2 blocks, and so does every pair the rotation connects. When m + n is odd, each of the (m - 1)(n - 1) corners owns a neighborhood that appears nowhere else — exactly what a detector needs to hand you a stable corner list.
Decide by addition: 5 x 4 squares (sum 9) works, while 4 x 4 (16), 5 x 5 (10) and 9 x 9 (18) are all self-identical under rotation. Print one of those and the corner numbering is ambiguous no matter how crisp the print is.
What actually breaks when both sides have the same parity?
Corner numbering, and every index built on it: on an 8 x 8 board each corner has a diagonal twin with an identical 2 x 2 neighborhood, and when the board turns between frames the detector can hand your code the same physical corner under two different indices.
The failure is silent because it is self-consistent. Given an 8 x 8 board, a detector finds all 49 interior corners, reports a low reprojection error, and orders the list from either end of the board depending on where it locked on. Intrinsics averaged over many poses usually survive that. Anything that cares about the board's orientation does not.
Stereo and hand-eye calibration feel it first: the board's own coordinate frame comes out rotated 180 degrees about its normal, so a pose computed from the board lands mirrored. In LiDAR-to-camera calibration, image corners are matched to LiDAR returns on the board face, and a flipped index pairs a return from the wrong end of the board, putting the extrinsics off by an error on the order of the board's own width. A square same-parity board adds a second trap: remounted after cleaning with a 90-degree turn, it looks exactly like the board you calibrated with.
Corners that are found but ordered two ways are the quiet failure; corners that are not found at all are the loud one, and checkerboard corners not detected: fix gaps in your target covers those causes.
How many squares does the board need?
Draw 9 x 6 or 7 x 6 squares — 40 and 30 interior corners per view — and capture 15 to 20 poses at varied tilts; treat 20 corners per view as the practical floor for intrinsics, and the 12 corners of a 5 x 4 board as enough for pose only.
Interior corners, the points a detector actually reports, number (columns - 1) x (rows - 1). That off-by-one deserves emphasis: count squares when you print, corners when you configure the detector, because a 9 x 6 square board is declared to most APIs as an 8 x 5 pattern.
| Squares (columns x rows) | Interior corners | Sum of counts | 180° image | Verdict |
|---|---|---|---|---|
| 8 x 8 | 7 x 7 = 49 | 16, even | identical | ambiguous |
| 9 x 9 | 8 x 8 = 64 | 18, even | identical | ambiguous |
| 9 x 6 | 8 x 5 = 40 | 15, odd | different | use it |
| 7 x 6 | 6 x 5 = 30 | 13, odd | different | use it |
| 5 x 4 | 4 x 3 = 12 | 9, odd | different | pose only |
Corner count and pose variety set the floor together: forty corners over 15 to 20 tilted poses is a solid intrinsics set. Sizing the physical board for your reach, robot poses and depth-camera range is its own sum, covered in checkerboard calibration target size: how many squares and how big and, for robot work, hand-eye calibration target size: how big a board your poses need.
Printing your own board is fine at bench scales, but machined and photographic targets hold pitch that an office printer cannot, and both kinds sit in the calibration targets range.
Adapters, tubes, prisms, targets
376 models · from $23.00How big should each square be at your calibration distance?
Size the square to at least 20 pixels on a side at the farthest pose, which works out to an edge between one twentieth and one tenth of the field of view. Below 20 pixels the subpixel corner fit runs out of edge gradient to interpolate, and corner noise climbs quickly.
Work backwards from that farthest pose, and let the board fill 60 to 80 percent of the narrower frame dimension so tilted poses still land inside the frame:
Worked example, a stereo rig calibrating at 1.5 m. The board is 7 x 6 squares of 100 mm, so 700 mm wide by 600 mm tall, targeted at about 70 percent of frame width. The camera is a 1/2-inch-class 5 MP sensor, 2448 x 2048 pixels on 6.4 x 5.3 mm — 2.6 µm pixels.
- Field of view width: 700 mm / 0.70 = 1000 mm.
- Magnification: m = 6.4 mm / 1000 mm = 0.0064.
- Focal length: f = 1500 mm x 0.0064 / 1.0064 = 9.5 mm, so fit a 10 mm lens.
- Recheck with the real lens: m = 10 / (1500 - 10) = 0.0067, so FOV = 6.4 / 0.0067 = 954 mm wide and 790 mm high; the board fills 700 / 954 = 73% of the width and 600 / 790 = 76% of the height.
- Pixels per square: 2448 x 100 / 954 = 257 pixels, nearly thirteen times the floor.
- Corner repeatability: a 0.1-pixel subpixel error corresponds to 0.1 x 954 / 2448 = 0.039 mm on the board.
Aperture settles depth of field. At f/5.6 the geometric estimate 2 x WD² x N x c / f², with c = 2 pixels = 0.0052 mm, gives 2 x 1500² x 5.6 x 0.0052 / 10² ≈ 1300 mm of sharp zone centered on the 1.5 m plane — roughly 0.9 m to 2.2 m, which holds every pose in a normal capture set.
Run your own sensor through the lens focal length calculator and the depth of field calculator. The same board-sizing walk-through for stereo pairs is in checkerboard size for stereo calibration at 1 to 1.5 m, and the way target requirements grow with range is in checkerboard calibration fails at distance: depth camera target size.
Why can't the built-in checkerboard() call make an odd count?
Because the function assembles the board from tiles of 2 x 2 squares: checkerboard(100, 3, 5) returns a 600 x 1000 pixel image, 6 squares by 10, and both counts are twice the tile counts — even — whatever integers you pass.
In MATLAB, checkerboard(P, M, N) returns M tiles tall by N tiles wide, each tile four P x P squares. Twice any integer is even, so an odd-by-even board is out of reach by construction. Two fixes:
-
Crop a quarter. Call
checkerboard(P, r, c)and keep half the rows and half the columns; the remainder is exactly r x c squares, so pass the square counts you want as the tile counts.checkerboard(100, 5, 4)yields a 1000 x 800 pixel board of 10 x 8 squares, and its top-left 500 x 400 quarter is a clean 5 x 4 board. One trap to avoid: halving both axes of a 3 x 5 tile call leaves 3 x 5 squares — odd by odd, sum 8, even — a board that is self-identical again. Halve one axis only, or pick tile counts of opposite parity. -
Draw the grid yourself, which also lets you set border margins:
cols = 5; % integer: squares across
rows = 4; % integer: squares down; cols + rows = 9, odd
sq = 200; % integer: pixels per square edge
board = zeros(rows, cols); % rows x cols double, 0 = black square
board(1:2:rows, 1:2:cols) = 1; % white squares, first parity class
board(2:2:rows, 2:2:cols) = 1; % white squares, second parity class
img = repelem(board, sq, sq); % 800 x 1000 pixels, values 0 and 1
imshow(img, [])
% Rotation test: 1 = asymmetric (usable), 0 = self-identical (ambiguous)
~isequal(rot90(board, 2), board)
The last line is the parity rule as code: it returns 1 for the 5 x 4 board, and 0 after changing rows to 5. Run it on the artwork before you print. In any other language the construction is identical: fill a rows x cols array at (i + j) mod 2, repeat each cell by the square edge in pixels, and export at a known scale.
Does the parity rule apply to circle and dot targets too?
Yes — any pattern that repeats on a symmetric grid inherits the same ambiguity, which is why production circle and dot targets are made asymmetric: alternate rows offset by half a pitch, a marked origin point, or fully coded dots, so every point has an address.
A symmetric circle grid mispairs exactly like an even-by-even chessboard: the point pattern maps onto itself under rotation and the index list flips with it. Breaking the symmetry in the pattern itself fixes it permanently, and a fitted circle center averages more edge samples than two straight edges meeting, which is why circle grids often win on defocused or low-contrast images. The capture side is covered in stereo camera calibration with a circle grid target; when the dots refuse detection, MATLAB dot pattern calibration: detect the points yourself shows the manual route.
For close-range distortion and scale work, machined dot grids such as the LS-LXR-0029 — a dot grid with 0.5 mm dots on a 76 x 76 mm face — hold pitch far beyond any office printer.
- Type
- Calibration targets
What should you check before the first capture?
Run six checks on the physical board before the first image: parity of the counts, calipered pitch, pixels per square at the farthest pose, matte finish, flat mounting, and declaring corners rather than squares to the detector.
-
Parity. Count squares down one edge and across the other; the two counts must sum to an odd number. On generated artwork, run the rotation test:
~isequal(rot90(board, 2), board)must return 1. - Pitch. Measure square center to square center with calipers in two places, average, and enter the measured value in the calibration, never the drawing's nominal — a scaled print introduces a proportional bias that survives averaging over poses.
- Pixels per square. Recompute at the farthest pose; 20 pixels is the floor and 100 or more is comfortable.
- Finish. Matte black squares only. Glossy ink under a tilted board throws specular highlights that swallow corners, and the fix is a reprinted board, not more light.
- Flatness. Bond the print to glass or an aluminium plate. A board bowed 2 mm reports its corner positions 2 mm wrong, and that error lands directly in the extrinsics.
- Detector declaration. Tell the detector (squares - 1) per side, in corners. A 9 x 6 board is an 8 x 5 pattern.
Then capture the way stereo depth camera calibration: target capture and stream setup describes, and if corners still drop out, checkerboard calibration not detecting corners: what to check walks the usual causes; the 3D vision topic page collects the rest of the workflow. If the rig includes a laser-line or LiDAR sensor, respect its laser class notice and keep eyes out of the scan plane while you move the board. If the target is one part of a new cell, configure the system or size the board with us through the contact page.
Questions
Is an 8 x 8 chessboard usable for camera calibration?
No, not safely. An 8 x 8 board is identical to itself under a 180-degree rotation, so corners in every diagonal pair have matching 2 x 2 neighborhoods and the detector can order the list from either end — a silent flip of the board's frame. Use 9 x 6 squares (40 interior corners) or 8 x 5 (28); the side sums are 15 and 13, both odd, so neither board has a twin orientation.
Why does my detector ask for an 8 x 5 pattern on a 9 x 6 board?
Because the pattern size is counted in interior corners, where four squares meet — a 9 x 6 square board gives (9 - 1) x (6 - 1) = 40 points, so you declare 8 x 5. Declaring 9 x 6 instead makes the detector hunt for corners that do not exist, and detection fails on every image even though the board itself is perfect.
Can I rescue an even by even board I already printed?
Yes. Mask one full column or row of squares with matte material the color of the background: an 8 x 8 board with one column covered presents 8 x 7 squares — even by odd — with 7 x 6 = 42 interior corners and no rotational twin. Keep the tape edge exactly on the grid line and flat, because a lifted edge shifts the apparent corner position.
How accurate must the printed square size be?
Measure it and use the measured value. Focal length and scene scale come from the ratio of target size to image size, so a board printed 1% small biases focal length and every reconstructed distance by about 1%, and extra poses do not average that away. Caliper the pitch in two places, average, and enter that number instead of the drawing's nominal.
Is a small 3 x 3 or 4 x 4 board enough for a quick calibration?
For intrinsics, no. A 3 x 3 board has (3 - 1) x (3 - 1) = 4 interior corners and a 4 x 4 has 9, too few constraints per view even before their symmetry problem. A 7 x 6 board gives 30 corners in a similar footprint, and 15 poses of it beat 50 poses of a small same-parity board. Small boards are acceptable only for pose checks with intrinsics already known.
