@trillboards/edge-sdk 0.2.267 → 0.2.276
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/test_loader.py +1 -1
- package/deploy/detector/tests/test_staff_uniform.py +342 -0
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/loader.py +6 -0
- package/deploy/detector/trillboards_detector/registry.py +30 -1
- package/deploy/detector/trillboards_detector/server.py +43 -0
- package/deploy/detector/trillboards_detector/staff_uniform.py +190 -0
- package/deploy/detector/trillboards_detector/tasks.py +9 -1
- package/deploy/windows/build-windows.ps1 +3 -0
- package/deploy/windows/ci/test-published-install.ps1 +1 -1
- package/deploy/windows/e2e/test-recorder-family.ps1 +1 -1
- package/deploy/windows/process-priority.ps1 +229 -0
- package/dist/ActorPerception.d.ts.map +1 -1
- package/dist/ActorPerception.js +3 -1
- package/dist/ActorPerception.js.map +1 -1
- package/dist/AlertClips.d.ts +120 -0
- package/dist/AlertClips.d.ts.map +1 -1
- package/dist/AlertClips.js +296 -17
- package/dist/AlertClips.js.map +1 -1
- package/dist/AudienceAnalyzeClient.d.ts +34 -0
- package/dist/AudienceAnalyzeClient.d.ts.map +1 -1
- package/dist/AudienceAnalyzeClient.js +89 -15
- package/dist/AudienceAnalyzeClient.js.map +1 -1
- package/dist/CctvLiveViewCoordinator.d.ts +23 -2
- package/dist/CctvLiveViewCoordinator.d.ts.map +1 -1
- package/dist/CctvLiveViewCoordinator.js +50 -0
- package/dist/CctvLiveViewCoordinator.js.map +1 -1
- package/dist/ConnectorStatusClient.d.ts +8 -0
- package/dist/ConnectorStatusClient.d.ts.map +1 -1
- package/dist/ConnectorStatusClient.js +3 -0
- package/dist/ConnectorStatusClient.js.map +1 -1
- package/dist/DetectorFields.d.ts +114 -7
- package/dist/DetectorFields.d.ts.map +1 -1
- package/dist/DetectorFields.js +168 -43
- package/dist/DetectorFields.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/FloorObjects.d.ts +131 -8
- package/dist/FloorObjects.d.ts.map +1 -1
- package/dist/FloorObjects.js +396 -24
- package/dist/FloorObjects.js.map +1 -1
- package/dist/LocalDetectorClient.d.ts +21 -0
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +43 -0
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/NativeReadiness.d.ts.map +1 -1
- package/dist/NativeReadiness.js +8 -3
- package/dist/NativeReadiness.js.map +1 -1
- package/dist/QueueDwell.d.ts +87 -0
- package/dist/QueueDwell.d.ts.map +1 -0
- package/dist/QueueDwell.js +167 -0
- package/dist/QueueDwell.js.map +1 -0
- package/dist/ScopedVlmReview.d.ts +21 -2
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +68 -10
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +7 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +1 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/VideoSegmentUploader.d.ts +6 -0
- package/dist/VideoSegmentUploader.d.ts.map +1 -1
- package/dist/VideoSegmentUploader.js +31 -4
- package/dist/VideoSegmentUploader.js.map +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/connectorUpdate.d.ts +6 -0
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +8 -1
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/enterpriseNetwork.d.ts +9 -0
- package/dist/enterpriseNetwork.d.ts.map +1 -1
- package/dist/enterpriseNetwork.js +14 -0
- package/dist/enterpriseNetwork.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/localSensing.d.ts +29 -1
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +64 -6
- package/dist/localSensing.js.map +1 -1
- package/dist/mainThreadStall.d.ts +11 -0
- package/dist/mainThreadStall.d.ts.map +1 -1
- package/dist/mainThreadStall.js +35 -0
- package/dist/mainThreadStall.js.map +1 -1
- package/dist/pipelineSwitches.d.ts +61 -2
- package/dist/pipelineSwitches.d.ts.map +1 -1
- package/dist/pipelineSwitches.js +93 -15
- package/dist/pipelineSwitches.js.map +1 -1
- package/dist/processPriority.d.ts +75 -0
- package/dist/processPriority.d.ts.map +1 -0
- package/dist/processPriority.js +380 -0
- package/dist/processPriority.js.map +1 -0
- package/dist/sensingRunMode.d.ts.map +1 -1
- package/dist/sensingRunMode.js +22 -3
- package/dist/sensingRunMode.js.map +1 -1
- package/dist/vehicleEndWarmup.d.ts +60 -0
- package/dist/vehicleEndWarmup.d.ts.map +1 -0
- package/dist/vehicleEndWarmup.js +209 -0
- package/dist/vehicleEndWarmup.js.map +1 -0
- package/dist/windowsLiveView.d.ts +3 -1
- package/dist/windowsLiveView.d.ts.map +1 -1
- package/dist/windowsLiveView.js +2 -0
- package/dist/windowsLiveView.js.map +1 -1
- package/package.json +4 -4
- package/retained/RetainedCaptureClient.cjs +30 -4
- package/retained/__tests__/archive-lifecycle.test.cjs +44 -0
- package/retained/__tests__/held-frames.test.cjs +94 -0
- package/retained/__tests__/paired-theft-manager.test.cjs +24 -0
- package/retained/__tests__/queue-dwell.test.cjs +238 -0
- package/retained/__tests__/support/theft-builder.cjs +3 -1
- package/retained/held-frames.cjs +39 -0
- package/retained/manager.cjs +15 -0
package/dist/DetectorFields.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.policySha256 = exports.DETECTOR_FIELD_METHODS = exports.BUILDING_SIDES = exports.VEHICLE_END_PREPROCESSING = exports.UNIFORM_COLOURS = void 0;
|
|
3
|
+
exports.policySha256 = exports.DETECTOR_FIELD_METHODS = exports.BUILDING_SIDES = exports.VEHICLE_END_PREPROCESSING = exports.STAFF_UNIFORM = exports.STAFF_UNIFORM_PREPROCESSING = exports.UNIFORM_COLOURS = void 0;
|
|
4
4
|
exports.uniformColourRequest = uniformColourRequest;
|
|
5
5
|
exports.validStaffBand = validStaffBand;
|
|
6
6
|
exports.parseDetectorFields = parseDetectorFields;
|
|
@@ -11,6 +11,7 @@ exports.decideUniformColourAbsence = decideUniformColourAbsence;
|
|
|
11
11
|
exports.onScreen = onScreen;
|
|
12
12
|
exports.readUniformSceneMemory = readUniformSceneMemory;
|
|
13
13
|
exports.decideUniformColourAbsenceV2 = decideUniformColourAbsenceV2;
|
|
14
|
+
exports.uniformStudentAsks = uniformStudentAsks;
|
|
14
15
|
exports.decideUniformColourAbsenceV4 = decideUniformColourAbsenceV4;
|
|
15
16
|
exports.decideDetectedLabels = decideDetectedLabels;
|
|
16
17
|
exports.planVehicleGate = planVehicleGate;
|
|
@@ -74,6 +75,12 @@ const UNIFORM_COLOUR_BANDS = {
|
|
|
74
75
|
pink: { hue: [[0, 10], [221, 255]], minSaturation: 40, maxSaturation: 180, minValue: 150, maxValue: 255 },
|
|
75
76
|
};
|
|
76
77
|
exports.UNIFORM_COLOURS = Object.freeze(Object.keys(UNIFORM_COLOUR_BANDS));
|
|
78
|
+
/** The detector service's `staff_uniform.PREPROCESSING`: the client refuses an answer made any other way. */
|
|
79
|
+
exports.STAFF_UNIFORM_PREPROCESSING = 'pil-rgb-box-plus-10pct-clip-floor-jpeg92-letterbox-96x192-bilinear-fill-7c7468-imagenet-v1';
|
|
80
|
+
/** The uniform student m2 (detector staff_uniform.py): P(staff) of one person's crop. */
|
|
81
|
+
exports.STAFF_UNIFORM = { modelId: 'staff_uniform_student_m2', format: 'onnx',
|
|
82
|
+
sha256: 'bbbb24b90e5201dcb3317f4a0947320bd658e59ed14afe379a9cf9576621d13f' };
|
|
83
|
+
const torsoMethod = (f) => f.method === 'uniform_colour_absence_v4' || f.method === 'uniform_colour_absence_v5';
|
|
77
84
|
function uniformColourRequest(colour, minScore, maxBoxes) {
|
|
78
85
|
const band = UNIFORM_COLOUR_BANDS[colour];
|
|
79
86
|
return { version: 2, minScore, maxBoxes,
|
|
@@ -95,6 +102,9 @@ const UNIFORM_COLOUR_SCENE = {
|
|
|
95
102
|
screenMemory: { minSightings: 3, sameIou: 0.5, memoryMs: 86400000, maxScreens: 64 },
|
|
96
103
|
fixtures: { minConfidence: 0.05, sameIou: 0.5, gapMs: 120000, holdMs: 600000, maxConfidence: 0.6, expireMs: 86400000, maxTracks: 512 },
|
|
97
104
|
};
|
|
105
|
+
const UNIFORM_COLOUR_TORSO = { ...UNIFORM_COLOUR_SCENE, uniform: { colour: '*', band: '*' },
|
|
106
|
+
staff: { torsoFraction: 0.6, upperFraction: 0.1, boxFraction: 0.08, minTorsoPixels: 8, poseMinScore: 0.25, maxPosed: 8 },
|
|
107
|
+
identity: { sameIou: 0.3, footWidths: 1, footHeights: 0.5, gapMs: 15000, maxTracks: 64 } };
|
|
98
108
|
const PINNED = {
|
|
99
109
|
unattended_customer_v1: { minPersonConfidence: 0.25, screenLabels: ['laptop', 'tv'], screenContainment: 0.8, maxPeople: 32,
|
|
100
110
|
uniform: { hue: [[0, 10], [240, 255]], minSaturation: 100, minValue: 60, staffFraction: 0.08 } },
|
|
@@ -104,9 +114,8 @@ const PINNED = {
|
|
|
104
114
|
uniform: { colour: '*', staffFraction: 0.08 } },
|
|
105
115
|
uniform_colour_absence_v2: UNIFORM_COLOUR_SCENE,
|
|
106
116
|
uniform_colour_absence_v3: { ...UNIFORM_COLOUR_SCENE, staffRegion: '*' },
|
|
107
|
-
uniform_colour_absence_v4:
|
|
108
|
-
|
|
109
|
-
identity: { sameIou: 0.3, footWidths: 1, footHeights: 0.5, gapMs: 15000, maxTracks: 64 } },
|
|
117
|
+
uniform_colour_absence_v4: UNIFORM_COLOUR_TORSO,
|
|
118
|
+
uniform_colour_absence_v5: { ...UNIFORM_COLOUR_TORSO, student: { model: exports.STAFF_UNIFORM, vetoBelow: 0.3 } },
|
|
110
119
|
detected_labels_v1: { minConfidence: 0.5 },
|
|
111
120
|
vehicle_arrival_gate_v1: { vehicleLabels: ['bus', 'car', 'motorcycle', 'truck'], minConfidence: 0.5, minArea: 0.04,
|
|
112
121
|
sameVehicleIou: 0.6, stationaryIou: 0.8, minStationaryMs: 10000, maxGapMs: 120000 },
|
|
@@ -119,6 +128,8 @@ const PINNED = {
|
|
|
119
128
|
announce: { sameIou: 0.3, announceMs: 30000, clearMs: 600000, maxAnnounced: 32 } },
|
|
120
129
|
// Something left on the floor of the drawn area (FloorObjects.ts): no model of its own, the frame's person boxes.
|
|
121
130
|
floor_object_left_v1: FloorObjects_1.FLOOR_OBJECT_LEFT_V1,
|
|
131
|
+
// v2: v1 plus the frames held between two looks and the release of an object carried off (FloorObjects.ts).
|
|
132
|
+
floor_object_left_v2: FloorObjects_1.FLOOR_OBJECT_LEFT_V2,
|
|
122
133
|
[FaceWatchPolicy_1.WATCHLIST_METHOD]: FaceWatchPolicy_1.WATCHLIST_PINNED,
|
|
123
134
|
};
|
|
124
135
|
/**
|
|
@@ -138,7 +149,7 @@ const perCamera = (method, rest) => {
|
|
|
138
149
|
return { ...rest, uniform: null };
|
|
139
150
|
rest = { ...rest, uniform: { ...u, colour: '*' } };
|
|
140
151
|
}
|
|
141
|
-
if (method === 'uniform_colour_absence_v4') {
|
|
152
|
+
if (method === 'uniform_colour_absence_v4' || method === 'uniform_colour_absence_v5') {
|
|
142
153
|
const u = rest.uniform;
|
|
143
154
|
if (!keys(u, 'band,colour') || !exports.UNIFORM_COLOURS.includes(u.colour) || !validStaffBand(u.band))
|
|
144
155
|
return { ...rest, uniform: null };
|
|
@@ -202,24 +213,26 @@ function detectorFieldsRequest(policy) {
|
|
|
202
213
|
const all = p.fields.some(f => f.method === 'detected_labels_v1');
|
|
203
214
|
const personMethod = (f) => f.method === 'unattended_customer_v1'
|
|
204
215
|
|| f.method === 'unattended_customer_v2' || f.method === 'uniform_colour_absence_v1'
|
|
205
|
-
|| f.method === 'uniform_colour_absence_v2' || f.method === 'uniform_colour_absence_v3' || f
|
|
216
|
+
|| f.method === 'uniform_colour_absence_v2' || f.method === 'uniform_colour_absence_v3' || torsoMethod(f);
|
|
206
217
|
const classes = all ? [] : [...new Set(p.fields.flatMap(f => personMethod(f)
|
|
207
218
|
? ['person', ...f.screenLabels] : f.method === 'vehicle_arrival_gate_v1' || f.method === 'vehicle_orientation_gate_v1'
|
|
208
|
-
|| f.method === 'vehicle_orientation_gate_v2' ? f.vehicleLabels : f.method === 'floor_object_left_v1'
|
|
209
|
-
|
|
219
|
+
|| f.method === 'vehicle_orientation_gate_v2' ? f.vehicleLabels : f.method === 'floor_object_left_v1'
|
|
220
|
+
|| f.method === 'floor_object_left_v2' ? ['person'] : []))].sort();
|
|
221
|
+
const colourRequests = p.fields.filter(personMethod).map(f => torsoMethod(f) ? staffBandRequest(f.uniform.band, f.minPersonConfidence, f.maxPeople)
|
|
210
222
|
: f.method !== 'unattended_customer_v1' && f.method !== 'unattended_customer_v2'
|
|
211
223
|
? uniformColourRequest(f.uniform.colour, f.minPersonConfidence, f.maxPeople) : { version: 1, minScore: f.minPersonConfidence, maxBoxes: f.maxPeople,
|
|
212
224
|
hue: f.uniform.hue.map(r => [r[0], r[1]]),
|
|
213
225
|
minSaturation: f.uniform.minSaturation, minValue: f.uniform.minValue });
|
|
214
226
|
if (colourRequests.some(request => !(0, util_1.isDeepStrictEqual)(request, colourRequests[0])))
|
|
215
227
|
throw Error('Detector fields require one shared colour specification');
|
|
216
|
-
// v4
|
|
217
|
-
const torso = p.fields.find(
|
|
228
|
+
// v4 and v5 measure each person's torso on the pose of THIS frame's confident people (the held-phone rule's request).
|
|
229
|
+
const torso = p.fields.find(torsoMethod);
|
|
218
230
|
// v2's fixtures are seen below the person bar; every rule still applies its own bar to what it counts. The face
|
|
219
231
|
// watchlist reads no detection of the look (its faces are the face lane's), so it sets no bar.
|
|
220
232
|
const bars = p.fields.filter(f => f.method !== FaceWatchPolicy_1.WATCHLIST_METHOD).map(f => f.method === 'uniform_colour_absence_v2'
|
|
221
|
-
|| f.method === 'uniform_colour_absence_v3' || f
|
|
233
|
+
|| f.method === 'uniform_colour_absence_v3' || torsoMethod(f)
|
|
222
234
|
? Math.min(f.minPersonConfidence, f.fixtures.minConfidence) : personMethod(f) || f.method === 'floor_object_left_v1'
|
|
235
|
+
|| f.method === 'floor_object_left_v2'
|
|
223
236
|
? f.minPersonConfidence : f.minConfidence);
|
|
224
237
|
return { classes, minConfidence: bars.length ? Math.min(...bars) : 0.5,
|
|
225
238
|
expectedModel: { modelId: p.detector.modelId, sha256: p.detector.sha256 },
|
|
@@ -443,23 +456,21 @@ function decideUniformColourAbsenceV2(input) {
|
|
|
443
456
|
...(staffRegion ? { staffAreaPeople } : {}) } };
|
|
444
457
|
}
|
|
445
458
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
* on an earlier look (identity). Screens and fixtures as v2. The answer is decided from the memory as it stood
|
|
450
|
-
* BEFORE this look; only a look captured after the memory's last one teaches it. Pure.
|
|
459
|
+
* The colour rule's read of each counted person of one v4/v5 look, before identity: the screens' pictures taken out,
|
|
460
|
+
* `direct` staff by any bar, `seeds` staff by the torso bar (the evidence identity remembers). Shared by the decision
|
|
461
|
+
* and by uniformStudentAsks, so the student is asked about exactly the reads the decision weighs. Validates the inputs.
|
|
451
462
|
*/
|
|
452
|
-
function
|
|
463
|
+
function uniformColourReads(input) {
|
|
453
464
|
const p = parseDetectorFields(input.policy);
|
|
454
465
|
const m = p.fields.find(f => f.field === input.method.field);
|
|
455
|
-
if (m
|
|
466
|
+
if (!m || m.method !== input.method.method || !torsoMethod(m) || !(0, util_1.isDeepStrictEqual)(m, input.method))
|
|
456
467
|
throw Error('Invalid uniform colour method binding');
|
|
457
468
|
const { width, height } = input.frame, t = input.capturedAtMs;
|
|
458
469
|
if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width <= 1 || height <= 1)
|
|
459
470
|
throw Error('Uniform colour absence needs a valid original frame');
|
|
460
471
|
if (!Number.isSafeInteger(t) || t < 0)
|
|
461
472
|
throw Error('Uniform colour absence needs the capture time');
|
|
462
|
-
const region = uniformRegion(input.region);
|
|
473
|
+
const region = input.region === undefined ? undefined : uniformRegion(input.region);
|
|
463
474
|
const people = input.detections.map((d, index) => ({ d, index }))
|
|
464
475
|
.filter(({ d }) => d.label === 'person' && d.confidence >= m.minPersonConfidence);
|
|
465
476
|
if (people.length > m.maxPeople)
|
|
@@ -474,14 +485,11 @@ function decideUniformColourAbsenceV4(input) {
|
|
|
474
485
|
throw Error('A person has no measured staff colour');
|
|
475
486
|
}
|
|
476
487
|
const prior = readUniformSceneMemory(input.memory);
|
|
477
|
-
const S = m.screenMemory,
|
|
488
|
+
const S = m.screenMemory, B = m.staff;
|
|
478
489
|
const seen = input.detections.filter(d => m.screenLabels.includes(d.label)
|
|
479
490
|
&& d.confidence >= m.minPersonConfidence).map(d => d.box);
|
|
480
491
|
const remembered = prior.screens.filter(s => s.sightings >= S.minSightings && t - s.lastSeenAtMs <= S.memoryMs).map(s => s.box);
|
|
481
|
-
const
|
|
482
|
-
const pictures = [], rememberedPictures = [], outside = [], still = [];
|
|
483
|
-
const matching = [], nonMatching = [];
|
|
484
|
-
const evidence = [];
|
|
492
|
+
const pictures = [], rememberedPictures = [];
|
|
485
493
|
// Colour first: who is staff on THIS look. Only the torso (the garment itself) is evidence strong enough to
|
|
486
494
|
// remember: a customer in a red plaid shirt crosses the upper-body and box bars on some looks (camera 23,
|
|
487
495
|
// Nov 11 00:03Z, 6 of 11 looks) but never the torso bar (0 of 60 customer looks; highest 0.54).
|
|
@@ -503,6 +511,64 @@ function decideUniformColourAbsenceV4(input) {
|
|
|
503
511
|
direct.set(index, torso || row.upper >= B.upperFraction || box >= B.boxFraction);
|
|
504
512
|
live.push({ d, index });
|
|
505
513
|
}
|
|
514
|
+
return { p, m, t, width, height, region, people, fractions, measured, prior, seen, remembered, pictures, rememberedPictures, direct, seeds,
|
|
515
|
+
live };
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* uniform_colour_absence_v5: the people the student is asked about on this look, in detection order: every counted
|
|
519
|
+
* person (not a picture on a screen) the colour rule reads as staff by any bar. The decision requires an answer for
|
|
520
|
+
* exactly these. Pure.
|
|
521
|
+
*/
|
|
522
|
+
function uniformStudentAsks(input) {
|
|
523
|
+
if (input.method?.method !== 'uniform_colour_absence_v5')
|
|
524
|
+
throw Error('Invalid uniform colour method binding');
|
|
525
|
+
const r = uniformColourReads(input);
|
|
526
|
+
return r.live.filter(l => r.direct.get(l.index)).map(l => ({ detectionIndex: l.index, box: { ...l.d.box } }));
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* uniform_colour_absence_v4 on one look: a customer in the area and no staff member in it, where staff is the
|
|
530
|
+
* camera's own band on the torso (>= torsoFraction of at least minTorsoPixels), else on the upper body
|
|
531
|
+
* (>= upperFraction), else on the whole box (>= boxFraction), or a person whose box continues one that was staff
|
|
532
|
+
* on an earlier look (identity). Screens and fixtures as v2. The answer is decided from the memory as it stood
|
|
533
|
+
* BEFORE this look; only a look captured after the memory's last one teaches it. Pure.
|
|
534
|
+
*
|
|
535
|
+
* uniform_colour_absence_v5 is the same decision with `student`, the uniform student's answer for exactly the people
|
|
536
|
+
* uniformStudentAsks names: a read below the method's vetoBelow drops that person's colour evidence of this look
|
|
537
|
+
* (no direct staff, no seed), so only identity from an earlier look can still make them staff. A null answer keeps
|
|
538
|
+
* the colour rule's read.
|
|
539
|
+
*/
|
|
540
|
+
function decideUniformColourAbsenceV4(input) {
|
|
541
|
+
const { p, m, t, width, height, region: inArea, people, fractions, measured, prior, seen, remembered, pictures, rememberedPictures, direct, seeds, live } = uniformColourReads(input);
|
|
542
|
+
const region = inArea;
|
|
543
|
+
const F = m.fixtures, I = m.identity;
|
|
544
|
+
const fixtures = prior.tracks.filter(tr => tr.fixture && t - tr.lastSeenAtMs <= F.expireMs).map(tr => tr.box);
|
|
545
|
+
const outside = [], still = [];
|
|
546
|
+
const matching = [], nonMatching = [];
|
|
547
|
+
const evidence = [];
|
|
548
|
+
// v5: the student's answer for each person the colour rule reads as staff, and the reads it vetoes.
|
|
549
|
+
const answered = new Map(), vetoed = new Set();
|
|
550
|
+
if (m.method === 'uniform_colour_absence_v5') {
|
|
551
|
+
const asked = live.filter(l => direct.get(l.index)).map(l => l.index);
|
|
552
|
+
const reads = input.student;
|
|
553
|
+
if (!Array.isArray(reads) || reads.length !== asked.length || reads.some((a, i) => !a || a.detectionIndex !== asked[i]
|
|
554
|
+
|| !(a.pStaff === null || Number.isFinite(a.pStaff) && a.pStaff >= 0 && a.pStaff <= 1)
|
|
555
|
+
|| !(a.unavailable === undefined || a.unavailable === true && a.pStaff === null)))
|
|
556
|
+
throw Error('The staff reads have no uniform student answer');
|
|
557
|
+
for (const a of reads) {
|
|
558
|
+
answered.set(a.detectionIndex, a.pStaff);
|
|
559
|
+
if (a.pStaff !== null && a.pStaff < m.student.vetoBelow) {
|
|
560
|
+
vetoed.add(a.detectionIndex);
|
|
561
|
+
direct.set(a.detectionIndex, false);
|
|
562
|
+
seeds.set(a.detectionIndex, false);
|
|
563
|
+
}
|
|
564
|
+
// A read the student could not check keeps this look's colour answer (as v4) but teaches identity nothing:
|
|
565
|
+
// seeded, the person stayed staff on every later look past the student's veto (review of #16560).
|
|
566
|
+
if (a.unavailable === true)
|
|
567
|
+
seeds.set(a.detectionIndex, false);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
else if (input.student !== undefined)
|
|
571
|
+
throw Error('Only uniform_colour_absence_v5 reads the uniform student');
|
|
506
572
|
// Identity: each person of the memory's latest looks continues at most one box of this look.
|
|
507
573
|
const tracks = t > prior.lastAtMs ? (prior.people ?? []).filter(q => t - q.lastSeenAtMs <= I.gapMs) : [];
|
|
508
574
|
const foot = (b) => ({ x: b.x + b.width / 2, y: b.y + b.height });
|
|
@@ -536,7 +602,8 @@ function decideUniformColourAbsenceV4(input) {
|
|
|
536
602
|
}
|
|
537
603
|
const row = measured.get(index), fraction = fractions.get(index), staff = staffNow.get(index);
|
|
538
604
|
evidence.push({ index, torso: row.torso, upper: row.upper, box: fraction, staff,
|
|
539
|
-
...(staff && !direct.get(index) ? { remembered: true } : {})
|
|
605
|
+
...(staff && !direct.get(index) ? { remembered: true } : {}),
|
|
606
|
+
...(answered.has(index) ? { pStaff: answered.get(index) } : {}), ...(vetoed.has(index) ? { vetoed: true } : {}) });
|
|
540
607
|
if (staff) {
|
|
541
608
|
matching.push({ index, fraction });
|
|
542
609
|
continue;
|
|
@@ -556,7 +623,7 @@ function decideUniformColourAbsenceV4(input) {
|
|
|
556
623
|
memory = { ...scene, people: [...nowPeople, ...kept].slice(0, I.maxTracks) };
|
|
557
624
|
}
|
|
558
625
|
return { value: nonMatching.length > 0 && matching.length === 0, memory,
|
|
559
|
-
trace: { method:
|
|
626
|
+
trace: { method: m.method, imageSha256: hash(input.jpeg), policySha256: (0, exports.policySha256)(p),
|
|
560
627
|
colour: m.uniform.colour, people: people.length, pictures, outside, matching, nonMatching, fixtures: still, rememberedPictures,
|
|
561
628
|
staffEvidence: evidence } };
|
|
562
629
|
}
|
|
@@ -702,6 +769,18 @@ function planVehicleGate(input) {
|
|
|
702
769
|
* so a box that changed under it (a door, a person, a pole) inherits its answer
|
|
703
770
|
* instead of letting the answer drop and the alert fire again; only a reversed
|
|
704
771
|
* answer is inherited, so a car parking where another left is looked at afresh.
|
|
772
|
+
* An undecided parked vehicle, and the track of a vehicle not yet stationary, stays
|
|
773
|
+
* while a look misses it (no vehicle over it) for 2.5 looks at the camera's own
|
|
774
|
+
* spacing (the interval since the previous look), at least minStationaryMs and
|
|
775
|
+
* at most 3 x minStationaryMs; a vehicle over it is the car moving, and a car
|
|
776
|
+
* decided forward keeps minStationaryMs (a car backing into the spot it left is
|
|
777
|
+
* looked at, not handed its answer). At a
|
|
778
|
+
* 10 s least look gap one missed look otherwise departed the car or restarted
|
|
779
|
+
* its track, and its looks started again: Texas camera 3 (the box misses a lone
|
|
780
|
+
* parked car on 0.5% of its looks, 96 of 19,146, Nov 17-19), its 21 arrival
|
|
781
|
+
* alerts of Nov 17-20 re-timed to 10 s looks: 0.21 alerts per 3 days more than
|
|
782
|
+
* 20 s late with the old keeps, 0.03 with these (0.27 and 0.12 over 15 s). At
|
|
783
|
+
* the 3-4 s spacing of a shared rotation the keep stays minStationaryMs.
|
|
705
784
|
* The answer is whether any parked vehicle is reversed; an undecided one does
|
|
706
785
|
* not count yet.
|
|
707
786
|
*/
|
|
@@ -719,10 +798,18 @@ function planVehicleOrientation(input) {
|
|
|
719
798
|
vehicles.push({ ...d.box });
|
|
720
799
|
const memory = input.memory && input.memory.version === 2 ? input.memory : undefined;
|
|
721
800
|
const prior = memory && t > memory.lastAtMs && t - memory.lastAtMs <= m.maxGapMs ? memory : undefined;
|
|
801
|
+
const keepMs = Math.min(Math.max(m.minStationaryMs, 2.5 * (prior ? t - prior.lastAtMs : 0)), 3 * m.minStationaryMs);
|
|
802
|
+
// A vehicle of this frame over an unseen box (IoU >= inheritIou) is that car moving, not a look that missed it: only
|
|
803
|
+
// a miss earns the longer keep (the real video's car backing in left and came back to its box 22 s later).
|
|
804
|
+
const moved = (box) => vehicles.some(v => iou(v, box) >= o.inheritIou);
|
|
805
|
+
// A track seen on the previous look always carries (as before); one a look missed carries for keepMs.
|
|
806
|
+
const live = (prior?.tracks ?? []).filter(tr => tr.lastSeenAtMs === undefined || tr.lastSeenAtMs === prior.lastAtMs
|
|
807
|
+
|| t - tr.lastSeenAtMs < keepMs);
|
|
722
808
|
const tracks = vehicles.map(box => {
|
|
723
|
-
const was =
|
|
724
|
-
return { box, firstSeenAtMs: was ? was.firstSeenAtMs : t };
|
|
809
|
+
const was = live.find(tr => iou(tr.box, box) >= m.stationaryIou);
|
|
810
|
+
return { box, firstSeenAtMs: was ? was.firstSeenAtMs : t, lastSeenAtMs: t };
|
|
725
811
|
});
|
|
812
|
+
const missed = live.filter(tr => !moved(tr.box)).map(tr => ({ ...tr, lastSeenAtMs: tr.lastSeenAtMs ?? prior.lastAtMs }));
|
|
726
813
|
const stationary = tracks.filter(tr => t - tr.firstSeenAtMs >= m.minStationaryMs).map(tr => tr.box);
|
|
727
814
|
const parked = [];
|
|
728
815
|
let departures = 0;
|
|
@@ -730,12 +817,13 @@ function planVehicleOrientation(input) {
|
|
|
730
817
|
const now = vehicles.find(v => iou(v, p.box) >= m.sameVehicleIou);
|
|
731
818
|
if (now)
|
|
732
819
|
parked.push({ ...p, box: now, lastSeenAtMs: t, seen: true });
|
|
733
|
-
else if (t - p.lastSeenAtMs < (p.reversed === true ? 3 * m.minStationaryMs
|
|
820
|
+
else if (t - p.lastSeenAtMs < (p.reversed === true ? 3 * m.minStationaryMs
|
|
821
|
+
: p.reversed === null && !moved(p.box) ? keepMs : m.minStationaryMs))
|
|
734
822
|
parked.push({ ...p, seen: false });
|
|
735
823
|
else
|
|
736
824
|
departures++;
|
|
737
825
|
}
|
|
738
|
-
let arrivals = 0, inherited = 0;
|
|
826
|
+
let arrivals = 0, inherited = 0, created = 0;
|
|
739
827
|
for (const s of stationary) {
|
|
740
828
|
if (parked.some(p => p.seen && iou(p.box, s) >= m.sameVehicleIou))
|
|
741
829
|
continue;
|
|
@@ -748,7 +836,7 @@ function planVehicleOrientation(input) {
|
|
|
748
836
|
inherited++;
|
|
749
837
|
}
|
|
750
838
|
else
|
|
751
|
-
parked.push({ box: { ...s }, lastSeenAtMs: t, looks: [], reversed: null, seen: true });
|
|
839
|
+
parked.push({ box: { ...s }, lastSeenAtMs: t, looks: [], reversed: null, seen: true, id: t * 1024 + created++ });
|
|
752
840
|
}
|
|
753
841
|
const due = parked.filter(p => p.seen && p.reversed === null && (p.looks.length === 0
|
|
754
842
|
|| p.looks.length < o.majorityOf && t - p.looks[p.looks.length - 1].atMs >= o.lookIntervalMs)).slice(0, 8);
|
|
@@ -774,7 +862,7 @@ function planVehicleOrientation(input) {
|
|
|
774
862
|
});
|
|
775
863
|
const kept = parked.map(({ seen: _seen, ...p }) => p);
|
|
776
864
|
const reversedParked = kept.filter(p => p.reversed === true).length;
|
|
777
|
-
return { value: reversedParked > 0, memory: { version: 2, lastAtMs: t, tracks, parked: kept },
|
|
865
|
+
return { value: reversedParked > 0, memory: { version: 2, lastAtMs: t, tracks: [...tracks, ...missed], parked: kept },
|
|
778
866
|
trace: { ...base(action), decided, reversedParked } };
|
|
779
867
|
} };
|
|
780
868
|
}
|
|
@@ -783,7 +871,8 @@ function readVehicleAnnounceMemory(value) {
|
|
|
783
871
|
const v = value;
|
|
784
872
|
const valid = !!v && v.version === 1 && time(v.lastAtMs) && Array.isArray(v.announced) && v.announced.length <= 256
|
|
785
873
|
&& v.announced.every(a => !!a && boxOf(a.box) && time(a.announcedAtMs) && time(a.lastSeenAtMs) && a.announcedAtMs <= a.lastSeenAtMs
|
|
786
|
-
&& time(a.emptyMs) && a.emptyMs >= 0)
|
|
874
|
+
&& time(a.emptyMs) && a.emptyMs >= 0 && (a.announcedBox === undefined || boxOf(a.announcedBox))
|
|
875
|
+
&& (a.entryId === undefined || time(a.entryId)));
|
|
787
876
|
return valid ? v : { version: 1, lastAtMs: -1, announced: [] };
|
|
788
877
|
}
|
|
789
878
|
/**
|
|
@@ -792,6 +881,17 @@ function readVehicleAnnounceMemory(value) {
|
|
|
792
881
|
* announced less than announceMs ago. A position stays announced while a vehicle of the looks keeps overlapping it,
|
|
793
882
|
* and is forgotten once looks have seen no vehicle there for clearMs: a stretch without looks (camera or connector
|
|
794
883
|
* down) is not evidence the car left. A late or repeated frame decides from the memory and teaches nothing. Pure.
|
|
884
|
+
* A position follows its own car, the gate's parked entry it was announced for (reversedIds), wherever that entry's
|
|
885
|
+
* box goes, and its car is never announced again; a position whose car's entry is gone (a connector restart, the
|
|
886
|
+
* gate starting afresh, a memory written before positions kept their car) is taken by the first reversed car without
|
|
887
|
+
* a position of its own that stands where it was announced. Any other car is the same stay only where a position was
|
|
888
|
+
* announced, never where its car went, so a spot cannot creep along a row of cars. The gate's parked entry follows its
|
|
889
|
+
* car's detections and passes its answer to a box that replaced it (IoU >= inheritIou), so a fixed position let the
|
|
890
|
+
* entry walk out from under it:
|
|
891
|
+
* Texas camera 3, Nov 18 2026, a nose-in van parked in front of the backed-in pickup announced at 00:55:41Z and hid
|
|
892
|
+
* it, took the pickup's answer at 01:04:55Z, and backing out at 01:09:00Z was announced (IoU 0.298 with the pickup's
|
|
893
|
+
* box): a false alert, 1 of 22 Nov 17-20. The pickup, decided again where it was announced while the entry sat on
|
|
894
|
+
* the van, is the same stay.
|
|
795
895
|
*/
|
|
796
896
|
function announceReversedVehicles(input) {
|
|
797
897
|
const A = input.method.announce, t = input.capturedAtMs;
|
|
@@ -802,12 +902,14 @@ function announceReversedVehicles(input) {
|
|
|
802
902
|
if (t <= prior.lastAtMs)
|
|
803
903
|
return { value: recent(prior.announced), memory: prior,
|
|
804
904
|
trace: { held: prior.announced.length, newlyAnnounced: [], cleared: 0 } };
|
|
805
|
-
const entries = prior.announced.map(a => ({ ...a, box: { ...a.box } }));
|
|
905
|
+
const entries = prior.announced.map(a => ({ ...a, box: { ...a.box }, announcedBox: { ...(a.announcedBox ?? a.box) } }));
|
|
806
906
|
// Look time, not the clock: an interval between two looks longer than the gate's maxGapMs (camera or connector
|
|
807
907
|
// down) adds nothing, so a car still there when looks resume is seen and kept, never announced again.
|
|
808
908
|
const interval = prior.lastAtMs >= 0 ? t - prior.lastAtMs : 0, counted = interval <= input.method.maxGapMs ? interval : 0;
|
|
909
|
+
// A vehicle where a position was announced keeps it; its own car keeps it below, wherever it went. A vehicle where
|
|
910
|
+
// its car was last seen does not: once that car's entry is gone, a neighbour there held a stale spot for good.
|
|
809
911
|
for (const a of entries) {
|
|
810
|
-
if (input.vehicles.some(v => iou(
|
|
912
|
+
if (input.vehicles.some(v => iou(a.announcedBox, v) >= A.sameIou)) {
|
|
811
913
|
a.lastSeenAtMs = t;
|
|
812
914
|
a.emptyMs = 0;
|
|
813
915
|
}
|
|
@@ -816,17 +918,40 @@ function announceReversedVehicles(input) {
|
|
|
816
918
|
}
|
|
817
919
|
const kept = entries.filter(a => a.emptyMs < A.clearMs);
|
|
818
920
|
const cleared = entries.length - kept.length;
|
|
921
|
+
const id = (i) => { const v = input.reversedIds?.[i]; return time(v) ? v : undefined; };
|
|
922
|
+
const live = new Set(input.reversed.map((_, i) => id(i)).filter((k) => k !== undefined));
|
|
923
|
+
const where = (r) => (a) => iou(a.announcedBox, r) >= A.sameIou;
|
|
924
|
+
const owner = input.reversed.map((_, i) => { const k = id(i); return k === undefined ? undefined : kept.find(a => a.entryId === k); });
|
|
925
|
+
input.reversed.forEach((r, i) => {
|
|
926
|
+
const k = id(i);
|
|
927
|
+
if (k === undefined || owner[i])
|
|
928
|
+
return;
|
|
929
|
+
const a = kept.find(e => (e.entryId === undefined || !live.has(e.entryId)) && where(r)(e));
|
|
930
|
+
if (a) {
|
|
931
|
+
a.entryId = k;
|
|
932
|
+
owner[i] = a;
|
|
933
|
+
}
|
|
934
|
+
});
|
|
819
935
|
const newly = [];
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
if (
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
936
|
+
input.reversed.forEach((r, i) => {
|
|
937
|
+
const own = owner[i];
|
|
938
|
+
if (own) {
|
|
939
|
+
own.box = { ...r };
|
|
940
|
+
own.lastSeenAtMs = t;
|
|
941
|
+
own.emptyMs = 0;
|
|
942
|
+
return;
|
|
826
943
|
}
|
|
827
|
-
|
|
944
|
+
// Where a position was announced: the same stay, not announced (as before).
|
|
945
|
+
const same = kept.find(where(r));
|
|
946
|
+
if (same) {
|
|
947
|
+
same.lastSeenAtMs = t;
|
|
948
|
+
same.emptyMs = 0;
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const k = id(i);
|
|
952
|
+
kept.push({ box: { ...r }, announcedAtMs: t, lastSeenAtMs: t, emptyMs: 0, announcedBox: { ...r }, ...(k === undefined ? {} : { entryId: k }) });
|
|
828
953
|
newly.push({ ...r });
|
|
829
|
-
}
|
|
954
|
+
});
|
|
830
955
|
const bounded = kept.map((a, i) => ({ a, i })).sort((x, y) => y.a.lastSeenAtMs - x.a.lastSeenAtMs || x.i - y.i)
|
|
831
956
|
.slice(0, A.maxAnnounced).sort((x, y) => x.i - y.i).map(e => e.a);
|
|
832
957
|
return { value: recent(bounded), memory: { version: 1, lastAtMs: t, announced: bounded },
|