Case study · Computer vision & industrial automation · October 2025

AI-powered garment measurement and quality inspection.

How computer vision can turn a photo of a garment into structured measurements, and how that prototype could grow into an industrial inspection workstation and a measurement platform for apparel brands.

Built by
Insaf Inhaam & Bavaram Karunaaharan
Type
Computer vision R&D
Stack
Python · OpenCV · NumPy · SciPy
Status
Working software prototype
Proposed garment inspection workstation: an overhead camera and LED light bars on an aluminium frame above a matte table with calibration targets, a flat T-shirt, an operator screen and an edge processor
Proposed hardware concept. The working prototype today is software only.

The challenge: a “medium” isn't one size.

One supplier's medium T-shirt can differ from another's in chest width, shoulder width and length. Stores often publish a generic size chart instead of the real measurements of each garment, because measuring every item by hand is slow and two people rarely measure it the same way.

We set out to test whether a photograph could capture garment dimensions consistently enough to make measurement faster, repeatable and digital from the start.

BuiltReal output from the prototype

What we built.

  1. A white T-shirt laid flat at an angle on a grey surface, with a green 5 cm calibration square beside it
    01 · Input
  2. Edge map of the same photo: the T-shirt outline and the calibration square as white lines on black
    02 · Edge map
  3. Result image: garment outline, axis-aligned and rotated boxes, a chest measurement line and a measurement panel
    03 · Measured
  1. 01

    Capture

    A photo of the garment laid flat, with a 5 × 5 cm green square in frame.

  2. 02

    Calibrate

    The square is found by colour and shape, giving a pixels-per-centimetre scale.

  3. 03

    Detect

    Edges are enhanced and the garment outline is isolated from the background.

  4. 04

    Measure

    Width and length are read from the outline, corrected if the garment is rotated.

  5. 05

    Review

    An annotated image and a measurement report are saved for the operator to check.

The engineering behind it. Python and OpenCV, built as separate modules for detection, classification, measurement and drawing.

  • Finding the reference square reliably

    The calibration square is searched in two HSV colour ranges to cope with different lighting, and every green candidate is scored on area, solidity and squareness. The best-scoring shape sets the scale.

  • Getting a clean garment outline

    Fabric texture and soft shadows break simple edge detection. The pipeline combines bilateral filtering, contrast enhancement (CLAHE), two Canny passes at different thresholds and morphological closing to join broken edges.

  • Garments that aren't laid straight

    Both an axis-aligned box and a minimum-area rotated box are computed. If the garment is tilted by more than 5°, measurements follow the rotated box instead of overstating the width.

  • Classifying without a training set

    We tried a YOLOv8 model, but general-purpose models don't recognise garment types. The working version classifies by shape instead, using aspect ratio, solidity and how far the sleeves extend from the body.

Prototype result on a blue polo shirt: detected outline, bounding boxes, a chest line, the calibration square details and a measurement panel
A harder case: a polo with a collar, placket and texture

Known limits of the prototype

  • One global scale assumes the camera is square to a flat garment. Tilt and depth differences add error.
  • Shoulder width is estimated from chest width, not measured from landmarks.
  • It needs a flat garment on a plain, contrasting background.
  • Accuracy has not yet been validated against tape measurements across many garments.

These limits are exactly what a fixed inspection station is designed to remove.

Proposed hardware concept

From a phone photo to an inspection station. Same software, controlled conditions.

A fixed camera height, even lighting and calibration targets on the table remove the variables that limit a hand-held photo. Camera, lens and table size would be chosen from the largest garment and the tolerance a manufacturer needs, and validated before any accuracy is promised.

Edge processorRaspberry Pi 5 (8 GB) for capture, calibration and the operator interface; heavier models on a Jetson or in the cloud
CameraHigh-resolution camera at a fixed height; Pi Camera Module 3 for R&D, a machine-vision camera for production
LightingDiffused LED bars for even, shadow-free light, switched through a driver, never straight from GPIO
Inspection surfaceMatte or backlit table that separates any garment colour from the background
CalibrationChArUco targets for lens distortion, scale and perspective correction
Operator controlsTouchscreen for review and a physical capture button
Proposed

A connected measurement platform.

  1. Garment
  2. Camera
  3. Edge device
  4. Measurement engine
  5. Cloud platform
  6. E-commerce / ERP

Inspection · T-shirt, size M

Interface concept
Point of measureTargetMeasuredToleranceResult
Chest width52.052.3±1.0PASS
Body length70.071.5±1.0FAIL
Shoulder width44.044.2±0.5PASS
Illustrative values in centimetres, not prototype measurements
POST /v1/measurements

{
  "measurement_id": "meas_demo_001",
  "status": "completed",
  "garment_type": "t_shirt",
  "unit": "cm",
  "measurements": {
    "chest_width": 52.3,
    "body_length": 70.5
  },
  "requires_review": false
}
Mock response showing the proposed API contract
  • Tolerance checks per point of measure, flagged pass, fail or review
  • Inspection history, batch summaries and CSV or PDF export
  • Size charts published to Shopify and other stores after human approval
  • Organisation accounts, device management, API keys and webhooks

Roadmap.

  1. Phase 1

    Built

    Software prototype

    Photo-based garment detection, calibration and measurement in Python and OpenCV.

  2. Phase 2

    Proposed

    Hardware R&D

    Fixed camera, controlled lighting, lens calibration and a validation study against manual measurements.

  3. Phase 3

    Proposed

    Platform

    Cloud dashboard, tolerance-based quality inspection, multi-tenant accounts and e-commerce APIs.

Questions, answered.

How can computer vision measure garments?

A photo of a flat garment is segmented to find its outline, and an object of known size in the same photo converts pixels to centimetres. Measurements are then taken from the outline or from detected landmarks such as shoulder and sleeve points.

Why is image calibration important?

Without a known reference, a photo has no physical scale. Lens distortion and camera tilt also stretch parts of the image, so production systems correct for both with camera calibration and perspective correction before measuring.

What are the limits of smartphone garment measurement?

Hand-held photos vary in height, angle and lighting, which changes the scale across the image. A fixed overhead camera with controlled lighting removes most of that variation, which is why we propose a workstation for production use.

Can garment measurements feed an e-commerce store?

Yes, through an API: measurements are returned as structured data that can populate product size charts after a person reviews them. We would never overwrite a store's existing measurements without approval.

Exploring computer vision for your manufacturing workflow?

Throughout builds software, AI and automation for complex operational problems, from a first prototype to a validated system.