This README provides instructions for setting up and using the BrickScanner project for the LEGO sorting machine.
Before starting, make sure you have the following files and directories:
./data
and./images
directories- STLs.zip (download and unzip to
./stl/
) - BrickScanner repository or our fork
To set up the necessary files and directories, follow these steps:
# Clone the BrickScanner repository
git clone https://github.com/flowmeadow/BrickScanner
# or our fork...
git clone https://github.com/moukle/BrickScanner BrickScanner2
# Download STLs.zip and unzip it
unzip STLs.zip
# Copy the base_obb_data.pkl file
cp BrickScanner/resources/base_obb_data.pkl ./data
A Docker image is provided with the necessary dependencies already installed and set up. We use x11docker to handle graphical outputs.
- Docker: Installation Guide
- with the buildx plugin
- x11docker: Installation
Follow the steps below to build and run the BrickScanner project.
-
Build: to build the image, run the following command:
docker buildx build --tag lego .
-
Run:
- with GUI (recommended)
x11docker --interactive --webcam \ -- \ "-v $(pwd)/BrickScanner:/lego/src \ -v $(pwd)/stl:/lego/stl \ -v $(pwd)/data:/lego/data \ -v $(pwd)/images:/lego/images" \ lego bash
- without GUI (cams not tested...)
docker-compose run --rm --build scanner
After running the above command, you will have an interactive shell inside the Docker container. From there, you can run the provided scripts, such as real_recon.py, as follows:
./real_recon.py
- with GUI (recommended)
NOTE: all directories are mounted as VOLUME
which means all changes on the host will be directly reflected inside the container and vice versa.
If you have cameras, make sure they are mounted under /dev/video#
. By default, the StereoCam
class assumes camera indices 0
and 2
. Adjust these indices based on your camera setup. You can use the command mpv /dev/video#
to determine the correct indices for your cameras.