Skip to main content

Codenames board game pictures parsers.

Project description

Codenames Parser

PyPI version Pipeline codecov Ruff Code style: black Imports: isort Type checked: mypy Linting: pylint

A Python package to parse Codenames game boards from images.
Before we dive in, here are some examples:

Color map extraction

Given color_map.png:

Running:

python -m codenames_parser/color_map/entrypoint.py color_map.png classic

Outputs:

Some parsing logs...

# As emoji table
โฌœ ๐ŸŸฅ ๐ŸŸฆ ๐ŸŸฆ ๐ŸŸฅ
โฌœ ๐ŸŸฆ ๐ŸŸฅ โฌœ ๐ŸŸฆ
๐ŸŸฆ ๐ŸŸฅ ๐ŸŸฅ ๐ŸŸฆ โฌœ
๐ŸŸฆ ๐ŸŸฅ ๐ŸŸฅ โฌœ โฌœ
โฌœ ๐ŸŸฆ ๐Ÿ’€ ๐ŸŸฅ ๐ŸŸฆ

# As list
['NEUTRAL', 'RED', 'BLUE', 'BLUE', 'RED', 'NEUTRAL', 'BLUE', 'RED', 'NEUTRAL', 'BLUE', 'BLUE', 'RED', 'RED', 'BLUE', 'NEUTRAL', 'BLUE', 'RED', 'RED', 'NEUTRAL', 'NEUTRAL', 'NEUTRAL', 'BLUE', 'ASSASSIN', 'RED', 'BLUE']

Board extraction

"Life is not perfect, neither is OCR" (credit: Github Copilot)

Given board.png:

Running:

python -m codenames_parser/board/entrypoint.py board.png heb

Outputs:

Some parsing logs...

# As table
+-------+---------+-------+-------+------+
| ืฆื™ื‘ื•ืจ | ืื•ื˜ื•ื‘ื•ืก | ื™ืฉืจืืœ |  ืžืชื—  |  ื’ืก  |
+-------+---------+-------+-------+------+
| ื‘ืจื™ืช  |   ื’ื•ืฉ   | ืื™ื•ื  | ืžื•ืจื—  | ืงื ื”  |
+-------+---------+-------+-------+------+
| ืœื™ื“ื”  |  ืžื‘ื—ืŸ   | ืื•ื“ื  | ืฉื•ืงื•  | ื—ื˜ื™ืฃ |
+-------+---------+-------+-------+------+
|  ื—ื•ืง  |   ืจืฅ    | ื—ืฆื•ืช  | ืจื“ื™ื•  | ื›ืชื  |
+-------+---------+-------+-------+------+
|  ื’ืจื  |   ื›ื”ืŸ   | ืจื•ืฉื  | ืืœืžื•ื’ |      |
+-------+---------+-------+-------+------+

# As list
[
    "ืฆื™ื‘ื•ืจ",    "ืื•ื˜ื•ื‘ื•ืก",    "ื™ืฉืจืืœ",    "ืžืชื—",    "ื’ืก",
    "ื‘ืจื™ืช",    "ื’ื•ืฉ",    "ืื™ื•ื",    "ืžื•ืจื—",    "ืงื ื”",
    "ืœื™ื“ื”",    "ืžื‘ื—ืŸ",    "ืื•ื“ื",    "ืฉื•ืงื•",    "ื—ื˜ื™ืฃ",
    "ื—ื•ืง",    "ืจืฅ",    "ื—ืฆื•ืช",    "ืจื“ื™ื•",    "ื›ืชื",
    "ื’ืจื",    "ื›ื”ืŸ",    "ืจื•ืฉื",    "ืืœืžื•ื’",     "",
]

* It looks as if the direction of the board is flipped. This is a bug due to Hebrew being written from right to left, the list order is correct.

Installation

pip install codenames-parser

OCR

  1. Uses pytesseract to extract text from images.
  2. Requires tesseract to be installed on the system ( see installing-tesseract).
  3. Download more languages from: https://github.com/tesseract-ocr/tessdata

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codenames_parser-1.0.4.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codenames_parser-1.0.4-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file codenames_parser-1.0.4.tar.gz.

File metadata

  • Download URL: codenames_parser-1.0.4.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for codenames_parser-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7ccecac47d1fd3d79604fc78850dbb16221cf8669c09703cde8f4f7d1aa4b7e5
MD5 595d178ef9daa7beeac9ed65fdbe312b
BLAKE2b-256 d8d6f5a6c2e1e93c910a369ab6a34dfcbb820ff90e50470e3c90ea0e4983c692

See more details on using hashes here.

Provenance

The following attestation bundles were made for codenames_parser-1.0.4.tar.gz:

Publisher: pipeline.yml on asaf-kali/codenames-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codenames_parser-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for codenames_parser-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 38db0f99e58f6fd3353a7f3caeab1753348f7b1d0f5d1b984ee0ecaa1ba0095e
MD5 0d315f869f70bcb1e4c252345d98c7f7
BLAKE2b-256 e123f4dfd5b3520252c12a72b7b88cb70a2627eda80c07462c3cfc975ebd7efa

See more details on using hashes here.

Provenance

The following attestation bundles were made for codenames_parser-1.0.4-py3-none-any.whl:

Publisher: pipeline.yml on asaf-kali/codenames-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page