Magic: The Gathering card scanner with Raspberry Pi and Lego

Michael Portera‘s trading card scanner uses LEGO, servo motors, and a Raspberry Pi and Camera Module to scan Magic: The Gathering cards and look up their prices online. This is a neat and easy-to-recreate project that you can adapt for whatever your, or your younger self’s, favourite trading cards are.

“Magic: The What Now?”

For those of you who aren’t this nerdy [Janina is 100% this nerdy – Ed.], Magic: The Gathering (or MTG for short) is a trading card game first launched in 1993. It’s based on a sprawling fantasy multiverse storyline, and is very heavy on mechanics — the current comprehensive rules fill 228 pages! You can imagine it as being a bit like Dungeons and Dragons, with less role-playing and more of a chess vibe. Unlike in chess, however, you can beat your MTG opponent in one turn with just the right combination of cards. If that’s your style of play, that is.

Magic: The Gathering card scanner with Raspberry Pi

Scanning trading cards

So far, there are around 20000 official MTG cards, and, as with other types of trading cards, some of them are worth a lot of money.

Michael is one of the many people who were keen MTG players in their youth. Here’s how he came up with his project idea:

I was really into trading cards as a kid. I recently came across a lot of Magic: The Gathering cards in a box and thought to myself — I wonder how many cards I have and how much they’re worth?! Logging and looking these up manually would take a while, so I decided to see if I could automate some of the process. Somehow, the process led to building a platform out of Lego and leveraging AWS S3 and Rekognition.

LEGO, servos and camera

To build the housing of the scanner, Michael used LEGO, stating “I’m not good at wood working, and I thought that it might be rough on the cards.” While he doesn’t provide a build plan for the housing, Michael only used bricks from in the LEGO Medium Creative Brick Box he bought for the project. In addition, his tutorial includes a lot of pictures to guide you.

Magic: The Gathering card scanner with Raspberry Pi

Servo motors spin plastic wheels to move single cards from a stack set into the scanner. Michael positioned a Raspberry Pi Camera Module so that it can take a picture of the title of each card as it is set before the lens. The length of the camera’s ribbon cable gave Michael a little difficulty, so he recommends getting an extension for it if you’re planning to recreate the build.

Magic: The Gathering card scanner with Raspberry Pi

Optical character recognition and MTG card price API

On the software side, Michael wrote three scripts. One is a Python script to control the servos and take pictures. This, he says, “[records] about 20–25 cards a minute.”

Another script identifies the cards and looks up their prices automatically. Michael tried out OpenCV and Tesseract for optical character recognition (OCR) first, before settling on AWS S3 and Rekognition for storing and processing images, respectively. You’ll need an AWS account to do this — Michael used the free tier, which he says allows him to process 5000 pictures per month.

Raspberry Pi Magic The Gathering card scanner

A sizeable collection

Finally, the data that Rekognition sends back gets processed by another Python script that looks up the identified cards on the TCGplayer API to find their price.

Michael says he’s very satisfied with the accuracy of the project’s OCR. He found out that the 920 Magic: The Gathering cards he scanned are worth about $275 in total. He provides a full write-up plus code over on

And for my next trick…

You might be thinking what I’m thinking: the logical next step for this project is to turn it into a card sorter. Then you could input a list of the card deck you want to put together, and presto! The device picks out the right cards from your collection. Building a Commander deck just became a little easier!

What trading cards would you use this project with, and how would you extend it? Also, what’s your favourite commander? Let me know in the comments!


Steve avatar

I love the idea, but I’m not sure I could trust my cards to a machine fed system like that. I could just see one getting bent, or stuck so that the wheel rubs on the card, or causes some other damage.

Henrique Araujo avatar

I guess this is really useful to sort those bulk commons and uncommons that are kept into boxes without any kind of sorting.

Expensive cards you kind of know them, anyway.

(I wouldn’t trust any card that I knew beforehand that is higher than 5 USD to this machine either)

swak avatar

This is awesome! I am a MTG player and a collector myself but I have been needing to get rid my extras and I have 10 pi’s and a few of them are collecting dust so I am going to create this to help catalog. Thank you for the build.

Jon Seager avatar

I was doing a weekend night job for a client and while waiting for a process to complete noticed a business card reader on a desk. I played around with it the following night with some mint cards with a white like background, the cards weren’t worth the cost of a stamp. Anyhow it was the DuplexScan 1210 that scans both sides w/o any bending. I ran some through with a sleeve and some w/o. There is even an option to eject the card in the front or back. Put your cards in sideways in the middle and you will get a straighter scan. I wouldn’t try it w/ a thicker bent Bowman Chrome though.

Comments are closed