Skip to content

Repository files navigation

Automating the Detection of Surface Defects in LEGO Bricks

International Elte Summer School in Robotics and Entrepeneurship 2025 project at the University of Southern Denmark (SDU), exploring how to detect surface scratches on LEGO bricks from a very small dataset of extreme-resolution photographs.

Team: Mahmood Seoud · Shinjae Kang · Davide Ragogna · Daniel Bösch

The problem

  • ~100–200 sample images, only of scratched bricks (no clean baseline)
  • 4500×4500 pixel resolution — most scratches are invisible at default zoom
  • Contaminants (hair, fingerprints, dirt) easily get mistaken for scratches
  • Very limited labeling budget

Headline approach: AnomalyDINO

The approach that worked best for us was AnomalyDINO — a few-shot anomaly detection method built on DINOv2 features. With only a handful of "normal" reference crops it localizes scratches directly on the brick surface, no fine-tuning required.

Results gallery

Single scratch detected Multiple scratches detected
single scratch multiple scratches
Anomaly score 0.261 — scratch localized as a clear purple streak. Anomaly score 0.405 — several small scratches lit up near the edge.
Clean brick (true negative) Failure case
no scratch failure case
Anomaly score 0.050 — no spurious hotspots on an unscratched brick. Anomaly score 0.089 — the mask latches onto unrelated edge artifacts while the real scratch stays invisible.

The three approaches we compared

Approach Accuracy Strengths Weaknesses
AnomalyDINO (few-shot) best qualitative results High accuracy, needs only a few normal examples, no training Still needs annotated reference crops
YOLOv11 (tile classification) 74.1% / F1 0.73 Geometry-agnostic after tiling, usable on new bricks Heavy labeling effort per tile
VLM prompting (Llama-4-Maverick via Groq) 71.7% / F1 0.53 Zero-shot, flexible across resolutions and brick types Low precision, inconsistent reasoning

What we also tried — and why we ended up at AnomalyDINO

We first experimented with synthetic data generation in BlenderProc, then built a full CNN pipeline with custom filtering and random tile sampling, and also evaluated a vision-language model. Each had instructive failure modes that pushed us toward the few-shot approach.

The full writeup — pipeline diagrams, filtering design, tile sampling, VLM evaluation, and how to reproduce each experiment — lives in docs/APPROACHES.md.

The original presentation is also checked in: presentation.pdf.

Related work we drew from

About

Explorative project on detecting surface defects on LEGO bricks using computer vision

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages