Skip to main content...
CV Depth: the Measurement Pipeline
25 min

Day 75: Pipeline integration: the one API call design

One call in, one structured answer out

The Stage 2 exit criterion is a single API call: image in → {pose, measurements_cm, size, confidence} out. Design that contract deliberately. It should expose enough for a client to render results and understand uncertainty, without leaking pipeline internals. A clean, versioned response schema is a backend instinct that transfers directly — and it's what makes the engine consumable by the Next.js UI and, later, by the Stage 5 gateway.

The Measurement Engine response contract
from pydantic import BaseModel

class Measurement(BaseModel):
    cm: float
    confidence: float
    sources: list[str]        # ["pose", "parsing"] — provenance

class MeasurementResponse(BaseModel):
    measurements: dict[str, Measurement]   # shoulder_width, chest, arm_length...
    size: str                              # "M"
    size_confidence: float                 # 0.91
    pose_detected: bool
    warnings: list[str] = []               # e.g. "low visibility: left_wrist"

Provenance is not optional

Recording which models produced each measurement (sources) is the Stage 2 seed of the model telemetry that becomes central in Stage 5 — 'when a number looks wrong, which component produced it?'. Design the answer to that question into the contract now, and debugging (and the Day-90 honesty report) gets far easier.

Key terms

Response contract
The deliberately-designed schema of a service's output — what it exposes and guarantees to clients.
Provenance
Recording which model/source produced each result, enabling later debugging and telemetry.

Why include each measurement's source models (provenance) in the API response?

We use cookies

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. Learn more

    Day 75: Pipeline integration: the one API call design | RBTechIconX