EasyOCR Card Scanner is a tool to automatically recognize and rename TCG images using OCR and relevant APIs.
- Magic: The Gathering
- Pokémon
- Lorcana
- Automatically recognizes card names using OCR.
- Identifies card details by querying relevant APIs.
- Renames card image files based on identified card names.
- Logs processing details for error checking.
- Can use OpenAI API for critical error scanning.
The tool uses a configuration file tcg.cfg to set up directories and options. Below are the options supported in the configuration file:
- mtg_folder: Directory path where Magic: The Gathering card images are stored.
- pokemon_folder: Directory path where Pokemon card images are stored.
- lorcana_folder: Directory path where Lorcana card images are stored.
- logging_level: Logging level (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL). Default is
WARNING. - is_flipped_mtg: Set to
trueif MTG card images are flipped; otherwise,false. Default isfalse. - is_flipped_pokemon: Set to
trueif Pokemon card images are flipped; otherwise,false. Default isfalse. - is_flipped_lorcana: Set to
trueif Lorcana card images are flipped; otherwise,false. Default isfalse. - pokemon_api_key: API key for accessing the Pokemon TCG API.
- openai_api_key: API key for accessing the OpenAI API for critical error scanning.
- CleanUpMode: Set to
trueto enable cleanup of empty error directories; otherwise,false. Default istrue. - NoPrompt: Set to
trueto automatically run the critical error scanner instead of prompting for user input; otherwise,false. Default isfalse. - preprocessor_enabled: Se to
trueto enable the preprocessor. This will automatically rotate the image according to EXIF and crop the image if it's larger than the size threshold. - size_threshold: Set to 2300 by default
The expected directory structure for the card images is as follows:
├── mtg_folder
│ ├── Set1
│ │ └── Process
│ ├── Set2
│ │ └── Process
│ └── ...
├── pokemon_folder
│ ├── Set1
│ │ └── Process
│ ├── Set2
│ │ └── Process
│ └── ...
└── lorcana_folder
├── Set1
│ └── Process
├── Set2
│ └── Process
└── ...
To install the required modules, use:
pip install unidecode requests easyocr Pillow numpy opencv-python
python easyocr_card_scanner.py
- Sign up for an account at OpenAI.
- Navigate to the API section and generate a new API key.
- Copy the API key and add it to the
openai_api_keysetting in yourtcg.cfgfile.
- Sign up for an account at Pokemon TCG API.
- Navigate to the API section and generate a new API key.
- Copy the API key and add it to the
pokemon_api_keysetting in yourtcg.cfgfile.
The tool logs its activities in log.txt located in the same directory as the script. The logging level can be configured in the tcg.cfg file.
If the tool fails to recognize or identify cards, check the log.txt for detailed error messages. You can also enable DEBUG logging in the tcg.cfg for more verbose output.
- EasyOCR for providing the OCR capabilities used in this tool.
- Scryfall for the Magic: The Gathering card API.
- Pokémon TCG API for the Pokémon card API.
- Lorcana API for the Lorcana card API.
- OpenAI for use of the GPT-4o vision API.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.