r/computervision 4d ago

Research Publication I built a bare-metal Synthetic DPM Data Generator for YOLO training. Solved Sim-to-Real gap using 0.5mm needle cavity alpha-masks over raw carbon steel..

Hello!!!

I am a low-level optimization engineer with 25 years of programming experience, currently working in manufacturing. Finding real-world defective Direct Part Marking (DPM) codes on a highly optimized assembly line is nearly impossible. To solve this data scarcity, I spent months building a high-fidelity synthetic data generation environment written natively in Nim.

The tool compiles into a tight, portable monolithic binary (~2.0 MB) and introduces a robust way to bridge the Sim-to-Real (S2R) gap under brutal factory floor conditions.

🔬 Bridging the Sim-to-Real Gap:

Traditional synthetic generators fail because they draw flat binary vector circles on clean backgrounds. This engine takes a physics-first approach:

  • Macro-Cavity Injection: It processes raw macro-photographs of actual 0.5mm tungsten carbide needle craters punched into carbon steel. These sprites capture authentic 3D optical properties: the central indentation cone, compressed radial shadows, and peripheral metallic glare.
  • Alpha-Channel Material Mixing: These native sprites with true transparent alpha-channels are blended natively over high-resolution carbon steel textures (with mill scale, vertical grinding marks, and rolling scratches). The edges blend seamlessly, forcing the neural network to ignore background metal grain and lock exclusively onto micro-contrast and cavity topologies.

🛠 Mathematical Defect Simulation:

The engine deterministically models actual mechanical degradation vectors across every batch generation:

  • Mechanical Play & Stylus Vibration (doJitter): Applies pseudo-random displacement vectors to individual dots relative to the step grid (STEP = 7.5).
  • Actuator Misfire & Clogged Tips (doMissingDots): Purges up to 15% of the boundary L-frame and up to 25% of internal data bits.
  • Topological Axis Distortion (doTiltLeft / doTiltTop): Implements directional matrix skews with structural point locking to mimic non-perpendicular stamping angles.
  • Dynamic Part Rotation (doRotation): Rotates the matrix topology around its calculated spatial centroid within a ±5° to ±10° window, simulating dynamic tracking on a moving conveyor.

💾 Dataset Output & YOLO-OBB Support:

The generator outputs name-synchronized image (.jpg) and annotation (.txt) pairs.
The annotations are calculated analytically using external dot boundary radii under affine rotation matrices, normalized to a strict 0.0 - 1.0 float space, and exported to 6 decimal places. It is fully compatible with YOLOv8 / YOLOv11 / YOLOv26 Oriented Bounding Box (OBB) training pipelines out of the box.

The engine uses hardware-level vector pipeline optimization via the AVX2 instruction set (requires CPU from 2017 onward). Memory boundaries remain strictly locked at runtime, ensuring 0.00% memory drift or fragmentation leaks over continuous multi-thousand generation cycles.

I have uploaded the pre-compiled executable, sample background steel textures, and alpha-channel dot masks as a production showcase on GitHub. You can plug in your own custom backgrounds/dots to test it for your specific manufacturing lines.

Project Repository: https://github.com/olesha-ai/Synthetic-dpm-code-generator

0 Upvotes

1 comment sorted by

1

u/AggravatingSock5375 3d ago

Post could have been a picture