feat(review): sample every detected car, not only ticketed entries
Build & push images / images (push) Successful in 5m20s
Build & push images / images (push) Successful in 5m20s
The entry stream for the reviewer was fed from the session-tied read only (ticket printed / exit signed). park-2 ran an afternoon with its barriers up: hundreds of camera vehicle pushes, zero tickets, zero samples. - anpr-entry: keep the best-framed vehicle of each poll loop (highest body-type confidence with a box), store that frame as a snapshot (identity pass:<id>, no session) and emit a vehicle read with the camera id — plate or no plate. One sample per detection, fire-and-forget, never on the ANPR path. - snapshot.ts: normalizedBoxes() shared by the session-tied read and the bridge; vehicle reads now carry deviceId. - review-outbox: sampleEntry(deviceId) dedups per camera for 30 s so the pass sample and a ticket entry's read (same car, seconds apart) go once. - wiki: outbox page (entry stream, troubleshooting checklist for 'nothing arrives': the month-long silence was a missing Netbird policy, not code), park-2 camera port-forward procedure (site-device-installation §7), log.
This commit is contained in:
@@ -6,7 +6,7 @@ import type { FastifyInstance } from "fastify";
|
||||
import { deviceEvents as deviceEventBus } from "../../device-events.js";
|
||||
import { buildServer } from "../../server.js";
|
||||
import { login, makeLog, minutesAgo, seedTariff, seedUser, silentLogger } from "../../test-helpers.js";
|
||||
import { EXPIRE_DAYS, ReviewOutbox, makeReviewCrop, operatorRef, reviewUploadConfigFromEnv } from "./review-outbox.js";
|
||||
import { ENTRY_DEDUP_MS, EXPIRE_DAYS, ReviewOutbox, makeReviewCrop, operatorRef, reviewUploadConfigFromEnv } from "./review-outbox.js";
|
||||
|
||||
// The review outbox, booth side (wiki/concepts/vision-review-outbox.md): a plate-blurred
|
||||
// vehicle crop + the operator's choice, queued off the intake path, drained one-way with
|
||||
@@ -165,6 +165,20 @@ describe("queue + drain", () => {
|
||||
const sampler = new ReviewOutbox(db, silentLogger(), { ...cfg, entrySample: 3 }, fetchFn);
|
||||
expect([sampler.sampleEntry(), sampler.sampleEntry(), sampler.sampleEntry(), sampler.sampleEntry()]).toEqual([false, false, true, false]);
|
||||
expect(ob.sampleEntry()).toBe(false); // entrySample 0 = off
|
||||
// Per-camera dedup: the bridge's pass sample and the ticket entry's read, seconds
|
||||
// apart from the same camera, are ONE car — the second is skipped and not counted.
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const every = new ReviewOutbox(db, silentLogger(), { ...cfg, entrySample: 1 }, fetchFn);
|
||||
expect(every.sampleEntry("cam-a")).toBe(true);
|
||||
expect(every.sampleEntry("cam-a")).toBe(false);
|
||||
expect(every.sampleEntry("cam-b")).toBe(true); // another camera = another car
|
||||
vi.advanceTimersByTime(ENTRY_DEDUP_MS + 1);
|
||||
expect(every.sampleEntry("cam-a")).toBe(true);
|
||||
expect(every.sampleEntry()).toBe(true); // camera unknown → no dedup
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
expect(await sampler.enqueueEntry(read)).toBe(true);
|
||||
const entryRow = db.select().from(carwashReviewOutbox).where(eq(carwashReviewOutbox.orderId, "entry:snap-1")).get()!;
|
||||
expect(entryRow.payload).toMatchObject({ v: 1, kind: "entry", booth: "booth-7", vision: { class: "car", confidence: 0.86 }, image: { plateBlurred: true } });
|
||||
|
||||
Reference in New Issue
Block a user