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:
@@ -63,6 +63,9 @@ const CROP_MARGIN = 0.08;
|
||||
/** Items older than this are abandoned (failed "expired") — a booth cut off for two weeks
|
||||
* should not resurface a fortnight of crops in one burst. */
|
||||
export const EXPIRE_DAYS = 14;
|
||||
/** Two entry reads from the same camera closer than this are one car (the ANPR bridge's
|
||||
* per-detection pass sample, then the ticket entry's session-tied read ~seconds later). */
|
||||
export const ENTRY_DEDUP_MS = 30_000;
|
||||
/** Backoff: 1 min · 2^attempts, capped. */
|
||||
const BACKOFF_BASE_MS = 60_000;
|
||||
const BACKOFF_CAP_MS = 6 * 60 * 60 * 1000;
|
||||
@@ -166,6 +169,9 @@ export class ReviewOutbox {
|
||||
#timer: NodeJS.Timeout | null = null;
|
||||
#draining = false;
|
||||
#entrySeen = 0;
|
||||
/** Last entry sample per camera: the bridge's pass sample and the ticket entry's read are
|
||||
* the SAME car seconds apart — one goes, the other is skipped (and not counted). */
|
||||
readonly #lastEntryByDevice = new Map<string, number>();
|
||||
|
||||
constructor(db: Db, logger: FastifyBaseLogger, cfg: ReviewUploadConfig | null, fetchFn?: FetchLike) {
|
||||
this.#db = db;
|
||||
@@ -202,9 +208,15 @@ export class ReviewOutbox {
|
||||
|
||||
/** Every Nth entry read is a sample (N = entrySample); the caller queues it. Counted
|
||||
* in-process, so "1 in 5" is exactly that across a booth's day. */
|
||||
sampleEntry(): boolean {
|
||||
sampleEntry(deviceId?: string): boolean {
|
||||
const n = this.#cfg?.entrySample ?? 0;
|
||||
if (n <= 0) return false;
|
||||
if (deviceId) {
|
||||
const now = Date.now();
|
||||
const last = this.#lastEntryByDevice.get(deviceId);
|
||||
if (last != null && now - last < ENTRY_DEDUP_MS) return false;
|
||||
this.#lastEntryByDevice.set(deviceId, now);
|
||||
}
|
||||
this.#entrySeen += 1;
|
||||
return this.#entrySeen % n === 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user