Small python3 project to recognize Magic The Gathering (MTG) cards from pictures taken, and lookup their prices on the market.
- pillow (image processing) : GitHub
- AWS Rekognition (text recognition) documentation
- AWS Comprehend (language recognition) documentation
- mtgsdk (card name translation) GitHub
- Scryfall REST API (prices lookup) documentation
Clone the repo
$ git clone https://github.com/seriously24/mtg-aws-ocr
$ cd mtg-aws-ocr
Install python dependencies
$ pip install -r requirements.txt
Check that aws is correctly running and configured for your AWS account
$ aws configure
AWS Access Key ID [********************]:
AWS Secret Access Key [********************]:
Default region name [eu-west-1]:
Default output format [None]:
Init the sqlite3 database
$ python database.py -init
Run the main script, either for 1 image, or for a folder containing the images
$ python main.py -img "D:\My Images\OCR\my_best_mtg_card.jpg"
$ python main.py -dir "D:\My Images\OCR"
All the results go into mtg_cards.db, that you can open with an SQLite3 browser. Or you can choose to export the results as an Excel-like CSV.
$ python main.py -img "D:\My Images\OCR\my_best_mtg_card.jpg" -export
$ python main.py -dir "D:\My Images\OCR" -export
If anything went wrong and you want to start all over again, you can reset the database
$ python database.py -reset
You can create a 1-year free account for AWS here. You will also need to create access tokens and IAM users with access to Rekognition and Comprehend Services. Please refer to AWS doc mentioned previously.
This script can only fetch prices for the last edition of the card, there is no way for it to know the actual card's edition for now.