MTG OCR – Introduction

Using OCR to identify and manage Magic: the Gathering cards is not a new idea. There are many, many applications of it throughout time and space. However, for me, it is a good excuse to learn some python, learn some image editing, learn some OCR, basically just learn a bunch.

OCR, Optical Character Recognition in full, is the process by which you have a computer identify text in an image. This is exceptionally easy for humans, as sight is the primary method by which we interact with the world, but a surprisingly difficult challenge for computers. Computers are used to thinking about text in terms of individual characters with well-defined values. The letter O is not a large circle, but rather the value U+004F. A computer doesn’t understand the visual context that informs whether or not a given vaguely-uniform circle is a letter, or just a circle. OCR aims to build a system that allows it to do this.

OCR is useful in its application to MTG cards, because MTG collections tend to be large. My current collection stands at about 18,000 cards, with an individual card value being anywhere between $0.01 and over $50. While most people will have a good idea of which cards are valuable and/or wanted, that information is fuzzy and unreliable.

Ideally, I’d like a system that

  • accepts a big box of cards
  • takes them one at a time
  • passes them in front of a camera
  • identifies the card by set and printing number (which provides a unique reference for each printing of each card)
  • sorts the card into one of many buckets, depending on a provided strategy

The biggest hurdle in this is identifying the card by set and printing number, which is where the OCR comes in. It’s also the most code-intensive part of the project. Given I’m a programmer, it makes sense to start here.