Assembling the working prototype Part 2| #MyCardSorter DevLog 4

Prototype with wheel under the cards

Reworking the card dispenser and incorporating OCR was no easy task. In this edition of the DevLog, I will showcase what I did to enhance the card dispenser and how I added card detection using OCR.

Note: This is part of a series of blog posts I am currently writing (Fall 2023), reflecting back on my journey. I acknowledge that some details might be a bit fuzzy, as I failed to document my progress from the beginning. Nevertheless, I wanted to provide a write-up.

In the previous DevLog, I had completed all three components necessary for the prototype: card dispensing, holding and releasing a card from the tray, and taking a picture of the card. Since I was dissatisfied with the card dispenser, I chose to rework it. The goal in this step was to create a new dispenser, detect the card, and determine if the card held value or was a bulk card.

Reworking the card dispenser

After witnessing the current iteration of the machine in action, I aimed to devise a solution that would allow me to refill the card dispenser while the machine operated. The optimal solution was to enable top loading. I deconstructed the dispenser and embarked on constructing a new one with the intent of positioning the servo motor's wheel beneath the card stack, similar to the previous version's front position.

I implemented Michael's concept (as seen in the first blog post) by incorporating a wheel into the dispenser, which acted as a card blocker. I attached it with tiltable blocks, allowing me to configure the height. It took some time to find the correct position and calibration, and I recognized that this part might be somewhat unstable with the available parts. Nonetheless, I managed to make it work!

Prototype with wheel under the cards
Prototype with wheel under the cards

After assembling this version, I concluded that I needed to elevate all components to accommodate a box under the tray, which would catch the cards.

Video file

In the video, you can observe the new version coming together seamlessly. Please note that I continued using the "Push-Pull" mechanism to tidy up the card stack. With this phase complete, the next task involved coding, specifically implementing card detection using OCR.

Detecting the cards

The plan involved intercepting the process after capturing a card's picture. I opted to use Azure Cognitive Vision, thanks to its generous free tier. Fortunately, I discovered a GitHub project that had already implemented card detection for MTG cards using Python. It had components I could leverage to kickstart this phase of the project!

The Repo:

Huge thanks to Quentin Fortier!

The process essentially worked as follows: I generated a local database with all MTG card names and utilized the text result from the OCR to identify a card. While it lacked features like identifying the correct version of the card, this sufficed for my immediate goals. Implementing it was relatively straightforward, as I only needed to create my own wrapper class and let the script handle the rest.

Naturally, this had a considerable impact on the project's performance. Initializing and loading the database consumed a significant amount of time, and card detection, as well as retrieving card prices, required interactions with multiple services. To reduce the number of price queries, I swiftly decided to cache all known prices. This way, the next time the same card name was detected, I only had to consult the cache table, instead of requesting the price again. This greatly enhanced overall performance!

A screenshot of the running script with card detection

Sorting the cards

Having obtained the prices for the cards, the next task was to take action based on the information. I aimed to sort the cards into two categories: bulk (indicating minimal value) and valuable cards.

The initial idea that came to mind, and could be implemented with the parts I had on hand, was to reconfigure the card tray where the card would be scanned. The previous version merely released the card into the box, which was insufficient. I revamped it to ensure that the entire tray could tilt left or right, depending on the card's value, and direct the card into one of two boxes. While this solution worked to some extent, I wasn't entirely satisfied with it, as you might deduce from the following video.

Video file

Of course, this solution wasn't the final one I adopted, but it was a fun experiment. Shortly after, I had another solution in mind, which I built and will discuss later. I had a second servo motor (the one with the substantial wheel) ready to go and used it, along with some leftover smaller wheels, to transport cards into different boxes.

The new tray

The large wheel spins the smaller wheels, which then direct cards into either box.


Video file

I was genuinely content with this version; it worked exceptionally well! There were some issues, such as cards not always landing perfectly in the boxes (due to the fatpack boxes' imperfect shape), but overall, I succeeded in sorting 10,000 cards with this setup. Of course, this wasn't accomplished in a single go; it took some time. I continued to refine the version in the video, making improvements on the software side. I enhanced the dispenser's flexibility, reduced the pullback time, and made the system more error-tolerant overall.

In conclusion, the journey of refining MyCardSorter has been an exhilarating endeavor filled with unexpected challenges and rewarding solutions. With a determined spirit and a thirst for improvement, I've reshaped the card dispenser to make it more efficient and adaptable. The relentless pursuit of automation led me to the world of Optical Character Recognition (OCR) and the integration of Azure Cognitive Vision. Through the use of OCR, the machine has been empowered to not only capture card images but also recognize their names.

Moreover, I've strived for efficiency, knowing that time is of the essence when sorting a vast collection of Magic: The Gathering cards. To this end, the process has been streamlined by implementing caching mechanisms, resulting in quicker access to card data.

The path of sorting cards into two distinct categories - bulk and valuable - presented its own unique challenges. While I initially ventured into a tilting tray solution, I soon realized the need for a more effective method. Enter the servo motor and a clever system of wheels, guiding cards precisely to their designated destinations.

With each step of this journey, I've been met with moments of satisfaction and others filled with the excitement of discovery. It's essential to remember that innovation often comes from iteration, and this project embodies this principle.

As I move forward, the possibilities for MyCardSorter are boundless. In the next phase of this adventure, I'll delve into the future and lay the groundwork for what's to come. Stay tuned for more updates on this quest to create the ultimate card sorting solution!


Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Duncan (not verified)

3 months 2 weeks ago

Wow! I'm really impressed and excited to see how far you've gotten with this. Not only is it working better than I expected for the low-tech mechanics, but it's also so approachable!

I've been bouncing around the thought of attempting just such a magic card sorter for over a year now. I'm a much less experienced developer, so I have been pretty intimidated by the software side of things. I've mostly stuck to researching, trying to find similar projects and existing work. I'm so glad to have found your blog! I'm much more confident now that I can follow in your footsteps.

I'm looking forward to seeing more updates about your project. Thank you for sharing it!

Member for

2 months 1 week


2 months 3 weeks ago

In reply to by Duncan (not verified)

Hello Duncan,

thank you very much for your nice feedback! Sorry that I missed it, I had a lot of stuff todo and did not check the comments.

Really great to hear that you are more confident now and try to build something on your own. Please let me know your progress :) 

I will update my blog soon, have a lot to talk about. :)