Have you ever wondered what happens to the loose LEGO® bricks you sell to us? You tried to sort them out yourself, realised it was more time-consuming than you expected, and decided to sell the pile of bricks to us as a big jumble. Sorting LEGO® pieces might sound simple, but when you’re dealing with over 80,000 different shapes, sizes and colours, it quickly becomes a much bigger challenge.
At WeBuyBricks, we needed a way to identify and sort huge quantities of loose LEGO® pieces efficiently, so we decided to teach a machine how to do it. What started with training AI to recognise individual LEGO® pieces has grown into a much bigger project.
WeBuyBricks has developed a LEGO® sorting machine, lovingly called the Brick-o-matic. It combines cameras, conveyor belts, software and AI to identify individual LEGO® pieces and sort them into sets, shapes or colours. The system first detects a piece, works out exactly what it is and then sends it into the correct tub.
The name Brick-o-matic is a nod towards the crazy inventions of Willy Wonka and Wallace & Grommit.
The Brick-o-matic allows WeBuyBricks to process large quantities of loose LEGO® pieces and organise them into groups that can be matched back to their original sets.
As the team explains:
The big challenge was taking a huge pile of loose LEGO® bricks and figuring out how to sort them back into their original sets.
But teaching a machine to recognise LEGO® pieces is far more complicated than it might sound.
There are so many different LEGO® pieces, from different shapes and sizes to over 100 different colours, some of which are incredibly similar. We had to learn how to recognise all these pieces ourselves, and then figure out how to teach the AI to recognise them too.
The first step is detecting that there is a LEGO® piece that needs to be identified. The machine uses software called an object detector to detect an individual piece.
Once the piece has been detected, a second part of the system, called a classifier, works out exactly which LEGO® piece it is.
This means the system has to complete two important tasks: first, find the piece and then identify it.
Before the machine can recognise LEGO® pieces on the conveyor belt, it needs to be trained. The team starts by putting individual LEGO® bricks into the system and taking dozens of images of them from lots of different angles. These images are then added to a database, helping to build up the information the AI needs to recognise each piece.
The team compares this process to teaching a brain. Just as you need to learn what something looks like before you can recognise it, the system needs to be shown individual LEGO® pieces before it can identify them as they move through the machine.
As the team explains:
There’s a training process at the start where we put individual bricks through the system, take images of them, and add those images to a database. This helps the AI learn what each piece looks like.
The training process is particularly important because LEGO® collections can contain an enormous variety of pieces.

LEGO® pieces come in many different shapes and sizes, with more than 100 different colours to distinguish between. Some colours (like grey, dark grey) can also look extremely similar. That makes identifying individual LEGO® pieces a much bigger challenge than simply recognising whether something is a LEGO® piece. The AI needs to learn the differences between individual pieces so that it can correctly identify them as they move along the conveyor belt./
Teaching the machine all these different LEGO® pieces and developing the AI to recognise them has been a 2-year long challenge.
The LEGO® sorting machine can process around two pieces every second, so it can process around 100,000 pieces a day. This is a significant increase in the number of LEGO® pieces that can be processed compared with the previous manual sorting process.
Before the Brick-o-matic machine was introduced, LEGO® pieces had to be sorted manually. According to the team, the manual process could handle only around 1% of the number of pieces that can now be processed during an eight-hour day.
It processes around two pieces a second down the conveyor, so over an eight-hour day, we could get through around 40,000 pieces. Before we had the conveyor in place, we used to do it all manually.
The Brick-o-matic LEGO® sorting machine is designed to take a large quantity of loose LEGO® pieces and sort them into useful groups. One of the biggest challenges for WeBuyBricks was finding a way to take a mixed pile of loose LEGO® pieces and work out which original sets they could belong to.
The machine can identify individual LEGO® pieces and organise them so they can be matched with the sets they came from. It can also sort LEGO® bricks by colour or organise them in other ways depending on what is needed. This means mixed LEGO® collections can be turned into organised groups without relying entirely on manual sorting.
As the team explains:
We chuck a whole load of loose LEGO® bricks in at one end, and we can sort them back into their original sets. We can also sort them by colour, or in whatever way best matches consumer demand.
Building a machine of this size was a collaborative effort between WeBuyBricks and several specialist partners. The team worked with Monk Conveyor, which helped with much of the hardware, as well as PECAP Technology, a company based in Stirling. The project brought together different areas of expertise, from the physical conveyor system and hardware to the software and AI needed to recognise LEGO® pieces.
Building a machine of this size has been a huge collaborative effort, and we’ve had the pleasure of working with some fantastic partners along the way.
The development of the LEGO® sorting machine has shown what is possible when technology is used to tackle the challenge of processing large quantities of LEGO® pieces. From a great big pile of loose LEGO® bricks, the system can detect individual parts, identify them and sort them into different groups. What previously required extensive manual sorting can now be handled on a much larger scale.
As the team puts it:
I think, between us, we’ve come up with something quite remarkable.
From training AI to recognise thousands of different LEGO® pieces to developing a conveyor system capable of processing around 40,000 pieces a day, the project has transformed how WeBuyBricks can approach the challenge of sorting loose LEGO® pieces.
And it all starts with a pile of LEGO® bricks going in at one end.
The LEGO® sorting machine uses cameras, software and AI to detect and identify individual LEGO® pieces as they move along a conveyor belt. An object detector first identifies a piece, while a classifier then works out exactly which LEGO® piece it is.
The system is trained using individual LEGO® pieces. Images of each piece are taken and added to a database, giving the AI the information it needs to recognise LEGO® pieces as they move through the sorting machine.
The conveyor can process around two LEGO® pieces every second, allowing WeBuyBricks to get through approximately 40,000 LEGO® pieces during an eight-hour day.
There are many different LEGO® pieces, with variations in shape and size and more than 100 different colours. Some LEGO® colours can also be very similar, making it challenging for the AI system to distinguish between individual pieces.
Yes. The sorting machine can take a large pile of loose LEGO® pieces and sort them into groups that can be matched back to their original LEGO® set.
Yes. As well as sorting LEGO® pieces into original sets, the machine can organise LEGO® bricks by colour and can sort them in other ways depending on consumer demand.
Before the conveyor system was introduced, LEGO® pieces were sorted manually. According to the team, the manual process could handle only around 1% of the number of LEGO® pieces that can now be processed during an eight-hour day.
Building the LEGO® sorting machine involved a collaborative effort between WeBuyBricks and specialist partners. Monk Conveyor helped with much of the hardware, while PECAP Technology, a company based in Stirling, was also involved in the project.
Our machine-learning technology is helping us make the process of sorting LEGO® bricks faster and more efficient, but the goal is simple: to give more bricks the chance to be enjoyed again. By carefully identifying and sorting each piece, we can help keep unwanted LEGO® in circulation and make it easier for new builders to discover pre-loved sets. If you have LEGO® sets or bricks you no longer use, sell them to WeBuyBricks and give your collection a chance to start its next adventure.
Would you like to continue the conversation? Share this post!