@trillboards/edge-sdk 0.2.253 → 0.2.255
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/README.md +15 -0
- package/deploy/detector/pyproject.toml +1 -1
- package/deploy/detector/tests/test_face_identity.py +448 -0
- package/deploy/detector/tests/test_loader.py +3 -1
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/face_contract.py +166 -0
- package/deploy/detector/trillboards_detector/face_identity.py +467 -0
- package/deploy/detector/trillboards_detector/loader.py +12 -0
- package/deploy/detector/trillboards_detector/registry.py +45 -1
- package/deploy/detector/trillboards_detector/server.py +42 -1
- package/deploy/detector/trillboards_detector/tasks.py +12 -1
- package/deploy/windows/ci/test-main-stream-gpu-decode.ps1 +119 -0
- package/dist/CctvLiveViewCoordinator.d.ts +34 -2
- package/dist/CctvLiveViewCoordinator.d.ts.map +1 -1
- package/dist/CctvLiveViewCoordinator.js +106 -25
- package/dist/CctvLiveViewCoordinator.js.map +1 -1
- package/dist/CloudSensingManager.d.ts +17 -0
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +11 -2
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/ConnectorStatusClient.d.ts +18 -1
- package/dist/ConnectorStatusClient.d.ts.map +1 -1
- package/dist/ConnectorStatusClient.js +6 -0
- package/dist/ConnectorStatusClient.js.map +1 -1
- package/dist/DetectorFields.d.ts +77 -1
- package/dist/DetectorFields.d.ts.map +1 -1
- package/dist/DetectorFields.js +34 -4
- package/dist/DetectorFields.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/FaceIdentity.d.ts +122 -0
- package/dist/FaceIdentity.d.ts.map +1 -0
- package/dist/FaceIdentity.js +256 -0
- package/dist/FaceIdentity.js.map +1 -0
- package/dist/FaceSightingUploader.d.ts +95 -0
- package/dist/FaceSightingUploader.d.ts.map +1 -0
- package/dist/FaceSightingUploader.js +214 -0
- package/dist/FaceSightingUploader.js.map +1 -0
- package/dist/FaceWatchLane.d.ts +297 -0
- package/dist/FaceWatchLane.d.ts.map +1 -0
- package/dist/FaceWatchLane.js +660 -0
- package/dist/FaceWatchLane.js.map +1 -0
- package/dist/FaceWatchPolicy.d.ts +154 -0
- package/dist/FaceWatchPolicy.d.ts.map +1 -0
- package/dist/FaceWatchPolicy.js +101 -0
- package/dist/FaceWatchPolicy.js.map +1 -0
- package/dist/LiveViewControlHttp.d.ts +11 -2
- package/dist/LiveViewControlHttp.d.ts.map +1 -1
- package/dist/LiveViewControlHttp.js +14 -5
- package/dist/LiveViewControlHttp.js.map +1 -1
- package/dist/LiveViewCpuMeter.d.ts +26 -0
- package/dist/LiveViewCpuMeter.d.ts.map +1 -0
- package/dist/LiveViewCpuMeter.js +73 -0
- package/dist/LiveViewCpuMeter.js.map +1 -0
- package/dist/LiveViewProducerSignaling.d.ts +7 -0
- package/dist/LiveViewProducerSignaling.d.ts.map +1 -1
- package/dist/LiveViewProducerSignaling.js +12 -2
- package/dist/LiveViewProducerSignaling.js.map +1 -1
- package/dist/LocalDetectorClient.d.ts +11 -0
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +44 -0
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/MainStreamRing.d.ts +63 -1
- package/dist/MainStreamRing.d.ts.map +1 -1
- package/dist/MainStreamRing.js +101 -7
- package/dist/MainStreamRing.js.map +1 -1
- package/dist/NativeReadiness.d.ts.map +1 -1
- package/dist/NativeReadiness.js +7 -3
- package/dist/NativeReadiness.js.map +1 -1
- package/dist/ReviewPriority.d.ts +9 -0
- package/dist/ReviewPriority.d.ts.map +1 -1
- package/dist/ReviewPriority.js +6 -1
- package/dist/ReviewPriority.js.map +1 -1
- package/dist/ScopedVlmReview.d.ts +11 -2
- package/dist/ScopedVlmReview.d.ts.map +1 -1
- package/dist/ScopedVlmReview.js +43 -16
- package/dist/ScopedVlmReview.js.map +1 -1
- package/dist/SensingProfileClient.d.ts +14 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +9 -0
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/UniformSceneStore.d.ts +6 -0
- package/dist/UniformSceneStore.d.ts.map +1 -1
- package/dist/UniformSceneStore.js +22 -1
- package/dist/UniformSceneStore.js.map +1 -1
- package/dist/VideoSegmentUploader.d.ts +11 -0
- package/dist/VideoSegmentUploader.d.ts.map +1 -1
- package/dist/VideoSegmentUploader.js +28 -2
- package/dist/VideoSegmentUploader.js.map +1 -1
- package/dist/VlmCandidateBuffer.d.ts +2 -0
- package/dist/VlmCandidateBuffer.d.ts.map +1 -1
- package/dist/VlmCandidateBuffer.js.map +1 -1
- package/dist/WatchlistClient.d.ts +55 -0
- package/dist/WatchlistClient.d.ts.map +1 -0
- package/dist/WatchlistClient.js +161 -0
- package/dist/WatchlistClient.js.map +1 -0
- package/dist/autoSense.d.ts +2 -0
- package/dist/autoSense.d.ts.map +1 -1
- package/dist/autoSense.js +23 -1
- package/dist/autoSense.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/connectorUpdate.d.ts +16 -0
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +30 -6
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/hostCpu.d.ts +56 -0
- package/dist/hostCpu.d.ts.map +1 -0
- package/dist/hostCpu.js +113 -0
- package/dist/hostCpu.js.map +1 -0
- package/dist/localSensing.d.ts +17 -0
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +53 -2
- package/dist/localSensing.js.map +1 -1
- package/dist/windowsLiveView.d.ts +19 -2
- package/dist/windowsLiveView.d.ts.map +1 -1
- package/dist/windowsLiveView.js +72 -5
- package/dist/windowsLiveView.js.map +1 -1
- package/package.json +2 -2
- package/retained/RetainedCaptureClient.cjs +2 -0
- package/retained/WebsiteAdmissionCaptureClient.cjs +3 -1
- package/retained/__tests__/website-admission-realtime.test.cjs +27 -2
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FaceSightingUploader = void 0;
|
|
37
|
+
exports.newSightingId = newSightingId;
|
|
38
|
+
const crypto_1 = require("crypto");
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const AudienceAnalyzeClient_1 = require("./AudienceAnalyzeClient");
|
|
42
|
+
const BATCH = 16;
|
|
43
|
+
const FILE = /^(\d{13})-(fs_[a-f0-9]{32})\.json$/;
|
|
44
|
+
class FaceSightingUploader {
|
|
45
|
+
constructor(options) {
|
|
46
|
+
this.sending = null;
|
|
47
|
+
this.backoffMs = 0;
|
|
48
|
+
this.nextAttemptAtMs = 0;
|
|
49
|
+
this.counts = { queued: 0, accepted: 0, refused: 0, dropped: 0, failedPosts: 0 };
|
|
50
|
+
this.endpoint = `${options.apiBaseUrl.replace(/\/+$/, '')}/v2/earner/sense/face-sightings`;
|
|
51
|
+
this.deviceToken = options.deviceToken;
|
|
52
|
+
this.dir = options.dir;
|
|
53
|
+
this.poster = options.poster ?? AudienceAnalyzeClient_1.defaultHttpPoster;
|
|
54
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
55
|
+
this.maxFiles = options.maxFiles ?? 5000;
|
|
56
|
+
this.maxBytes = options.maxBytes ?? 512 * 1024 * 1024;
|
|
57
|
+
this.log = options.log ?? ((level, message) => (level === 'warn' ? console.warn : console.log)(message));
|
|
58
|
+
try {
|
|
59
|
+
fs.mkdirSync(this.dir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
catch { /* the first enqueue reports it */ }
|
|
62
|
+
}
|
|
63
|
+
/** Keep a sighting until the server has answered for it. */
|
|
64
|
+
enqueue(sighting) {
|
|
65
|
+
const name = `${String(sighting.firstSeenAtMs).padStart(13, '0')}-${sighting.sightingId}.json`;
|
|
66
|
+
const file = path.join(this.dir, name);
|
|
67
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
68
|
+
try {
|
|
69
|
+
fs.writeFileSync(tmp, JSON.stringify(sighting), { mode: 0o600 });
|
|
70
|
+
fs.renameSync(tmp, file);
|
|
71
|
+
this.counts.queued += 1;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
try {
|
|
75
|
+
fs.rmSync(tmp, { force: true });
|
|
76
|
+
}
|
|
77
|
+
catch { /* nothing to clean */ }
|
|
78
|
+
this.log('warn', `[face] sighting not spooled: ${error.message}`);
|
|
79
|
+
}
|
|
80
|
+
this.enforceBounds();
|
|
81
|
+
}
|
|
82
|
+
/** Files waiting, oldest first. */
|
|
83
|
+
pending() {
|
|
84
|
+
try {
|
|
85
|
+
return fs.readdirSync(this.dir).filter(name => FILE.test(name)).sort();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Send what is waiting, one POST at a time; never throws. */
|
|
92
|
+
flush(nowMs = Date.now()) {
|
|
93
|
+
if (this.sending)
|
|
94
|
+
return this.sending;
|
|
95
|
+
if (nowMs < this.nextAttemptAtMs)
|
|
96
|
+
return Promise.resolve();
|
|
97
|
+
this.sending = this.sendBatches().finally(() => { this.sending = null; });
|
|
98
|
+
return this.sending;
|
|
99
|
+
}
|
|
100
|
+
async sendBatches() {
|
|
101
|
+
for (let rounds = 0; rounds < 8; rounds++) {
|
|
102
|
+
const names = this.pending().slice(0, BATCH);
|
|
103
|
+
if (!names.length)
|
|
104
|
+
return;
|
|
105
|
+
const sightings = [];
|
|
106
|
+
const byId = new Map();
|
|
107
|
+
for (const name of names) {
|
|
108
|
+
try {
|
|
109
|
+
const s = JSON.parse(fs.readFileSync(path.join(this.dir, name), 'utf8'));
|
|
110
|
+
sightings.push(s);
|
|
111
|
+
byId.set(s.sightingId, name);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
this.remove(name);
|
|
115
|
+
this.counts.dropped += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!sightings.length)
|
|
119
|
+
continue;
|
|
120
|
+
let response;
|
|
121
|
+
try {
|
|
122
|
+
response = await this.poster(this.endpoint, { method: 'POST', timeoutMs: this.timeoutMs, headers: {
|
|
123
|
+
'Content-Type': 'application/json', Accept: 'application/json',
|
|
124
|
+
'X-Device-Token': this.deviceToken, 'X-Trillboard-Device-Token': this.deviceToken,
|
|
125
|
+
'X-Device-Timestamp': String(Date.now()), 'X-Device-Nonce': (0, crypto_1.randomUUID)()
|
|
126
|
+
} }, JSON.stringify({ version: 1, sightings }));
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
this.retryLater(`transport: ${error.message}`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (response.statusCode === 200) {
|
|
133
|
+
let body = {};
|
|
134
|
+
try {
|
|
135
|
+
body = JSON.parse(response.body);
|
|
136
|
+
}
|
|
137
|
+
catch { /* answered for nothing: keep and retry */ }
|
|
138
|
+
const accepted = Array.isArray(body.accepted) ? body.accepted.filter((id) => typeof id === 'string') : [];
|
|
139
|
+
const rejected = Array.isArray(body.rejected) ? body.rejected : [];
|
|
140
|
+
for (const id of accepted) {
|
|
141
|
+
const name = byId.get(id);
|
|
142
|
+
if (name) {
|
|
143
|
+
this.remove(name);
|
|
144
|
+
this.counts.accepted += 1;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const r of rejected) {
|
|
148
|
+
const name = typeof r?.sightingId === 'string' ? byId.get(r.sightingId) : undefined;
|
|
149
|
+
if (name) {
|
|
150
|
+
this.remove(name);
|
|
151
|
+
this.counts.refused += 1;
|
|
152
|
+
this.log('warn', `[face] sighting ${r.sightingId} refused: ${String(r.reason)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!accepted.length && !rejected.length) {
|
|
156
|
+
this.retryLater('empty answer');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.backoffMs = 0;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (response.statusCode === 400) {
|
|
163
|
+
// A batch the server cannot read never gets better: dropped, said once.
|
|
164
|
+
for (const name of byId.values())
|
|
165
|
+
this.remove(name);
|
|
166
|
+
this.counts.dropped += byId.size;
|
|
167
|
+
this.log('warn', `[face] ${byId.size} sighting(s) dropped: the server refused the batch (HTTP 400)`);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
this.retryLater(`HTTP ${response.statusCode}`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
retryLater(reason) {
|
|
175
|
+
this.counts.failedPosts += 1;
|
|
176
|
+
this.backoffMs = Math.min(10 * 60000, Math.max(5000, this.backoffMs * 2));
|
|
177
|
+
this.nextAttemptAtMs = Date.now() + this.backoffMs;
|
|
178
|
+
this.log('warn', `[face] sightings kept for retry in ${Math.round(this.backoffMs / 1000)}s (${reason})`);
|
|
179
|
+
}
|
|
180
|
+
remove(name) {
|
|
181
|
+
try {
|
|
182
|
+
fs.rmSync(path.join(this.dir, name), { force: true });
|
|
183
|
+
}
|
|
184
|
+
catch { /* gone */ }
|
|
185
|
+
}
|
|
186
|
+
/** Oldest out first, by count and by bytes. */
|
|
187
|
+
enforceBounds() {
|
|
188
|
+
const names = this.pending();
|
|
189
|
+
let bytes = 0;
|
|
190
|
+
const sizes = names.map(name => {
|
|
191
|
+
try {
|
|
192
|
+
const size = fs.statSync(path.join(this.dir, name)).size;
|
|
193
|
+
bytes += size;
|
|
194
|
+
return size;
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
let i = 0;
|
|
201
|
+
while (i < names.length && (names.length - i > this.maxFiles || bytes > this.maxBytes)) {
|
|
202
|
+
this.remove(names[i]);
|
|
203
|
+
bytes -= sizes[i];
|
|
204
|
+
this.counts.dropped += 1;
|
|
205
|
+
i += 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.FaceSightingUploader = FaceSightingUploader;
|
|
210
|
+
/** A new sighting id: `fs_` and 32 hex. */
|
|
211
|
+
function newSightingId() {
|
|
212
|
+
return 'fs_' + (0, crypto_1.randomUUID)().replace(/-/g, '');
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=FaceSightingUploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FaceSightingUploader.js","sourceRoot":"","sources":["../src/FaceSightingUploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiMA,sCAEC;AAnMD,mCAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAC7B,mEAA6E;AA6C7E,MAAM,KAAK,GAAG,EAAE,CAAC;AACjB,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAElD,MAAa,oBAAoB;IAc/B,YAAY,OAAoC;QALxC,YAAO,GAAyB,IAAI,CAAC;QACrC,cAAS,GAAG,CAAC,CAAC;QACd,oBAAe,GAAG,CAAC,CAAC;QACnB,WAAM,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAGnF,IAAI,CAAC,QAAQ,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,iCAAiC,CAAC;QAC3F,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,yCAAiB,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAM,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAK,CAAC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I,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC;YACzB,CAAC,IAAI,CAAC,CAAC;QACT,CAAC;IACH,CAAC;CACF;AA3ID,oDA2IC;AAED,2CAA2C;AAC3C,SAAgB,aAAa;IAC3B,OAAO,KAAK,GAAG,IAAA,mBAAU,GAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import type { HttpPoster } from './AudienceAnalyzeClient';
|
|
2
|
+
import type { FaceWatchlistMethod, WatchlistAnnouncement } from './DetectorFields';
|
|
3
|
+
import { type FaceRequest, type FaceResult } from './FaceIdentity';
|
|
4
|
+
import { FaceSightingUploader } from './FaceSightingUploader';
|
|
5
|
+
import { type FaceCaptureConfig, type FaceZone, type WatchlistMemory } from './FaceWatchPolicy';
|
|
6
|
+
import { type Gallery } from './WatchlistClient';
|
|
7
|
+
/**
|
|
8
|
+
* FaceWatchLane — one door camera's faces (plan v7 T1): its main stream's face zone (an edge-platform-rtsp
|
|
9
|
+
* FaceZoneOutput carried by the camera's ONE main-stream session, MainStreamRing.attachOutput), every face
|
|
10
|
+
* found and embedded by the detector service's face task (LocalDetectorClient.faces), tracked across frames
|
|
11
|
+
* (edge-core's CentroidTracker), the best 5 frames of each track kept, and each track posted as a door sighting
|
|
12
|
+
* when it ends (FaceSightingUploader -> audience_face_observations, per_face_rail cctv).
|
|
13
|
+
*
|
|
14
|
+
* COLLECT-ONLY until the camera's own receipt: face capture alone never matches. Matching starts only when the
|
|
15
|
+
* camera's retained profile carries a face_watchlist_v1 entry (setMatchPolicy, from LocalSensingClient), with the
|
|
16
|
+
* camera's threshold and the owner's gallery version. Then every embedded face is scored against the owner's
|
|
17
|
+
* gallery (WatchlistClient): a person's score is the best cosine to their templates, refused when the face is closer
|
|
18
|
+
* to one of their negatives (a face the owner said is not them). A person is announced when >= minFrames frames
|
|
19
|
+
* score at or above the threshold within windowMs, ONCE PER VISIT: the announce memory (kept on disk with the
|
|
20
|
+
* camera's scene memory, like the vehicle gate's) holds each announced person until they have been unseen for
|
|
21
|
+
* revisitMs. A visit is recorded only once its announcement exists (a face crop in hand): a crop that fails or is
|
|
22
|
+
* late leaves no visit, so the person's next matching frame announces again. The camera's next look takes the
|
|
23
|
+
* announcement (take) and answers watchlist_person_returned; the look jumps the review round (onAnnounce).
|
|
24
|
+
*
|
|
25
|
+
* ONE PULL PER CAMERA. The lane never opens the main stream itself: a recorder admits a bounded number of
|
|
26
|
+
* concurrent main-stream sessions, so the face output rides the session the camera's main-stream owner holds for
|
|
27
|
+
* its probe and its ring recording (one RTSP session, one credentials file, one admission ticket, one backoff).
|
|
28
|
+
*
|
|
29
|
+
* Never throws into the connector: a detector that does not answer drops the frame (counted); a camera whose main
|
|
30
|
+
* stream cannot be named, or a feed without a main-stream owner, keeps the lane off (reported).
|
|
31
|
+
*/
|
|
32
|
+
/** The face-zone output (edge-platform-rtsp FaceZoneOutput), as the lane drives it. */
|
|
33
|
+
export interface FaceZoneOutputLike {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
setCapture(capture: {
|
|
36
|
+
zone: FaceZone | null;
|
|
37
|
+
fps: number;
|
|
38
|
+
} | null): void;
|
|
39
|
+
on(event: 'frame', listener: (frame: {
|
|
40
|
+
jpeg: Buffer;
|
|
41
|
+
atMs: number;
|
|
42
|
+
seq: number;
|
|
43
|
+
}) => void): unknown;
|
|
44
|
+
getStats?(): unknown;
|
|
45
|
+
}
|
|
46
|
+
/** The camera's main-stream owner (MainStreamRing): the one session every main-stream consumer rides. */
|
|
47
|
+
export interface CameraMainStream {
|
|
48
|
+
attachOutput(output: {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
}): void;
|
|
51
|
+
detachOutput(name: string): void;
|
|
52
|
+
sessionState?(): string;
|
|
53
|
+
/** The owner's beacon block (MainStreamRing.report): read for its probe state when no session carries the output. */
|
|
54
|
+
report?(): {
|
|
55
|
+
probeState?: string;
|
|
56
|
+
} | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What the face lane is doing, on the five-minute beacon's `faceCapture` block (earner_screen_devices
|
|
60
|
+
* connector_face_state). A camera whose face capture is on reads `capturing` only while face-zone frames reach the
|
|
61
|
+
* detector; every other value names why not, so an on-but-refused camera never reads as a quiet one.
|
|
62
|
+
*
|
|
63
|
+
* off the camera's face capture is off (or the lane has not read the setting yet)
|
|
64
|
+
* capturing face-zone frames reached the lane in the window and the detector ran on them
|
|
65
|
+
* starting on and attached; the camera's main-stream session is starting (or was just asked to)
|
|
66
|
+
* no_frames the main-stream session runs, but no face-zone frame arrived in the window
|
|
67
|
+
* session_limit no main-stream room on the recorder for this camera now (the per-recorder cap, or a shed)
|
|
68
|
+
* refused the recorder refused the camera's main stream (busy, login or path); re-probed later
|
|
69
|
+
* backoff the main-stream session ended (unreachable, timed out, broken); retrying after a delay
|
|
70
|
+
* detector_down frames arrived, but the detector service answered none of them
|
|
71
|
+
* no_main_stream the feed's main stream cannot be named, or the feed has no main-stream owner
|
|
72
|
+
* unsupported this install cannot capture faces here (no face-zone output, or an unsupported main stream)
|
|
73
|
+
*/
|
|
74
|
+
export type FaceCaptureState = 'off' | 'capturing' | 'starting' | 'no_frames' | 'session_limit' | 'refused' | 'backoff' | 'detector_down' | 'no_main_stream' | 'unsupported';
|
|
75
|
+
/**
|
|
76
|
+
* The beacon's `faceCapture` block, per camera: the window since the lane's previous report (or its start, so a
|
|
77
|
+
* restarted connector starts again from zero). Every count is that window's delta, never a lifetime total.
|
|
78
|
+
*/
|
|
79
|
+
export interface FaceCaptureReport {
|
|
80
|
+
state: FaceCaptureState;
|
|
81
|
+
/** True only in state `capturing`. */
|
|
82
|
+
capturing: boolean;
|
|
83
|
+
/** Face-zone frames the camera's main-stream session delivered to the lane (the face output's own count). */
|
|
84
|
+
frames: number;
|
|
85
|
+
/** Frames the detector service answered (found faces or not). */
|
|
86
|
+
framesDetected: number;
|
|
87
|
+
/** Faces the detector found in those frames. */
|
|
88
|
+
faces: number;
|
|
89
|
+
/** Door sightings the server accepted. */
|
|
90
|
+
sightings: number;
|
|
91
|
+
/** When the face output delivered its last frame (this PC's clock, ISO-8601); null in `off` or never. */
|
|
92
|
+
lastFrameAt: string | null;
|
|
93
|
+
/** The window's length, on the monotonic clock. */
|
|
94
|
+
windowSeconds: number;
|
|
95
|
+
}
|
|
96
|
+
/** A window shorter than this says nothing; the baseline is kept for the next report. */
|
|
97
|
+
export declare const FACE_REPORT_MIN_WINDOW_MS = 1000;
|
|
98
|
+
/** After an attach, a running session that has not delivered a frame yet is `starting`, not `no_frames`. */
|
|
99
|
+
export declare const FACE_START_GRACE_MS = 60000;
|
|
100
|
+
export interface FaceWatchLaneOptions {
|
|
101
|
+
feedName: string;
|
|
102
|
+
/** The feed's own (substream) URL; its main stream is derived (ChannelProber.deriveMainStreamUrl). */
|
|
103
|
+
rtspUrl: string;
|
|
104
|
+
apiBaseUrl: string;
|
|
105
|
+
deviceToken: string;
|
|
106
|
+
/** The camera's directory for its sighting spool and gallery cache. */
|
|
107
|
+
dir: string;
|
|
108
|
+
faces: (jpeg: Buffer, request: FaceRequest) => Promise<FaceResult>;
|
|
109
|
+
/** The camera's main-stream owner (its recorder's MainStreamRing); null: the lane stays off. */
|
|
110
|
+
mainStream: CameraMainStream | null;
|
|
111
|
+
/** Builds the face-zone output (default: edge-platform-rtsp FaceZoneOutput). */
|
|
112
|
+
outputFactory?: () => FaceZoneOutputLike;
|
|
113
|
+
/** Crops a face out of a zone frame (default: sharp). Null when it cannot. */
|
|
114
|
+
cropFace?: (jpeg: Buffer, box: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
width: number;
|
|
118
|
+
height: number;
|
|
119
|
+
}) => Promise<Buffer | null>;
|
|
120
|
+
poster?: HttpPoster;
|
|
121
|
+
pollMs?: number;
|
|
122
|
+
galleryPollMs?: number;
|
|
123
|
+
now?: () => number;
|
|
124
|
+
/** Monotonic milliseconds for the beacon window (default process.hrtime). */
|
|
125
|
+
monotonicMs?: () => number;
|
|
126
|
+
log?: (level: 'info' | 'warn', message: string) => void;
|
|
127
|
+
}
|
|
128
|
+
/** The best cosine of `probe` to a person, or null when the probe is closer to one of their negatives. */
|
|
129
|
+
export declare function personScore(probe: ArrayLike<number>, templates: ReadonlyArray<ArrayLike<number>>, negatives: ReadonlyArray<ArrayLike<number>>): number | null;
|
|
130
|
+
/** The gallery person a probe matches best, at or above `threshold`, or null. */
|
|
131
|
+
export declare function bestMatch(probe: ArrayLike<number>, gallery: Gallery, threshold: number): {
|
|
132
|
+
personId: string;
|
|
133
|
+
similarity: number;
|
|
134
|
+
} | null;
|
|
135
|
+
/**
|
|
136
|
+
* The announce rule, pure: given a person's recent hits and the memory, announce or not, and the memory after.
|
|
137
|
+
* A person is announced when `minFrames` hits fall within `windowMs` and the memory holds no visit of theirs
|
|
138
|
+
* seen within `revisitMs`; every hit keeps the visit alive. The memory after never holds a NEW visit: that is
|
|
139
|
+
* recorded (recordVisit) only once the announcement exists, so an announcement that could not be made is retried.
|
|
140
|
+
*/
|
|
141
|
+
export declare function announceRule(input: {
|
|
142
|
+
personId: string;
|
|
143
|
+
hits: ReadonlyArray<{
|
|
144
|
+
atMs: number;
|
|
145
|
+
}>;
|
|
146
|
+
nowMs: number;
|
|
147
|
+
method: Pick<FaceWatchlistMethod, 'minFrames' | 'windowMs' | 'announce'>;
|
|
148
|
+
memory: WatchlistMemory;
|
|
149
|
+
}): {
|
|
150
|
+
announce: boolean;
|
|
151
|
+
framesAbove: number;
|
|
152
|
+
memory: WatchlistMemory;
|
|
153
|
+
};
|
|
154
|
+
/** The memory once a person's announcement exists: their visit recorded, seen now. Pure. */
|
|
155
|
+
export declare function recordVisit(memory: WatchlistMemory, personId: string, nowMs: number, method: Pick<FaceWatchlistMethod, 'announce'>): WatchlistMemory;
|
|
156
|
+
export declare class FaceWatchLane {
|
|
157
|
+
private readonly o;
|
|
158
|
+
private readonly profileClient;
|
|
159
|
+
private readonly watchlist;
|
|
160
|
+
readonly uploader: FaceSightingUploader;
|
|
161
|
+
private readonly now;
|
|
162
|
+
private readonly log;
|
|
163
|
+
private capture;
|
|
164
|
+
private output;
|
|
165
|
+
private attached;
|
|
166
|
+
private tracker;
|
|
167
|
+
private readonly tracks;
|
|
168
|
+
private staticSpots;
|
|
169
|
+
/** Track ids of this process: a random base (a restart never reuses the last run's ids) and a counter. */
|
|
170
|
+
private readonly trackBase;
|
|
171
|
+
private trackSeq;
|
|
172
|
+
private busy;
|
|
173
|
+
private policy;
|
|
174
|
+
private readonly hits;
|
|
175
|
+
private readonly announcements;
|
|
176
|
+
/** People whose announcement is being made (waiting for its face crop): one at a time per person. */
|
|
177
|
+
private readonly announcing;
|
|
178
|
+
/** People whose last announcement had no face crop: warned once until one is made. */
|
|
179
|
+
private readonly cropMissWarned;
|
|
180
|
+
private memory;
|
|
181
|
+
private memoryStore;
|
|
182
|
+
private timers;
|
|
183
|
+
private started;
|
|
184
|
+
private readonly onAnnounceListeners;
|
|
185
|
+
private offReason;
|
|
186
|
+
readonly counts: {
|
|
187
|
+
frames: number;
|
|
188
|
+
droppedBusy: number;
|
|
189
|
+
detected: number;
|
|
190
|
+
detectorFailures: number;
|
|
191
|
+
faces: number;
|
|
192
|
+
embedded: number;
|
|
193
|
+
sightings: number;
|
|
194
|
+
hits: number;
|
|
195
|
+
announced: number;
|
|
196
|
+
taken: number;
|
|
197
|
+
staticFaces: number;
|
|
198
|
+
};
|
|
199
|
+
private readonly monotonicMs;
|
|
200
|
+
/** When the face output was last attached (monotonic ms): the start of its grace. */
|
|
201
|
+
private attachedAtMs;
|
|
202
|
+
/** The previous beacon report's counters: the next window is the difference. */
|
|
203
|
+
private reportBase;
|
|
204
|
+
constructor(options: FaceWatchLaneOptions);
|
|
205
|
+
/** Poll the camera's face capture, flush sightings, end idle tracks. Idempotent. */
|
|
206
|
+
start(): void;
|
|
207
|
+
stop(): void;
|
|
208
|
+
/** The camera's scene memory keeps the announce memory across restarts (UniformSceneStore). */
|
|
209
|
+
useMemory(store: {
|
|
210
|
+
get(): unknown;
|
|
211
|
+
set(memory: WatchlistMemory): void;
|
|
212
|
+
}): void;
|
|
213
|
+
/** face_watchlist_v1 for this camera, from its applied retained profile; null = collect-only. */
|
|
214
|
+
setMatchPolicy(method: FaceWatchlistMethod | null): void;
|
|
215
|
+
onAnnounce(listener: (announcement: WatchlistAnnouncement) => void): void;
|
|
216
|
+
/**
|
|
217
|
+
* The announcement this look takes, at most one, at most once: the oldest made under this method (its threshold
|
|
218
|
+
* and minimum frames) inside announceMs of the look's capture. Later looks take nothing until the next return.
|
|
219
|
+
*/
|
|
220
|
+
take(method: FaceWatchlistMethod, capturedAtMs: number): WatchlistAnnouncement | undefined;
|
|
221
|
+
/** An announcement no look has taken yet, made within the method's announce window. */
|
|
222
|
+
hasPendingAnnouncement(nowMs: number): boolean;
|
|
223
|
+
stats(): Record<string, unknown>;
|
|
224
|
+
/** The device token of the feed this lane serves (its beacon report rides that token). */
|
|
225
|
+
get deviceToken(): string;
|
|
226
|
+
/**
|
|
227
|
+
* The beacon's `faceCapture` block: the window since the previous report (or the lane's start), then a new
|
|
228
|
+
* baseline. Null only for a window under FACE_REPORT_MIN_WINDOW_MS (the baseline is kept). In `off` every count
|
|
229
|
+
* is 0 and lastFrameAt null, so a camera turned off stops claiming it captures.
|
|
230
|
+
*/
|
|
231
|
+
report(): FaceCaptureReport | null;
|
|
232
|
+
/** What the lane is doing (FaceCaptureState), from its own state, the camera's main-stream session and the window. */
|
|
233
|
+
private captureState;
|
|
234
|
+
/** The face output's own frame count and last frame time (FaceZoneOutput.getStats), tolerant of an older output. */
|
|
235
|
+
private outputCounters;
|
|
236
|
+
/** One profile read: only an explicit faceCapture changes anything (absent and unreadable keep the last). */
|
|
237
|
+
poll(): Promise<void>;
|
|
238
|
+
/** Start, re-plan (zone or fps changed) or stop the face-zone output on the camera's main-stream session. */
|
|
239
|
+
applyCapture(next: FaceCaptureConfig | false): void;
|
|
240
|
+
/** Take the face output off the camera's main-stream session (the session stops if nothing else rides it). */
|
|
241
|
+
private detach;
|
|
242
|
+
/** One face-zone frame. Dropped, never queued, while the previous one is with the detector. */
|
|
243
|
+
onFrame(frame: {
|
|
244
|
+
jpeg: Buffer;
|
|
245
|
+
atMs: number;
|
|
246
|
+
seq: number;
|
|
247
|
+
}): Promise<void>;
|
|
248
|
+
private observe;
|
|
249
|
+
/** Score one embedded face against the gallery; announce a person who has returned. */
|
|
250
|
+
private match;
|
|
251
|
+
private announce;
|
|
252
|
+
private endIdleTracks;
|
|
253
|
+
/** A track that ended becomes one sighting (with its photo), queued until the server answers for it. */
|
|
254
|
+
private endTrack;
|
|
255
|
+
}
|
|
256
|
+
/** A face box in zone-frame pixels, normalised to the whole camera frame. */
|
|
257
|
+
export declare function toCameraBox(box: {
|
|
258
|
+
x: number;
|
|
259
|
+
y: number;
|
|
260
|
+
width: number;
|
|
261
|
+
height: number;
|
|
262
|
+
}, frame: {
|
|
263
|
+
width: number;
|
|
264
|
+
height: number;
|
|
265
|
+
}, zone: FaceZone | null): {
|
|
266
|
+
x: number;
|
|
267
|
+
y: number;
|
|
268
|
+
width: number;
|
|
269
|
+
height: number;
|
|
270
|
+
};
|
|
271
|
+
export interface AttachFaceWatchArgs {
|
|
272
|
+
feedName: string;
|
|
273
|
+
rtspUrl: string;
|
|
274
|
+
/** The camera's main-stream owner (the feed recorder's MainStreamRing); null: the lane stays off. */
|
|
275
|
+
mainStream: CameraMainStream | null;
|
|
276
|
+
apiBaseUrl: string;
|
|
277
|
+
deviceToken: string;
|
|
278
|
+
dir: string;
|
|
279
|
+
detectorBaseUrl?: string;
|
|
280
|
+
httpPoster?: HttpPoster;
|
|
281
|
+
pollMs?: number;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The face lane of a crop-less camera feed: polls the camera's face capture and does nothing more until it is on.
|
|
285
|
+
* A second lane for the same directory replaces the first.
|
|
286
|
+
*/
|
|
287
|
+
export declare function attachFaceWatch(args: AttachFaceWatchArgs): FaceWatchLane;
|
|
288
|
+
/** Every attached lane, for diagnostics. */
|
|
289
|
+
export declare function activeFaceWatchLanes(): FaceWatchLane[];
|
|
290
|
+
/**
|
|
291
|
+
* The beacon's `faceCapture` block of the feed that uses this device token (its lane's window since the last call),
|
|
292
|
+
* or null for a token with no face lane. Call it once per beacon per token: each call starts a new window.
|
|
293
|
+
*/
|
|
294
|
+
export declare function faceCaptureReportForToken(deviceToken: string): FaceCaptureReport | null;
|
|
295
|
+
/** Test seam. */
|
|
296
|
+
export declare function __resetFaceWatchLanesForTests(): void;
|
|
297
|
+
//# sourceMappingURL=FaceWatchLane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FaceWatchLane.d.ts","sourceRoot":"","sources":["../src/FaceWatchLane.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAwE,KAAK,WAAW,EAC7F,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAoC,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAuE,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EACjH,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,uFAAuF;AACvF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,IAAI,CAAC;IACzE,EAAE,CAAC,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