Man Buys Two Metric Tons of LEGO Bricks; Sorts Them Via Machine Learning

iStock // Ekaterina Minaeva
iStock // Ekaterina Minaeva

Jacques Mattheij made a small, but awesome, mistake. He went on eBay one evening and bid on a bunch of bulk LEGO brick auctions, then went to sleep. Upon waking, he discovered that he was the high bidder on many, and was now the proud owner of two tons of LEGO bricks. (This is about 4400 pounds.) He wrote, "[L]esson 1: if you win almost all bids you are bidding too high."

Mattheij had noticed that bulk, unsorted bricks sell for something like €10/kilogram, whereas sets are roughly €40/kg and rare parts go for up to €100/kg. Much of the value of the bricks is in their sorting. If he could reduce the entropy of these bins of unsorted bricks, he could make a tidy profit. While many people do this work by hand, the problem is enormous—just the kind of challenge for a computer. Mattheij writes:

There are 38000+ shapes and there are 100+ possible shades of color (you can roughly tell how old someone is by asking them what lego colors they remember from their youth).

In the following months, Mattheij built a proof-of-concept sorting system using, of course, LEGO. He broke the problem down into a series of sub-problems (including "feeding LEGO reliably from a hopper is surprisingly hard," one of those facts of nature that will stymie even the best system design). After tinkering with the prototype at length, he expanded the system to a surprisingly complex system of conveyer belts (powered by a home treadmill), various pieces of cabinetry, and "copious quantities of crazy glue."

Here's a video showing the current system running at low speed:

The key part of the system was running the bricks past a camera paired with a computer running a neural net-based image classifier. That allows the computer (when sufficiently trained on brick images) to recognize bricks and thus categorize them by color, shape, or other parameters. Remember that as bricks pass by, they can be in any orientation, can be dirty, can even be stuck to other pieces. So having a flexible software system is key to recognizing—in a fraction of a second—what a given brick is, in order to sort it out. When a match is found, a jet of compressed air pops the piece off the conveyer belt and into a waiting bin.

After much experimentation, Mattheij rewrote the software (several times in fact) to accomplish a variety of basic tasks. At its core, the system takes images from a webcam and feeds them to a neural network to do the classification. Of course, the neural net needs to be "trained" by showing it lots of images, and telling it what those images represent. Mattheij's breakthrough was allowing the machine to effectively train itself, with guidance: Running pieces through allows the system to take its own photos, make a guess, and build on that guess. As long as Mattheij corrects the incorrect guesses, he ends up with a decent (and self-reinforcing) corpus of training data. As the machine continues running, it can rack up more training, allowing it to recognize a broad variety of pieces on the fly.

Here's another video, focusing on how the pieces move on conveyer belts (running at slow speed so puny humans can follow). You can also see the air jets in action:

In an email interview, Mattheij told Mental Floss that the system currently sorts LEGO bricks into more than 50 categories. It can also be run in a color-sorting mode to bin the parts across 12 color groups. (Thus at present you'd likely do a two-pass sort on the bricks: once for shape, then a separate pass for color.) He continues to refine the system, with a focus on making its recognition abilities faster. At some point down the line, he plans to make the software portion open source. You're on your own as far as building conveyer belts, bins, and so forth.

Check out Mattheij's writeup in two parts for more information. It starts with an overview of the story, followed up with a deep dive on the software. He's also tweeting about the project (among other things). And if you look around a bit, you'll find bulk LEGO brick auctions online—it's definitely a thing!

Wednesday’s Best Amazon Deals Include Computer Monitors, Plant-Based Protein Powder, and Blu-ray Sets

Amazon
Amazon
As a recurring feature, our team combs the web and shares some amazing Amazon deals we’ve turned up. Here’s what caught our eye today, December 2. Mental Floss has affiliate relationships with certain retailers, including Amazon, and may receive a small percentage of any sale. But we only get commission on items you buy and don’t return, so we’re only happy if you’re happy. Good luck deal hunting!

Connect Your Nintendo Switch Audio to Wireless Headphones With This Bluetooth Adapter

StackCommerce
StackCommerce

This article contains affiliate links to products selected by our editors. Mental Floss may receive a commission for purchases made through these links. If you haven't received your voucher or have a question about your order, contact the Mental Floss shop here.

One of the top gifts this holiday season is the Nintendo Switch ($300), and playing it with others is one of the safest ways to connect this year. You can make game time even more social with this Bluetooth adapter that can connect your Switch, smartphone, and wireless headphones simultaneously. That means you can listen to music, Switch audio, and even chat while you play. And through December 5, you can get it for just $36.54 with the code DEC15 at checkout.

The adapter works with a simple two-button design that houses the latest Bluetooth 5.0 technology and an advanced DSP algorithm to combine audio from your Switch and smartphone to stream wirelessly to your headphones or speakers.

The product earned itself a 4.7-star rating on Amazon, with reviewers saying, “The HomeSpot Bluetooth Adapter Pro is a must-have accessory for the Nintendo Switch” and, “I just ordered air pods for traveling and now I can listen to my Switch and/or whatever music or podcast I want all at the same time!”

The HomeSpot Bluetooth Audio Adapter Pro has five intuitive indicators that show operation at a glance. All of that functionality is housed in a pretty low-profile design that fits seamlessly with the Nintendo Switch and Nintendo Lite. The set comes with one adapter, one USB-C to USB-A converter, and a pouch for storage.

For a limited time, the HomeSpot Bluetooth Audio Adapter Pro is 14 percent off at a final price of $43. It's the perfect gift to keep your pals connected after a year of Zoom fatigue.

Prices subject to change.

Sign Up Today: Get exclusive deals, product news, reviews, and more with the Mental Floss Smart Shopping newsletter!