Magic the Gathering card sorting machine

I've been asked to do research on building a Magic the Gathering card sorting machine by a local shop. I have no experience with Arduinos, but I have experience with electronics (Associates in Mechatronics Engineering). I need to just get pointed in the right direction on what exactly I will need to accomplish this project.

Some details on the cards and how we can go about sorting them:

Every card has a unique symbol on it which represents the release of the card. For example... they have core set releases and will have a M13 (2013 release) on the card. There will then be expansions released throughout the year such as Gate Crash, Return to Ravnica, etc.. Each expansion will have a different symbol.

Here is a sample You can see the symbol on the middle right of the card. Yes, the symbol is small.

Cards will also be sorted by color. There are red, blue, green, black, white, and multicolor cards. We are not interested in sorting the multicolors at this moment. I will build a mechanical system to sort the cards once the symbol has been recognized. I will probably just use rubber wheels and motors to do this. I will obviously need a camera and variable motor control.

Big questions... Is it feasible? About how fast could it recognize the symbol? Which Arduino and shields will I need?

Thanks in advance!

As you can't realistically use a camera with an arduino and you can't do image processing with an arduino then NO.

You could hook the camera to a PC. Have the PC do the image processing and then send commands to the ardiuno.


Had a feeling that might be an issue. Is there any cheap software that I could use? I know MatLab might be capable but that's expensive.

OpenCV is free. Steep learning curve though.

I've also read about BeagleBoard. I don't know much about it but from what I can understand you can plug the camera into that. Is that true? I believe it is Uno compatible.

I believe it is Uno compatible

Never heard that.

Sorry Newb. Pardon my ignorance. Beagleboard is an alternative.

Which Arduino should I be looking to get and what shields? I know there are color recognition ones.

Just wanna get an idea so I can do some more research.

It seems like you're doing this backwards. To me it makes more sense to figure out the other hardware first. Figure out how you're going to scan the cards using the pc, which will give you an idea of what sort of data you'll be working with. Then figure out how you're going to send commands based on that data to the arduino. Then you'll need to figure out what hardware is going to be used for sorting the cards. Once you know all that, you can choose an arduino based on the requirements of your chosen hardware rather than taking a wild guess as to what might work.

If you want to do without the PC then look at the raspberry Pi.


I have seen the gameboy camera being used on the Arduino as well as optical mouse sensors turned into cameras on the Arduino.

With the gameboy camera, you would need to buffer the pixel data yourself. It is analog, so you would need to store 10 bits for every pixel (unless you use an algorithm to determine BLACK or WHITE for 1 bit per pixel.) The resolution is 123x123, so you would still need about 1.9K of RAM to hold the full image. But if you can pull that off, you would compare that pixel map to one stored in memory. Obviously, you would need some intelligence to determine matches of imperfect pictures.

With the optical mouse sensor, the frame buffer is stored internally in the chip. But of course, you still need to store your comparison picture in flash somewhere. But, the resolution is 18x18, pixel data is 1 byte per pixel (0 to 63).

So, the real limitation is the amount of RAM you have for a buffer and the amount of flash you have for your comparison pictures. Unless there is some very unique characteristics that you can compare against without having to store the entire image, you probably aren't going to have enough storage space.

Something to experiment with might be to use just a single line of the mouse sensor at a time and seeing if you can come up with a deductive method to eliminate symbols.

For color, just use a color sensor.

The most complex part of the job is the card recognition. It would be feasible to do this on a PC using OpenCV, but you will need to get up to speed with image processing and OpenCV.

Unless you have some compelling reason you haven't mentioned yet preventing you from using a PC, I wouldn't bother looking for any other platforms for the image processing.

Making the card handling hardware will need some specialised skills. I expect you'll already know whether you have these. I expect it'll need switches and motors and sensors and so on and the Arduino will enable you to interface these to the PC. You will need to decide how much of the logic you put on the PC and how much on the Arduino, and I suggest your main criteria should be to produce the simplest interface between them. For example: a command to load the next card; notification that the card has been loaded; a command to send the current card to a destination; notification that the card has been sent.

I think you should first focus on getting the computer to analyze a picture of a card and then match it. Do not try to rely on the symbols on the cards. First, not all cards have symbols. Alpha, Beta, Unlimited, Revised, 4th, and 5th did not have symbols. Knowing how to tell the difference between these means you look at some different details. Also, there are editions that have duplicated the edition symbols. Chronicles is a good example of that. Cards from Arabian Nights, Antiquities, Legends, and The Dark were all reprinted in that edition and their symbols were used again. So any identification method has to rely on more than just the symbol. I do not know what it would take to build equipment/software to take a picture of the card in question and then compare the full picture against a database. Not sure on the speed either. If it takes 1 minute for the program to identify the card then that will bog down any kind of sorting machine. My guess is the machine needs to make the decision in a second or so. At 1 card per second, it should take a little over 15 minutes to go thru a 1000 cards and get a list of what is in there. Then the computer organizes that list and then physically moves the cards to match the organized list. Plus, it would be nice to automatically move that list into a database or at least into a file that can be exported.

I have an idea on how to get the machine to physically handle the cards. Rely on an arm that uses air pressure and a cup for suction. That way you do not have to try to find a way to grab the card by its edges. You can avoid grabbing more than one card at once and also maybe prevent damaging the card. I am thinking of a tube with a cup at the end and there is an air flow that can be turned on or off, maybe even reversed. When the computer wants to pick up the card the cup is positioned on top of the card and the air flow is turned on. The pressure difference will catch the card. It would not take much pressure. The arm can then move and when you want to drop the card you either kill the air flow or reverse the pressure.

As for sorting technique, here is the method I think would work. The first pass thru the cards the machine scans each one and keeps in memory the name/edition/version of the card and its location in the stack. Then it will go thru the main stack and move the cards to smaller stacks logically. Kind of like a sort of physical array sort. It is sorted on a ranking based on a master list in memory that is set by the user. Personally, I would want by Edition and then by Alphabet and then by Version (for the editions with multiple versions of the same card) but there are many different collectors out there who want their collections organized different ways. The computer program keeps track which stack each card was put in. It will move the cards into stacks and then back into the main stack. Each time it does this it partially organizes all of the cards. After a couple of iterations you should have the cards sorted. I know I have simplified my explanation but from what I have seen of sorting programs and also physical sorting methods I think it would work.

Well, this is a subject I have been putting a lot of thought to lately. I am not too experienced in building electronics but I do deal in data and have had to work on sorting and organizing data. Would love to see how far along you can get this. If you have any questions let me know.

I have an interest in developing this product. Possibly to commercialize it, even. Care to collobarate?


I've already developed this... -Jp-

@Jpizzal: do have you project described somewhere?

Maybe this product can be commercialized using crowdsourcing? I guess a lot of people would be happy to have this.

@jpizzal Future plans?

Are you planning to extend the capability to more than 2 piles? I have the name identification down as well but it's the mass card manipulation that's the tricky bit (assuming it will be quite portable).

You would make your life easier using a Raspberry Pi with a Camera module. It has more processing power and can do image recognition.

It would actually be easier to go for a text recognition approach. Reading the card name and query a database. That will give you all the information about the card. Set, color, rarity, etc. Some cards are re-released across sets but that's a minor detail as there aren't too many of those you'll see unless running a very large range of cards.

I'd be very careful about how your machine handles these cards, as they do have value based on their condition. Don't need your contraption putting creases in a $60 mythic rare.

The lesson to learn off the bat, though, is that this is not an arduino-only task.