Skip to content

Repository to identify Lego bricks automatically only using images

Notifications You must be signed in to change notification settings

Gadgeteering/LegoBrickClassification

 
 

Repository files navigation

Lego Brick Sorter Machine

This project is inspired by Daniel West's project to build a Lego sorter

Lego Sorter

This YouTube video is a nice explantion of the three steps to build a Lego sorter

1. Build a dataset to train the AI using the Ldraw Library and use blender to render the image, I have adapted this from J Theiner python script.

Render a Single Brick

Control of the blender script as stand-alone: blender -b -P dataset/blender/render.py -- -i 9.dat --save ./ --images_per_brick 1 --config thumbnail.json

Render Brick Set

render images 50 for each id image size: 224x224x3 brick augmentation: 11,000 official brick colors rotation: in x direction due to no standardized origin: 0, 90, 180, 270 scaling: normalized one dimension and size variation via zooming factor [ ] surface texture and reflexion setting background: random images from Background.jpg image camera position: random on the surface on the upper half of a sphere exposure: random spot on the sphere surface, radius and energy fixed [ ] varying exposure Script to render all images: python dataset/generate_dataset.py

Hint for Mac users to access blender: /Applications/Blender/blender.app/Contents/MacOS/blender -b -P ...

2. Train the AI with Tensorflow using Kaggle using the cloud GPU to produce the preprocess the dataset & classifier model.

Once the Lego Bricks have been rendered it is uploaded to Kaggle 7 to build the Tensorflow Dataset which is compatible with Tensorflow.

Them the model can be trainned from the dataset.

3. Build a image capature and classification process using the classifier model using the OpenMV

System has been build on Raspberrypi Model B but is very slow and the AI has to be executed remotely.

Using the OpenMV it is hoped that the AI deployed onto the local machine.

Requirements / Installation

Blender 2.90 + ImportLDraw
Kaggle Account
OpenMV/RaspberryPI

Thing to Do

Deploy Tensorflow model to OpenMV/RaspberryPi
Build dataset with 100,000 images of brick in Blender

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.9%
  • Batchfile 0.1%