Have you ever wondered what happens to the loose LEGO® bricks you sell? 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 it is. Sorting LEGO® pieces might sound simple, but when you’re dealing with thousands of 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 that combines cameras, software and AI to identify individual LEGO® pieces and sort them. The system first detects a piece, works out exactly what it is and then sends it where it needs to go.
This 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 great challenge was we get a great big pile of loose LEGO® bricks, resorting it back into the original sets.
But teaching a machine to recognise LEGO® pieces is far more complicated than it might sound.
The amount of different pieces there are ranging from different sizes to over 100 different colours, some of which are so similar. Us learning the pieces and then having to work out the AI aspect of the brain learning them as well.
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 images of them. 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 in and take images of those bricks and that adds to a database.
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 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.
According to the team, learning all these different LEGO® pieces and developing the AI to recognise them has been a long challenge.
The LEGO® sorting machine can process around two pieces every second. Over an eight-hour working day, that means the system can process around 40,000 pieces. This is a significant increase in the number of LEGO® pieces that can be processed compared with the previous manual sorting process.
Before the conveyor system 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 does two pieces a second down the conveyor. A longer 8 hour day we used to get through around 40,000 pieces a day. Previously before we had the conveyor in in place we used to do it manually.
The 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 in a whole load of loose LEGO® bricks at one end, and we can sort it out into the original sets. We can sort it out into different colour bricks. We can sort it out in whatever way the consumer demand is.
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 taken a huge collaborative effort. We've had the pleasure of working with some fantastic partners.
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 all come out 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.
Would you like to continue the conversation? Share this post!