A Python package to parse Codenames game boards from images.
Before we dive in, here are some examples:
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']
"Life is not perfect, neither is OCR" (credit: Github Copilot)
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.
pip install codenames-parser
- Uses
pytesseract
to extract text from images. - Requires
tesseract
to be installed on the system ( see installing-tesseract). - Download more languages from: https://github.com/tesseract-ocr/tessdata