Merge pull request #138 Co-authored-by: Arnaud Dartois <admin@tordais.cc>
8.2 KiB
name, description
| name | description |
|---|---|
| vision-identity | Implement Heimdall's opt-in, self-hosted plate OCR and preserve the licensing/privacy gates for camera face and plate identity. |
Vision identity in Heimdall
Read AGENTS.md and FEAT-03/UI-02 in todo.md. Current API contract only supports a human-triggered OCR request with an operator-supplied JPEG/PNG plate crop. It does not infer plate boxes from video frames or recognize faces.
Plate OCR currently implemented
PlateOcr:Enableddefaults to false. Explicitly enable the on-prem Central option to offer OCR; the camera detail UI sends only the file the user selected.- Central uses the system Tesseract executable and English LSTM data. Tesseract engine and the official
tessdata_bestmodel data declare Apache-2.0. Do not add other OCR or detection weights without reviewing their exact asset licenses and provenance. - The controller requires a human principal with
Camera.Write, camera scope, JPEG/PNG signature, configured byte limit (at most 512 KiB), and rate limits. OCR rejects malformed, oversized, or over-4-megapixel crops and times out after a bounded interval. - OCR runs on the Heimdall Central host. The image is written to a random temporary path and deleted in
finally; do not log the crop, extracted text, embedding, or raw image path. - Store only the normalized plate candidate, confidence, and a
LicensePlateDetectedevent. The API may return a unique exact vehicle/person as a suggestion, but it does not persist identity links during OCR.CameraDetailpresents the suggestion for operator review; the operator must explicitly confirm a vehicle. The confirmation API requires a human principal with both camera and vehicle write permissions, verifies access to the camera, the event-to-observation association, and an exact normalized plate match, and writes the observation/event links together. Never treat OCR output as verified identity. - OCR observations remain unassigned until a human confirms an association; unassigned plate rows are purged after 30 days.
CleanupLicensePlatesJobalso removesLicensePlateDetectedevents older than 30 days, including their label and metadata. If an event has stored snapshots, it deletes those objects from the exact captured destination before deleting the database row. Events with missing/incomplete storage provenance are retained with a warning rather than deleting from a guessed destination. Vehicle-owned plate records remain governed by their explicit vehicle lifecycle. Keep the wider privacy review open before production enablement.
Face-model gate
ONNX Runtime is already used by the Agent and is MIT licensed. A model runtime license does not grant rights to a particular model's weights or training data. InsightFace's model-zoo documentation restricts its distributed pretrained weights to non-commercial research. ONNX Model Zoo's ArcFace/UltraFace listing points to sourced models but does not establish one blanket weight/data license. Do not bundle SFace, ArcFace, YuNet, or plate-detector weights unless the exact asset and training-data rights are reviewed. An operator-provided model also needs a documented tensor/preprocessing contract, stable model ID stored with enrollments, explicit opt-in, deletion/retention semantics, and representative accuracy testing before face matches can create events.
Official sources reviewed:
- Tesseract engine license and command-line formats
- Official
tessdata_bestlicense - Official
tessdatalanguage-data license - Official Tesseract data-file compatibility guidance
- ONNX Runtime repository license
- ONNX Model Zoo sourcing and model catalog
- InsightFace model-zoo license statement
Human confirmation workflow
- Keep mismatches and ambiguous candidate lists unlinked until an operator selects a vehicle and confirms.
- Confirm with the observation ID, event ID and selected vehicle ID; reject anonymous or camera-scoped requests, mismatched plates, unrelated events, and conflicting existing links.
- Preserve the matching UI/API behavior with component/controller tests and handler tests. API authorization and camera scope stay at the Web boundary; the application handler independently checks camera access before persistence.
Acceptance
- Local targeted tests passed:
PlateOcrTests4/4,CameraDetailTests6/6,PlateRecognitionControllerTests1/1. These unit/component tests do not replace a browser-driven UI test. - Compose source build passed in isolated project
hmd-plate-20261105094933-31487. It used a generated database/JWT credential set, unused127.0.0.1ports, unique network/image/project, and project-scoped volumes.PlateOcrwas enabled only through a temporary Compose override. Thesynthetic-plate.pngfixture returnedAB-123-CDwith Tesseract confidence0.912through the authenticated multipart API;/api/eventspage 1 contained the created event. The historical entry does not record removal and exact-tag absence verification for the image; treat this recipe's image cleanup as unverified and repeat it before relying on that portion of acceptance. - The invalid JPEG signature returned HTTP 400. PostgreSQL inspection confirmed the plate observation and history event were persisted with no Person/Vehicle link and no event snapshot. The random OCR temp path was absent after processing.
down --volumes --remove-orphanscleanup verifiedcontainers=0 volumes=0 networks=0. The historical record for this bootstrap does not name a locally built image tag or document an exact image absence check; treat image cleanup as unverified and repeat it before relying on that part of the acceptance. The first admin bootstrap also called the existing HaveIBeenPwned breach checker with a generated synthetic password; that code uses k-anonymity, so the Compose exercise was not fully offline. No real password, camera, image, or release secret was used.- Human confirmation acceptance passed in source-built disposable project
hmd-plate-link-1793880442-bff1ca: the synthetic OCR crop returnedAB-123-CDat confidence 0.912; a vehicle with another plate was rejected with HTTP 422; PostgreSQL showed both links null before confirmation; explicit confirmation returned 200 and bothlicense_plates.VehicleIdandcamera_events.VehicleIdwere populated; anonymous confirmation returned 401. Cleanup verified zero containers, volumes and networks and removed/verified absence of the exactheimdall:hmd-plate-link-1793880442-bff1ca-centralimage tag. Two earlier recipe attempts had harness-only readiness/SQL identifier mistakes; each exact project and tag was cleaned and absence checked. - Keep assigning the locally built Central image a unique project tag and remove/verify that exact tag on every recipe completion, including failure paths. Retain shared .NET/ASP.NET base images and never use broad image pruning.
- These acceptances cover one synthetic crop and the API persistence/confirmation path only. They do not establish OCR accuracy in real scenes, video plate detection, face recognition, browser-driven upload behavior, camera hardware behavior, or the suitability of the retention period under an external privacy review.
- Plate-event retention is covered by
CleanupLicensePlatesJobTests(SQLite: expired plate event removed, recent plate and unrelated events retained; captured snapshot objects removed first; storage deletion failure retains the event) andPlateEventRetentionPostgresTests(PostgreSQL EF translation/deletion). The disposable Compose projecthmd-plate-retention-pg-1793885533-16210ran the PostgreSQL test from the mounted changed source with locked restore, generated credentials, and project-scoped database/NuGet volumes; result 1/1. Teardown removed and verified zero project containers/volumes/networks. The recipe builds no Heimdall image; shared PostgreSQL/SDK base images are retained. This validates the local retention mechanics, not the external privacy policy or any production retention requirement.