Files
parking_solution/apps/vision/.env.example
T
julian 20a3cb3e80 feat(vision): vehicle stage, phase A — YOLOX-S (Apache-2.0 ONNX) beside the plate recognizer
Fills /analyze vehicle.body_type + confidence (car / motorcycle / bus / truck from COCO,
mapped to the shared vocabulary) for the Car Wash desk's category suggestion
(venue-modules.md §Vehicle category from vision). Advisory: the operator decides, a
confident downgrade is flagged, nothing is gated on it.

- vision_service/vehicle.py: pure numpy/cv2 letterbox (pad 114, raw BGR), stride-grid
  decode, class-agnostic NMS, one vehicle per frame (the box holding the plate's centre,
  else the largest); YoloxVehicleDetector on onnxruntime CPU, 2 intra-op threads.
- recognizer.py: WithVehicle composes the stage over any plate recognizer (stub included);
  a failing stage yields vehicle=null + a "vehicle: …" note in /health.detail — never
  costs the plate read. model_version reads "<plate>+yolox:yolox_s.onnx@640".
- settings: VISION_VEHICLE_MODEL_PATH (unset = off), _INPUT_SIZE (640), _MIN_CONFIDENCE
  (0.4, the detector's floor; the flag threshold is site config).
- Dockerfile bakes yolox_s.onnx (best-effort curl at build; no network → stage off) and
  sets the path; compose forwards it (empty = off); .env.example documents it.
- Measured on four real dev entry frames (DS-2CD1047G3H, 2560×1440): car at 0.83–0.88 in
  ~240–330 ms; empty lane with a person → none.
- tests/test_vehicle.py: decode/NMS/pick/letterbox on synthetic tensors, the composition,
  and a missing-model /health. Wiki: opencv-anpr-service, venue-modules, log.

Claude-Session: https://claude.ai/code/session_01FWncR69HgGPuei1dLrW3cU
2026-09-06 19:53:11 +02:00

32 lines
1.8 KiB
Bash

# apps/vision — the ANPR microservice's own env (copy to apps/vision/.env).
# This is the PYTHON SERVICE's config only. The Node server has its OWN VISION_* vars
# (in apps/server/.env) — keep the two .env files SEPARATE (they share the VISION_
# prefix but are different processes). See wiki/entities/opencv-anpr-service.md "Configuration".
# Recognizer: "stub" (no models, recognizes nothing — boots anywhere, for dev/CI) or
# "fast_alpr" (the real MIT YOLOv9+CCT/ONNX stack — needs `uv sync --extra alpr`).
VISION_RECOGNIZER=fast_alpr
# Bind. On the appliance prefer 127.0.0.1 — the Node backend is the only caller, so the
# /analyze endpoint should NOT be reachable off-host. (0.0.0.0 only if you must.)
VISION_HOST=127.0.0.1
VISION_PORT=8089
# fast-alpr models (only used when recognizer=fast_alpr). The defaults won the Albanian
# benchmark; change the OCR to european-plates-mobile-vit-v2-model only to re-test.
VISION_DETECTOR_MODEL=yolo-v9-t-384-license-plate-end2end
VISION_OCR_MODEL=cct-xs-v2-global-model
# Confidence floor — a best plate below this is flagged low_confidence so the Node side
# treats it as advisory and falls back to the ticket path. Keep in sync with the server.
VISION_MIN_CONFIDENCE=0.5
# Vehicle stage (phase A): a YOLOX ONNX graph (Apache-2.0) run on the same frame after the
# plate read; fills /analyze `vehicle.body_type` (car/truck/bus/motorcycle) + confidence for
# the Car Wash desk's category suggestion. Unset = off. The Docker image bakes the weights
# at /app/models/yolox_s.onnx; locally: curl the release file into apps/vision/models/.
# https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx
# VISION_VEHICLE_MODEL_PATH=models/yolox_s.onnx
# VISION_VEHICLE_INPUT_SIZE=640
# VISION_VEHICLE_MIN_CONFIDENCE=0.4