01

Reading cards by camera

Card games are sometimes recorded or broadcast with cameras that read the cards on the table. A computer vision model can be trained to recognise each card from a photograph, usually by looking at the corner, where the rank and suit symbols are printed. It must report both the rank, such as queen or seven, and the suit.

02

Many designs

Although the 52-card French-suited deck is standard, card designs vary widely. Different manufacturers use different fonts, symbol shapes, colours and borders. Court cards, the jack, queen and king, are drawn in many styles. A model that works on one deck may struggle with another.

03

Memorising a deck

If a model is trained only on photographs of a few decks, it may learn features specific to those decks: the exact shape of the letter Q in one font, or a particular shade of red. It could score highly on test images from the same decks while failing on a new design.

04

Hold out a design

A fair test reserves a complete deck design for testing only. None of its cards appear in training. If the model still reads ranks and suits correctly, it has learned the general symbols. If its accuracy drops sharply, it was relying on features of the familiar decks.

05

Two separate scores

Rank and suit are different pieces of information, and errors in each reveal different problems. Confusing a 6 and a 9 is a rank error, perhaps due to rotation. Confusing hearts and diamonds is a suit error. Counting them separately shows where the model needs improvement.

06

The colour shortcut

Hearts and diamonds are both red, while clubs and spades are both black. If a model calls every red card a heart, it is using colour as a shortcut and has not learned to distinguish the heart and diamond shapes. A test with many diamonds would expose this weakness quickly.

07

Corner crops

Using only the corner of each card has advantages. The corner contains the essential rank and suit, and it is visible even when cards overlap in a hand. But corners are small, so image quality, focus and lighting matter. Tests should include blurry and angled corners.

08

Other suit systems

Not all playing cards use French suits. German, Swiss, Italian and Spanish decks use different suits, such as acorns, bells, cups and swords. A model trained only on French suits would not recognise these, and should not be expected to unless trained on them.

09

Why it matters

Shortcuts like these are common in machine learning. A model that seems accurate in testing may fail in real use if the test data are too similar to the training data. Holding out whole groups, such as a deck design, is a practical way to test generalisation.

10

Responsible testing

The NIST AI Risk Management Framework encourages developers to evaluate AI systems under conditions that reflect real use. For a card reader, real use means new decks, different lighting and cards held at angles.

11

Rotated corners

Cards are printed with symbols in two opposite corners, so they read correctly either way up. But a 6 turned upside down can look like a 9 in some fonts. Tests should include cards photographed at different rotations.

12

Jokers and blanks

Many decks include jokers and blank or advertising cards, which have no standard rank or suit. A reader should recognise them as special cases rather than force them into one of the 52 classes.

13

Try the arithmetic

If a model reads 52 cards from a new deck and gets the rank right on 50 and the suit right on 39, its rank accuracy is about 96 per cent but its suit accuracy only 75 per cent, showing that suits are the main problem.

14

The idea to take away

A card reader might memorise a deck's font or colour. Holding out a whole new deck design tests whether it recognises symbols more broadly. Count rank and suit errors separately, because they reveal different weaknesses.

FOLLOW THE EVIDENCE

Sources & further reading

Figures in the example are illustrative. Photograph: original AI-generated illustration (Adobe Firefly), created for this story. Reference organisations do not endorse this website.