WeBuyBricks
Last updated: Aug 21, 2026

How We Taught a Machine to Recognise LEGO® Pieces

Header.jpg

Have you ever wondered what happens to the loose LEGO® bricks after you sell them? 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® parts has grown into a much bigger project, including a conveyor system capable of processing around 40,000 pieces a day. It has involved plenty of testing, problem-solving and, as our team puts it, “a lot of head scratching”.

How does WeBuyBricks sort and recognise LEGO® pieces?

WeBuyBricks has developed a brick 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 sort them into groups that can be matched back to their original sets.

As the team explains:

The great challenge was when we get a great big pile of loose LEGO® [bricks], resorting them back into the original sets.

But teaching a machine to recognise LEGO® pieces is far more complicated than it might sound. LEGO® comes in a huge variety of shapes, sizes and colours, with some pieces looking extremely similar to one another.

The amount of different pieces there are ranging from different sizes to over 100 different colours, some of which are so similar.

How did WeBuyBricks teach a machine to recognise LEGO® pieces?

The first step was to break the process down into two parts.

  • First, the machine needs to recognise that there is a LEGO® piece in front of it. This is handled by an object detector.
  • Then, it needs to work out exactly which LEGO® piece it is. That’s where the classifier comes in.

As the team explains:

The first thing we have to do is detect a single part. So, we’ve got something called an object detector and that's software. There's a second part called a classifier and that tells us exactly which part it is.

Before the system could identify pieces, it had to be taught what they looked like.

The machine didn’t simply know what every LEGO® piece looked like from the beginning. The team created a training process where individual pieces were placed into the system and photographed. Those images were then added to a database, giving the system examples to learn from.

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 team describes the process a bit like teaching a brain. The system needs to learn each individual part before it can identify it as it moves along the conveyor belt.

You can think of it a bit like a brain, and you need to teach the system each part before it can then identify parts as they're going down the conveyor belt.

With thousands of different LEGO® pieces to learn, this required plenty of training and testing.

Why is it difficult for a machine to recognise LEGO® pieces?

You might think recognising a LEGO® piece would be easy. After all, someone familiar with LEGO® pieces can often look at one and quickly work out what it is.

For a machine, it isn't quite that simple. Some pieces can look almost identical, while small differences in size, shape or design can completely change which part it is. Then there are the many different LEGO® colours and shades to consider.

The system therefore has to learn these small differences before it can reliably identify each piece.

As the team puts it:

Us learning the pieces and then having to work out the AI aspect of the brain learning them as well. It's been a long challenge.

It wasn't simply a case of building the machine and switching it on. The technology had to be developed, trained and refined over time.

From manual sorting to 40,000 pieces a day

Before the conveyor system was introduced, the team sorted the LEGO® pieces manually. This meant working through the pieces, identifying them and sorting them by hand.

As the team explains:

Previously before we had the conveyor in place we used to do it manually. So, we did probably 1% of that throughout an 8-hour day.

Today, the conveyor system can process around two LEGO® pieces every second – approximately 40,000 pieces during an eight-hour day.

That increase in capacity means WeBuyBricks can process much larger quantities of loose LEGO® pieces in the same amount of time.

What happens on the LEGO® sorting conveyor?

So, what actually happens when a pile of loose LEGO® pieces reaches the conveyor?

The pieces are fed onto the conveyor, where the system detects and identifies them. Once the machine knows what each piece is, it can sort them according to whatever criteria are needed.

As the team describes it:

We chuck in a whole load of loose LEGO® [bricks] at one end, and we can sort it out into the original sets.

Sorting pieces towards their original sets isn't the only possibility. The system can also sort them according to other requirements, giving WeBuyBricks flexibility in how the LEGO® pieces are processed.

We can sort it out into different colour bricks. We can sort it out in whatever way the consumer demand is.

A huge collaborative effort

Developing a machine capable of recognising and sorting LEGO® pieces wasn't a small project. There was no single piece of technology that could do everything on its own. It took software, hardware, engineering, testing and plenty of problem-solving to bring everything together.

The WeBuyBricks team also worked with external partners, including Monk Conveyor and PECAP Technology, during the development of the system.

There was plenty of experimentation and problem-solving along the way, but having the right people involved made a huge difference.

We've had the pleasure of working with some fantastic partners.

Bringing all these different elements together has resulted in a system designed to tackle one of the biggest challenges involved in processing large quantities of LEGO® pieces: working out what all those individual pieces actually are.

As the team sums it up:

I think between us, we've all come out with something quite remarkable.

Frequently Asked Questions

How does the brick sorting machine work?

The machine uses an object detector to identify individual LEGO® pieces and a classifier to determine exactly which LEGO® part each piece is. Once identified, the pieces can be sorted according to different requirements.


How did you teach the machine to recognise LEGO® pieces?

Individual LEGO® pieces were photographed, and the images were added to a database. This gave the system examples to learn from and helped it recognise different LEGO® parts as they moved along the conveyor.


How many LEGO® pieces can the machine process?

The conveyor can process around two LEGO® pieces per second. Over an eight-hour day, this works out at approximately 40,000 pieces.


Can the machine recognise different colours of LEGO® pieces?

Yes. The system has been trained to recognise a wide variety of LEGO® pieces and colours. This can be particularly challenging because LEGO® comes in more than 100 different colours, including shades that can look very similar.


Can the machine sort LEGO® pieces back into their original sets?

Yes. One of the main purposes of the system is to help sort loose LEGO® pieces into groups that can be matched back to their original sets.


Was sorting LEGO® pieces always done by machine?

No. Before the conveyor system was developed, LEGO® pieces were sorted manually. The automated system allows significantly more pieces to be processed in the same amount of time.


Want to give your LEGO® a second life?

All of this technology has one simple purpose: helping us process and sort pre-loved LEGO® pieces so they can be enjoyed again.

If you have unwanted LEGO® sets or loose bricks taking up space at home, why not find out what they're worth? Enter your LEGO® set or weigh your loose bricks on WeBuyBricks to get a price and see how easy it is to sell your unwanted LEGO® sets and bricks.

Created on: Jan 01, 2022

Would you like to continue the conversation? Share this post!

LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorise or endorse this site
10% extra
How We Taught a Machine to Recognise Bricks | WeBuyBricks | WeBuyBricks.co.uk