← back to Damla Su Bilge

stitchu: turning a garment photo into a sewable pattern

by Damla Su Bilge
C++ / WASM / computer vision · technical documentation

Abstractstitchu takes a photograph of a garment, seven body measurements, and returns a calibrated, print-ready A4 sewing pattern you can cut against fabric. The draft is produced by a deterministic C++ engine compiled to WASM, running in the browser: every line traces to an explainable pattern-cutting formula rather than a model that guesses. This document describes the layered architecture, the drafting geometry, the contract that binds the layers, and the verification matrix of 70,200 drafts that every release must pass.

open stitchu → dated patch log

1overview

A sewing pattern is cut against real cloth. If the same measurements produced a slightly different pattern next time, someone wastes money and fabric. So the governing rule of the engine is same input, same pattern, every time. A rented probabilistic model cannot promise that the way owned deterministic code can, and the deterministic engine costs 0 tokens per draft, whether one person opens it or a thousand do.

stitchu began as a Swift iOS app. The valuable core turned out to be the drafting engine underneath the screens, so the identity moved onto a C++ core; every platform is now a thin consumer of the same draft, and the website reaches it through WASM.

2the pipeline

photo โ”€โ”€โ–ถ Cloudflare Worker (vision) โ”€โ”€โ–ถ confirmed GarmentSpec โ”‚ 7 measurements (local) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ–ผ C++ engine (WASM, in-browser) geometry core โ†’ blocks โ†’ garment drafter โ†’ validator โ”‚ โ–ผ web app: SVG render โ†’ tiled A4 PDF

Vision reads the garment photo and describes what it is; a spec turns that reading into structured garment data; the C++ engine drafts the pattern pieces from the spec plus the measurements; the pieces are laid out flat and exported as a tiled, calibrated A4 PDF.

3the contract

One versioned contract binds every layer boundary. garment-spec.schema.json is the semantic garment language: closed enums and bounded scalars, the only language the vision model or a human speaks. The render layer is deliberately not in the contract; each renderer compiles its own parameters from the semantics, and a runtime gate (additionalProperties:false) strips any render knob smuggled into a vision answer.

tables.json holds every shared value (skirt lengths, EU size chart, gather ratios, cross-layer word maps) and is generated into the C++, web and backend so consumers never copy numbers by hand. A guard, validate-contract.mjs, runs as a test and fails on any schema drift, vocabulary defect, or generated-file desync.

4geometry core

Point, path and cubic-Bezier primitives, seam-length measurement, outline offsetting, and self-intersection checks. All geometry is in millimeters; each piece lives in its own local space; curves are flattened to 24 segments for length and 16 for self-intersection. These were unit-tested before anything was built on them.

5drafting blocks

Parametric blocks (bodice, skirt, sleeve) are drafted from published pattern-cutting sources: FreeSewing (Bella/Titan), Muller & Sohn, Winifred Aldrich. They are driven by seven measurements plus percent ease, never a fixed centimetre. Assumptions the app does not collect (for example underbust โ‰ˆ bust โˆ’ 70 mm, shoulder drop โ‰ˆ 13ยฐ) are labelled in the formula spec and covered by a muslin warning in the sewing guide.

Every constant now lives in one machine-readable table with a status field: verified, assumed or refuted, each row carrying its source and the experiment that set its status. A 2026 paper-sloper comparison against an independent Aldrich hand draft verified the shoulder-slope and shoulder-seam values and refuted two legacy ones.

6seam allowance

The piece outline is the sewing line; the cut line is a drawn outward offset. The outward side is found empirically by probing the longest edge's normal with a point-in-polygon test, because traversal direction is not trusted (an area-sign heuristic once shipped an inward offset). After the per-edge offset, an envelope pass pushes any point closer than the allowance back out to exactly it, which tames concave curves whose radius is below the allowance, such as a sleeve underarm.

7the validator

Geometric invariants run on every draft and again at runtime before any PDF: side-seam balance, dart sums, armhole and cap ease, waist joins, self-intersection, print fit, cut-line sanity. A broken pattern cannot reach the printer. These invariants are physical facts about garments: side seams must balance, bust ease must survive the pipeline, a sleeve cap must converge on its armhole. If any breaks, the output is not slightly off, it is unsewable fabric.

8verification

The matrix drafts EU 34 to 52 plus edge bodies across the full spec space, 70,200 drafts, all of which must validate. Per-feature checks assert piece geometry, printability (a tile cap of 3000 mm) and a byte-identical base draft when a feature is off. A committed golden reference is compared at 0.1 mm tolerance: the engine was first ported from Swift against a Swift golden dump of 2,805 drafts for port fidelity, then re-pinned to the C++ output once precision truing deliberately improved on the original geometry.

The public benchmark tracks a different, harder number: how many of 54 real product photos become a complete, sewable pattern. Every change is measured and published, the misses included, in the dated patch log.

9who built it

stitchu is built and documented by Damla Su Bilge, one of 50+ projects and 20+ live products on noseydewdrop.com.

1 / 4

last update: 2026-07-24 · in active development, everything here may change tomorrow