feat(setup): "Test ANPR" probe on ANPR-enabled cameras
Adds a bottom-of-modal "Test ANPR" button (shown only when a camera's Plate recognition opt-in is checked) that captures a live snapshot off the camera and runs it through the vision service, reporting the plate read + confidence + elapsed time, or which stage failed. - New POST /api/setup/test-anpr: builds the camera from the unsaved config (no DB write/device change, like /test), captures a snapshot, runs vision.analyze. Fail-soft like the runtime path (snapshot.ts): camera/vision failures are reported results, never a 500. - Thread the existing VisionClient into setupRoutes; add an isCamera() type guard to @parking/devices. - Web: testAnpr() client + AnprTestResult; button, hint, result line. - i18n keys in sq + en (Catalog parity). Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
This commit is contained in:
@@ -280,6 +280,34 @@ export function testDevice(driverId: string, config: DeviceConfig): Promise<Test
|
||||
});
|
||||
}
|
||||
|
||||
/** Result of an end-to-end ANPR probe on a camera: snapshot → vision analyze. */
|
||||
export type AnprTestResult =
|
||||
| {
|
||||
ok: true;
|
||||
plate: string;
|
||||
confidence: number;
|
||||
region: string | null;
|
||||
lowConfidence: boolean;
|
||||
modelVersion: string;
|
||||
tookMs: number;
|
||||
}
|
||||
| {
|
||||
ok: false;
|
||||
/** vision-disabled | snapshot-failed | no-plate */
|
||||
reason: string;
|
||||
detail?: string;
|
||||
tookMs?: number;
|
||||
};
|
||||
|
||||
/** Take a live snapshot off the camera and run ANPR on it — without saving. Reports
|
||||
* whether a plate was extracted, the read, and how long it took. */
|
||||
export function testAnpr(driverId: string, config: DeviceConfig): Promise<AnprTestResult> {
|
||||
return apiFetch<AnprTestResult>("/api/setup/test-anpr", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ driverId, config }),
|
||||
});
|
||||
}
|
||||
|
||||
export interface BackendIpCandidate {
|
||||
ip: string;
|
||||
iface: string;
|
||||
|
||||
Reference in New Issue
Block a user