(Active development on this product stopped August 2019)
This project came out of a mix of boredom and really wanting to play with Legos again after so many years. I've seen countless videos of card sorters online but just couldn't get any of the designs to work they way I wanted them to. So, I made my own.
Allow me to introduce Karn.
Unfortunately Karn can't auto-feed from a stack of cards so it does require a little more manual attention than other similar card sorters. Karn does however offer incredible versatility with the card reading and scanning processes that make it an incredibly fun build to tinker with.
Once a card is inserted into the loading bay, the camera focused through an "optical array" (read: 3 reading glass lenses) will take a picture. That picture is then cropped to just the card name.
This picture is then uploaded to an Amazon S3 bucket and processed through the Rekognition service. Using the image-to-text feature, the card name is pulled from the supplied picture and sent back to the program.
After we receive the card name, the Scryfall api is called for the current price of the supplied card and returns that data to the end user. The data is then logged in two output files "cards.txt", for just the card names, and "mtgcards.csv", which includes price data in a searchable format. If no match for the card name can be found on Scryfall, an error is thrown and a second picture is taken. This process repeats up to five times before giving up, prompting the user to either keep retrying or move on to a different card.
Once a card has been successfully processed and logged, a servo dumps the positioned card and a new card can be inserted. This process will continue until the program is terminated with a "q" input after a card is read. It will then print out the total value of all the cards scanned in this session, how much you'd probably be able to sell the cards for at a store, and the percentage of cards that weren't scanned successfully.Update_CSV
Lastly, there's a "bonus" script in the repo that runs on the output mtgcards.csv from sort_lookup. Update_csv.py combines all card entries with the same name, foiling, and set into one row before updating all price data from Scryfall. This allows you to keep a digital representation of your entire collection and just update it at whatever rate you see fit.
For each card where there's a considerable change in price, a message is printed to console.
Price pulling can take some time, since Scryfall only has limited resources so they ask you only do one api call every 50-100 milliseconds. There's a wait statement in the code to honor this request.
There are two big issues with the current iteration: ignoring of sets and foils when being scanned through Rekognition. While there is support to include sets and foiling with the Update_csv by including tags like "*f*" or "[INS]", so far it's impossible for the card scanner to pick up on this info. Reading set symbols is a feature I'd love to include in a design down the line, it's not one I have time to develop right now. As it stands, Scryfall will return the cheapest print of the card as the associated price so at best, a user will be pleasantly surprised by their cards' value. As for foilings, either the reading process needs to identify foils either through some light thing or other magic...or foiling is data to be put in to the final spreadsheet by the end user which seems tedious at best.
It is with a heavy heart I share this news - Karn died today, surrounded by his friends after sorting one last pack of Adventures in the Forgotten Realms. I decided I wanted to build a Pi-hole and Karn's brain is the only Raspberry Pi I have so...
One silver lining, I can confidently say no Lego jobs will be lost in the transition to a network monitor. Given how much I like over-complicating things I'm sure I'll turn whatever Karn's brain becomes into a big contraption as well.