e67f0ccef0
The operator's category choice is a hypothesis, not truth (user, 2026-09-06): each wash order with a vehicle read queues a package for a trusted reviewer over the private overlay (Netbird); the verdict becomes the phase-B training label and the per-operator error rate. wiki/concepts/vision-review-outbox.md. - Boxes: the vision service returns the vehicle bbox; snapshot.ts stores the vehicle and plate boxes on the read as FRACTIONS of the analysed frame (the stored snapshot is a downscaled copy); vehicleForIdentity() returns them. - carwash_review_outbox (migration 0031) + review-outbox.ts: crop = detector box + 8 % margin, ≤ 640 px, plate blurred in place from the plate box; payload carries a pseudonymous booth id and a keyed operator hash — no site name, no plate, no OSD, no bystanders; multipart POST with a per-booth bearer; 2xx → sent (image dropped); 400/404/413/415/422 → abandoned; anything else → backoff 1 min·2^n capped 6 h; voided orders and items older than 14 days abandoned unsent. Nothing queued while unconfigured. - Enqueue is fire-and-forget off the intake path in createOrder; the loop runs every CARWASH_REVIEW_INTERVAL_SEC (60) and stops on close. - GET /api/carwash/review/status (site:read) + a "Remote review" line in Setup → Car wash. - Env CARWASH_REVIEW_URL / _TOKEN / _BOOTH_ID (all three or off) documented in .env.example and forwarded by compose. - Tests: review-outbox.test.ts (crop + blur on a synthetic frame, config/pseudonyms, queue/drain/backoff/abandon, through the app). Wiki: new concept page, index, venue-modules As built, log. The collector is not built. Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
71 lines
2.6 KiB
Python
71 lines
2.6 KiB
Python
"""The /analyze response contract — the shape the Node VisionClient adapter consumes.
|
||
|
||
Mirrors the first-cut API in wiki/entities/opencv-anpr-service.md:
|
||
{ plate: {text, confidence, bbox}|null, vehicle: {...}|null, modelVersion, tookMs }
|
||
Job 2 (vehicle attributes) is scaffolded as an optional field, not yet populated —
|
||
fast-alpr is plate-only; the vehicle stage is built later on the same ONNX runtime.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class BBox(BaseModel):
|
||
"""Plate bounding box in pixels (top-left origin)."""
|
||
|
||
x1: int
|
||
y1: int
|
||
x2: int
|
||
y2: int
|
||
|
||
|
||
class PlateResult(BaseModel):
|
||
text: str
|
||
# The plate's confidence = the MIN of fast-alpr's per-character confidences (a plate
|
||
# is only as trustworthy as its weakest character). See recognizer.py.
|
||
confidence: float = Field(ge=0.0, le=1.0)
|
||
bbox: BBox | None = None
|
||
# Predicted issuing region/country (advisory; fast-alpr's global model emits this).
|
||
region: str | None = None
|
||
|
||
|
||
class VehicleResult(BaseModel):
|
||
"""Job 2 — vehicle attributes. `body_type` is ADVISORY: the Node server records it
|
||
beside the plate and the Car Wash desk pre-selects the site category it maps to; the
|
||
operator decides, a disagreement is flagged, nothing is ever gated on it. Values come
|
||
from the shared vocabulary (car, sedan, hatchback, suv, minivan, pickup, van, truck,
|
||
bus, motorcycle) — anything else is ignored by Node. Phase A (a COCO detector) emits
|
||
car/truck/bus/motorcycle; the finer classes need the body-type classifier. Not yet
|
||
produced by any bundled recognizer."""
|
||
|
||
colour: str | None = None
|
||
body_type: str | None = None
|
||
# Confidence of `body_type` (0–1). Node compares it to the site's threshold.
|
||
confidence: float | None = Field(default=None, ge=0.0, le=1.0)
|
||
# The vehicle's box in frame pixels — the crop a reviewer sees / a classifier eats.
|
||
bbox: BBox | None = None
|
||
make: str | None = None
|
||
model: str | None = None
|
||
|
||
|
||
class AnalyzeResponse(BaseModel):
|
||
# The single best plate, or null when none was found.
|
||
plate: PlateResult | None = None
|
||
# All plates found (a frame may contain several vehicles).
|
||
plates: list[PlateResult] = Field(default_factory=list)
|
||
vehicle: VehicleResult | None = None
|
||
# True when the best plate is below the confidence floor — Node should treat the
|
||
# read as advisory only and prefer the ticket path. See fail-state-safety.
|
||
low_confidence: bool = False
|
||
model_version: str
|
||
took_ms: float
|
||
|
||
|
||
class HealthResponse(BaseModel):
|
||
status: str
|
||
recognizer: str
|
||
ready: bool
|
||
model_version: str
|
||
detail: str | None = None
|