Archived
2
0
Fork 0
A very simple poker table recognition
This repository has been archived on 2026-11-20. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Rust 66.5%
  • Python 33.5%
Find a file
2026-11-14 09:53:12 +00:00
adr feat: handle the another table layout 2026-11-14 09:53:12 +00:00
floppa feat: handle the another table layout 2026-11-14 09:53:12 +00:00
floppa_alphabet feat: one floppa command with the full alphabet and annotated output 2026-11-13 14:51:21 +00:00
floppa_detector feat: add a symbol detection mode 2026-11-13 20:36:17 +00:00
.editorconfig chore: add repository scaffolding 2026-11-13 12:16:55 +00:00
.gitignore chore: add repository scaffolding 2026-11-13 12:16:55 +00:00
AGENTS.md feat: add an OCR command-line tool 2026-11-13 14:46:58 +00:00
Cargo.lock feat: add a symbol detection mode 2026-11-13 20:36:17 +00:00
Cargo.toml feat: add a symbol detection mode 2026-11-13 20:36:17 +00:00
dprint.json chore: add repository scaffolding 2026-11-13 12:16:55 +00:00
README.md feat: handle the another table layout 2026-11-14 09:53:12 +00:00
rustfmt.toml chore: add repository scaffolding 2026-11-13 12:16:55 +00:00

Floppa

Detect symbols and table state in an image with the ocrs OCR engine. The floppa crate contains the library and the single floppa binary.

There is one processing mode: the class-agnostic symbol detector followed by the table-state reconstruction. The old text-line mode and --symbols flag are gone.

Usage

cargo run --release -- image.png

The command writes three files next to the input:

  • image_bbox.png — every symbol and card bbox, line underlines and line labels;
  • image_data.json — symbols, lines, cards and the derived table state;
  • image_table.png — only table data: card boxes, players and pot.

The default stem is the input stem, so photo.jpg produces photo_bbox.jpg, photo_data.json and photo_table.png.

Use -o to choose the bbox image path; data and table files are written beside it with the same stem:

cargo run --release -- image.png -o annotated.png
# writes annotated.png, annotated_data.json and annotated_table.png

An image without an extension uses .png for images.

The detector is class-agnostic: it finds character-shaped regions first and classifies each region afterwards. It does not train on screenshots of a particular application.

Data

image_data.json is the raw layout plus a conservative table state:

{
  "image": "image.png",
  "width": 900,
  "height": 140,
  "symbols": [
    {
      "text": "10",
      "bbox": { "x": 265, "y": 39, "width": 76, "height": 55 },
      "detector_score": 0.94,
      "classifier_score": 0.95
    }
  ],
  "lines": [
    {
      "text": "10♦",
      "bbox": { "x": 265, "y": 39, "width": 110, "height": 55 },
      "symbols": [0, 1]
    }
  ],
  "cards": [
    {
      "bbox": { "x": 223, "y": 250, "width": 62, "height": 86 },
      "rank": "4",
      "suit": "♣",
      "symbols": [69, 86, 91],
      "partial": false,
      "back": false
    }
  ],
  "table_state": {
    "game": "NLH",
    "table_name": "Diamond 05",
    "stakes": { "small_blind": 5.0, "big_blind": 10.0 },
    "unit": "$",
    "board": [
      {
        "rank": "4",
        "suit": "♣",
        "bbox": { "x": 223, "y": 250, "width": 62, "height": 86 }
      }
    ],
    "pot": 45.0,
    "pot_bbox": { "x": 353, "y": 226, "width": 91, "height": 14 },
    "players": [
      {
        "seat": 0,
        "name": "Chok Dee",
        "level": 24,
        "stack": 990.0,
        "bet": null,
        "hole_cards": [],
        "bbox": { "x": 47, "y": 167, "width": 76, "height": 52 }
      }
    ],
    "dealer": null
  }
}

lines[].symbols are indices into the flat symbols array. Lines are clustered by the lower edge of each glyph with a small tolerance, then recognized as a whole so word spaces survive. Descenders get a bounded exception. Symbols assigned to a card are excluded from lines and appear only in cards.

cards groups symbols by bright, solid-colored or light card surfaces. Each card has a bbox, the top-left rank and suit, indices into symbols, and a back flag for face-down cards. Light and dark patterned backs are split when several cards touch. table_state is built from lines and cards:

  • level badges are short numeric lines;
  • the name is the nearest alphabetic line below a badge;
  • the stack is the nearest amount below the name;
  • names with a stack but no level are included with level: null;
  • seats are ordered clockwise around the image centre;
  • the board is the largest contiguous, central horizontal row of at least three cards;
  • other cards, including backs, are attached to the nearest player as hole_cards;
  • $5 / $10, $0.02 / $0.05, Total Pot — <value> and the table header become stakes, pot, game and table name;
  • stacks and the pot accept $ or BB, including decimal values;
  • the dealer button is found by its gold plate and D glyph and assigned to the nearest player;
  • unknown bets and unknown card values stay null rather than being guessed.

Table image

image_table.png contains only table data:

  • each card is drawn with its overall bbox and its rank + suit below; backs show ?;
  • each player is drawn only with the bottom edge of the bbox containing the player's badge, name, stack and face-up cards; below it is <D: if dealer><nick> — <stack> <cards>;
  • the pot is drawn as a bbox with Total Pot — <value> below.

The bbox image keeps the debugging view: every symbol box, line underline and line label.

Short UI lines are re-segmented when the detector missed a glyph, boxes containing several recognized characters are split, and short line boxes are tightened to the components in the line crop. Short alphanumeric lines can also extend through a continuous run of text, which recovers names such as FelipeMelo. The rank 10 and card symbols stay as one box.

Small dark level badges are recognized as positive text even when the neural detector misses them on a colored or busy background.

The symbol mode embeds the character detector and recognition model and needs no model download. Individual glyphs are classified first, then nearby glyphs are re-recognized as a line. Uncertain and multi-character candidates are kept until after this regrouping. If the detector merged a glyph, the line text is distributed across the boxes and merged boxes are split afterwards, except for the rank 10 and card symbols. A quality gate drops isolated non-card symbols, weak lines, line outliers and low-contrast photo-like crops. Unusual fonts, low-contrast amounts and tiny glyphs can still be confused.

The alphabet is the printable Latin alphabet plus the four card suits ♠ ♥ ♦ ♣, so the command always recognizes the whole set. The output contains the base Unicode characters without the emoji variation selector. Append U+FE0F in post-processing if emoji presentation is needed.

The engine runs neural-network inference, so use a release build.

Layout

  • adr/ — architecture decision records;
  • floppa/ — the library, the binary, the alphabet and the models;
  • floppa_alphabet/ — the training project for the alphabet, with no runtime code and no binary;
  • floppa_detector/ — the training project for the character detector.

See adr/alphabet.md for the card-suit model, adr/symbols.md for the character detector, adr/table.md for table-state reconstruction, and floppa_alphabet/training/README.md for retraining.