@camstack/addon-pipeline 1.1.65 → 1.1.67
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/dist/audio-analyzer/index.js +1 -1
- package/dist/audio-analyzer/index.mjs +1 -1
- package/dist/detection-pipeline/index.js +83 -22
- package/dist/detection-pipeline/index.mjs +83 -22
- package/dist/{dist-WW3gH8hF.js → dist-BxxVKcnw.js} +56 -5
- package/dist/{dist-D6tHM9GA.mjs → dist-DkGHtAaK.mjs} +56 -5
- package/dist/motion-wasm/index.js +1 -1
- package/dist/motion-wasm/index.mjs +1 -1
- package/dist/pipeline-runner/index.js +88 -22
- package/dist/pipeline-runner/index.mjs +88 -22
- package/dist/recorder/index.js +141 -1
- package/dist/recorder/index.mjs +141 -1
- package/dist/session-decode/decode-worker-child.js +185 -14
- package/dist/session-decode/decode-worker-child.mjs +185 -14
- package/dist/{step-definitions-CXZpwwT0.js → step-definitions-CAs0RD2N.js} +127 -8
- package/dist/{step-definitions-Dbsm64_I.mjs → step-definitions-Delhq28w.mjs} +127 -8
- package/dist/stream-broker/_stub.js +2 -2
- package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-CbU_HuOC.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-CfFsU700.mjs} +2 -2
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D68Lj69v.mjs +26 -0
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DlALQ_wp.mjs +26 -0
- package/dist/stream-broker/{hostInit-QaDEOY0Z.mjs → hostInit-D-S5fCDx.mjs} +2 -2
- package/dist/stream-broker/index.js +1 -1
- package/dist/stream-broker/index.mjs +1 -1
- package/dist/stream-broker/remoteEntry.js +1 -1
- package/embed-dist/assets/{MaskShapeCanvas-DI4BY7W2-C7H0kVAH.js → MaskShapeCanvas-DI4BY7W2-CRvzj7Of.js} +1 -1
- package/embed-dist/assets/{MotionZonesSettings-NcxxQN8r-CHfEFlEF.js → MotionZonesSettings-NcxxQN8r-CBgvPUB-.js} +1 -1
- package/embed-dist/assets/{PrivacyMaskSettings-APgPLF7p-Bc-trVxX.js → PrivacyMaskSettings-APgPLF7p-DH07fe1k.js} +1 -1
- package/embed-dist/assets/index-BkoPcGtQ.js +114 -0
- package/embed-dist/assets/index-D2pF9Z3W.css +2 -0
- package/embed-dist/index.html +2 -2
- package/package.json +1 -1
- package/python/inference_pool.py +392 -45
- package/python/postprocessors/softmax.py +17 -5
- package/python/postprocessors/test_softmax.py +52 -0
- package/python/test_inference_pool_ov_ppp.py +117 -0
- package/python/test_inference_pool_preprocess.py +93 -1
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CxZvj8X1.mjs +0 -26
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BzNJyeNE.mjs +0 -26
- package/embed-dist/assets/index-Bm9LaQPH.css +0 -2
- package/embed-dist/assets/index-eZGm_itM.js +0 -81
|
@@ -7207,6 +7207,17 @@ var ModelCatalogEntrySchema = object({
|
|
|
7207
7207
|
"imagenet",
|
|
7208
7208
|
"none"
|
|
7209
7209
|
]).optional(),
|
|
7210
|
+
/**
|
|
7211
|
+
* The model already applies softmax IN-GRAPH — its raw output is a
|
|
7212
|
+
* probability distribution, not logits. When set, the `softmax`
|
|
7213
|
+
* postprocessor must NOT re-apply softmax: re-softmaxing an already-normalised
|
|
7214
|
+
* probability vector collapses it toward uniform (top-1 score craters far
|
|
7215
|
+
* below its true value, making every confidence gate meaningless). Absent ⇒
|
|
7216
|
+
* the output is raw logits and the postprocessor applies softmax (the normal
|
|
7217
|
+
* case). Set on the Google AIY Birds `bird-classifier` (softmax baked into the
|
|
7218
|
+
* TF graph). Threaded to the Python pool via `PoolModelConfig.outputProbabilities`.
|
|
7219
|
+
*/
|
|
7220
|
+
outputProbabilities: boolean().optional(),
|
|
7210
7221
|
preprocessMode: _enum(["letterbox", "resize"]).optional(),
|
|
7211
7222
|
/**
|
|
7212
7223
|
* Per-MODEL postprocessor override. Absent ⇒ the step's own
|
|
@@ -12081,7 +12092,14 @@ var pipelineExecutorCapability = {
|
|
|
12081
12092
|
* (inputClasses ≠ null) are skipped and served per-track via
|
|
12082
12093
|
* pipelineRunner.runDetailSubtree (two-plane design).
|
|
12083
12094
|
*/
|
|
12084
|
-
plane: _enum(["full", "frame"]).optional()
|
|
12095
|
+
plane: _enum(["full", "frame"]).optional(),
|
|
12096
|
+
/**
|
|
12097
|
+
* Inference-device selector (Phase 2 multi-device). Format
|
|
12098
|
+
* `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
|
|
12099
|
+
* Omitted ⇒ the runner's default device (current single-engine
|
|
12100
|
+
* behaviour). Selects WHICH device pool of the node runs the call.
|
|
12101
|
+
*/
|
|
12102
|
+
deviceKey: string().optional()
|
|
12085
12103
|
}), PipelineRunResultBridge, { kind: "mutation" }),
|
|
12086
12104
|
/**
|
|
12087
12105
|
* Batched run — N raw frames packed into one cap call. The provider
|
|
@@ -12099,7 +12117,20 @@ var pipelineExecutorCapability = {
|
|
|
12099
12117
|
steps: array(PipelineStepInputSchema).min(1),
|
|
12100
12118
|
frames: array(FrameInputSchema).min(1).max(255),
|
|
12101
12119
|
deviceId: number().optional(),
|
|
12102
|
-
sessionId: string().optional()
|
|
12120
|
+
sessionId: string().optional(),
|
|
12121
|
+
/**
|
|
12122
|
+
* Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
|
|
12123
|
+
* the batch to the Python pool's bench preprocess cache
|
|
12124
|
+
* (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
|
|
12125
|
+
* preprocessed ONCE and every later inference is a pure-inference cache
|
|
12126
|
+
* hit — the sustained-throughput run measures inference, not
|
|
12127
|
+
* decode+preprocess+infer. Omitted/0 for live frames (all different →
|
|
12128
|
+
* full preprocess every call, correct). Fresh per sustained run;
|
|
12129
|
+
* released via `uncacheFrame`.
|
|
12130
|
+
*/
|
|
12131
|
+
frameId: number().int().nonnegative().optional(),
|
|
12132
|
+
/** Inference-device selector (Phase 2 multi-device); see runPipeline. */
|
|
12133
|
+
deviceKey: string().optional()
|
|
12103
12134
|
}), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
|
|
12104
12135
|
/**
|
|
12105
12136
|
* Cache a raw frame inside the Python inference pool's memory.
|
|
@@ -12516,7 +12547,14 @@ var RunnerCameraConfigSchema = object({
|
|
|
12516
12547
|
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
12517
12548
|
* `remoteSourcingNodes` rollout setting).
|
|
12518
12549
|
*/
|
|
12519
|
-
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
12550
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" }),
|
|
12551
|
+
/**
|
|
12552
|
+
* Inference-device selector for this camera's sessions (Phase 2 multi-device).
|
|
12553
|
+
* Format `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`);
|
|
12554
|
+
* omitted ⇒ the runner's default device. The engine itself stays node-local —
|
|
12555
|
+
* this only selects WHICH device pool of that node runs the session.
|
|
12556
|
+
*/
|
|
12557
|
+
deviceKey: string().optional()
|
|
12520
12558
|
});
|
|
12521
12559
|
motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
|
|
12522
12560
|
/**
|
|
@@ -14087,6 +14125,8 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
|
|
|
14087
14125
|
kind: "mutation",
|
|
14088
14126
|
auth: "admin"
|
|
14089
14127
|
});
|
|
14128
|
+
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
|
|
14129
|
+
new Set(Object.values(DeviceType));
|
|
14090
14130
|
/**
|
|
14091
14131
|
* Evaluate `rules` against `items`. Returns the items partitioned
|
|
14092
14132
|
* into `passed` (kept by the gate) and `excluded` (dropped). When
|
|
@@ -21000,17 +21040,28 @@ var PlatformScoreSchema = object({
|
|
|
21000
21040
|
format: _enum([
|
|
21001
21041
|
"onnx",
|
|
21002
21042
|
"coreml",
|
|
21003
|
-
"openvino"
|
|
21043
|
+
"openvino",
|
|
21044
|
+
"tflite"
|
|
21004
21045
|
]),
|
|
21005
21046
|
score: number(),
|
|
21006
21047
|
reason: string(),
|
|
21007
21048
|
available: boolean()
|
|
21008
21049
|
});
|
|
21050
|
+
var InferenceDeviceDescriptorSchema = object({
|
|
21051
|
+
key: string(),
|
|
21052
|
+
backend: string(),
|
|
21053
|
+
device: string(),
|
|
21054
|
+
format: ModelFormatSchema,
|
|
21055
|
+
runtime: literal("python"),
|
|
21056
|
+
score: number(),
|
|
21057
|
+
available: boolean()
|
|
21058
|
+
});
|
|
21009
21059
|
var PlatformCapabilitiesSchema = object({
|
|
21010
21060
|
hardware: HardwareInfoSchema,
|
|
21011
21061
|
scores: array(PlatformScoreSchema).readonly(),
|
|
21012
21062
|
bestScore: PlatformScoreSchema,
|
|
21013
|
-
pythonPath: string().nullable()
|
|
21063
|
+
pythonPath: string().nullable(),
|
|
21064
|
+
devices: array(InferenceDeviceDescriptorSchema).readonly()
|
|
21014
21065
|
});
|
|
21015
21066
|
var ModelRequirementSchema = object({
|
|
21016
21067
|
modelId: string(),
|
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_dist = require("../dist-
|
|
5
|
+
const require_dist = require("../dist-BxxVKcnw.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
//#region src/motion-wasm/wasm-motion-detector.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as evaluateZoneRules, K as hydrateSchema, O as motionDetectionCapability, V as BaseAddon, W as DeviceType } from "../dist-
|
|
1
|
+
import { C as evaluateZoneRules, K as hydrateSchema, O as motionDetectionCapability, V as BaseAddon, W as DeviceType } from "../dist-DkGHtAaK.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
//#region src/motion-wasm/wasm-motion-detector.ts
|
|
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../chunk-D6vf50IK.js");
|
|
6
|
-
const require_dist = require("../dist-
|
|
6
|
+
const require_dist = require("../dist-BxxVKcnw.js");
|
|
7
7
|
const require_remote_restream = require("../remote-restream-CO36Sr30.js");
|
|
8
8
|
const require_sheet_geometry = require("../sheet-geometry-BR-ip0CP.js");
|
|
9
9
|
const require_worker_protocol = require("../worker-protocol-PP4jKHHJ.js");
|
|
10
|
-
const require_step_definitions = require("../step-definitions-
|
|
10
|
+
const require_step_definitions = require("../step-definitions-CAs0RD2N.js");
|
|
11
11
|
let node_child_process = require("node:child_process");
|
|
12
12
|
let node_url = require("node:url");
|
|
13
13
|
let sharp = require("sharp");
|
|
@@ -1248,23 +1248,39 @@ function startGuardedSessionDecode(deps) {
|
|
|
1248
1248
|
/** {@link RETAINED_FRAME_BUDGET_MB} in bytes. */
|
|
1249
1249
|
var RETAINED_FRAME_BUDGET_BYTES = (() => {
|
|
1250
1250
|
const raw = Number(process.env["CAMSTACK_SESSION_RETAIN_MB"]);
|
|
1251
|
-
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) :
|
|
1251
|
+
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 96;
|
|
1252
1252
|
})() * 1024 * 1024;
|
|
1253
|
+
/**
|
|
1254
|
+
* How many of each device's MOST RECENT frames are protected from a busy
|
|
1255
|
+
* neighbour's budget eviction. Sized to cover the late two-plane / cross-process
|
|
1256
|
+
* enrichment horizon (~150-500 ms): 6 frames ≈ 0.6 s @10 fps of guaranteed
|
|
1257
|
+
* survival for every active camera. Read ONCE from
|
|
1258
|
+
* `CAMSTACK_SESSION_RETAIN_FLOOR`; `0` disables the floor (pure global FIFO — the
|
|
1259
|
+
* pre-2026-07-19 behaviour). The hard byte ceiling always overrides the floor,
|
|
1260
|
+
* so this can never push retention past {@link RETAINED_FRAME_BUDGET_BYTES}.
|
|
1261
|
+
*/
|
|
1262
|
+
var RETAINED_FRAME_PER_DEVICE_FLOOR = (() => {
|
|
1263
|
+
const raw = Number(process.env["CAMSTACK_SESSION_RETAIN_FLOOR"]);
|
|
1264
|
+
return Number.isFinite(raw) && raw >= 0 ? Math.floor(raw) : 6;
|
|
1265
|
+
})();
|
|
1253
1266
|
/** Opaque RAM-key prefix stamped into a retained frame's `FrameHandle.shmId`. */
|
|
1254
1267
|
var RETAINED_FRAME_KEY_PREFIX = "ram:";
|
|
1255
1268
|
/** A retention frame is uniquely identified by its key + slot + committed seq. */
|
|
1256
1269
|
function keyOf(handle) {
|
|
1257
1270
|
return `${handle.shmId}#${handle.slot}#${handle.seq}`;
|
|
1258
1271
|
}
|
|
1259
|
-
/**
|
|
1260
|
-
* Node-level RAM store of retained rgb detection frames, keyed by
|
|
1261
|
-
* `FrameHandle` identity. Latest-wins with a byte budget.
|
|
1262
|
-
*/
|
|
1263
1272
|
var RetainedFrameStore = class RetainedFrameStore {
|
|
1264
1273
|
nodeId;
|
|
1265
1274
|
budgetBytes;
|
|
1266
|
-
|
|
1275
|
+
perDeviceFloor;
|
|
1276
|
+
/** Insertion-ordered (Map) → globally oldest is `keys().next()`. */
|
|
1267
1277
|
entries = /* @__PURE__ */ new Map();
|
|
1278
|
+
/**
|
|
1279
|
+
* Per-device insertion-ordered keys (oldest→newest). Mirrors {@link entries}
|
|
1280
|
+
* so the floor can be enforced in O(1) per eviction candidate without scanning
|
|
1281
|
+
* the global map for a device's frame count.
|
|
1282
|
+
*/
|
|
1283
|
+
perDeviceKeys = /* @__PURE__ */ new Map();
|
|
1268
1284
|
bytes = 0;
|
|
1269
1285
|
seq = 0;
|
|
1270
1286
|
/** Ring width used only to spread the `slot` field; the map key is authoritative. */
|
|
@@ -1272,6 +1288,7 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1272
1288
|
constructor(options) {
|
|
1273
1289
|
this.nodeId = options.nodeId;
|
|
1274
1290
|
this.budgetBytes = options.budgetBytes ?? RETAINED_FRAME_BUDGET_BYTES;
|
|
1291
|
+
this.perDeviceFloor = options.perDeviceFloor ?? RETAINED_FRAME_PER_DEVICE_FLOOR;
|
|
1275
1292
|
}
|
|
1276
1293
|
/** Number of retained frames (tests / metrics). */
|
|
1277
1294
|
get size() {
|
|
@@ -1304,14 +1321,21 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1304
1321
|
nodeId: this.nodeId,
|
|
1305
1322
|
slotCount: RetainedFrameStore.SLOT_SPREAD
|
|
1306
1323
|
};
|
|
1307
|
-
|
|
1324
|
+
const key = keyOf(handle);
|
|
1325
|
+
this.entries.set(key, {
|
|
1326
|
+
frame,
|
|
1327
|
+
deviceId
|
|
1328
|
+
});
|
|
1329
|
+
const deviceKeys = this.perDeviceKeys.get(deviceId);
|
|
1330
|
+
if (deviceKeys) deviceKeys.push(key);
|
|
1331
|
+
else this.perDeviceKeys.set(deviceId, [key]);
|
|
1308
1332
|
this.bytes += byteLength;
|
|
1309
1333
|
this.evictToBudget();
|
|
1310
1334
|
return handle;
|
|
1311
1335
|
}
|
|
1312
1336
|
/** The retained frame for `handle`, or `null` if never retained / already evicted. */
|
|
1313
1337
|
getFrame(handle) {
|
|
1314
|
-
return this.entries.get(keyOf(handle)) ?? null;
|
|
1338
|
+
return this.entries.get(keyOf(handle))?.frame ?? null;
|
|
1315
1339
|
}
|
|
1316
1340
|
/**
|
|
1317
1341
|
* Crop (and optionally downscale) the retained rgb frame for `handle` to the
|
|
@@ -1322,26 +1346,56 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1322
1346
|
* decode worker's surface (`getNativeCrop`), not here.
|
|
1323
1347
|
*/
|
|
1324
1348
|
crop(handle, bbox, maxWidth) {
|
|
1325
|
-
const
|
|
1326
|
-
if (!
|
|
1327
|
-
return cropRgb(frame, bbox, maxWidth);
|
|
1349
|
+
const entry = this.entries.get(keyOf(handle));
|
|
1350
|
+
if (!entry || entry.frame.format !== "rgb") return null;
|
|
1351
|
+
return cropRgb(entry.frame, bbox, maxWidth);
|
|
1328
1352
|
}
|
|
1329
1353
|
/** Drop every retained frame (node/addon shutdown). */
|
|
1330
1354
|
clear() {
|
|
1331
1355
|
this.entries.clear();
|
|
1356
|
+
this.perDeviceKeys.clear();
|
|
1332
1357
|
this.bytes = 0;
|
|
1333
1358
|
}
|
|
1334
|
-
/**
|
|
1359
|
+
/**
|
|
1360
|
+
* Evict frames until the retained bytes fit the budget (keep ≥1).
|
|
1361
|
+
*
|
|
1362
|
+
* Pass 1 (fairness): walk globally oldest→newest and drop only frames whose
|
|
1363
|
+
* device still holds MORE than {@link perDeviceFloor} frames — so a busy
|
|
1364
|
+
* camera's excess is reclaimed before any camera's protected recent window.
|
|
1365
|
+
* Pass 2 (OOM guard): if still over budget (every remaining frame is
|
|
1366
|
+
* floor-protected yet the ceiling is exhausted), drop globally oldest-first
|
|
1367
|
+
* regardless of the floor. The ceiling ALWAYS wins over fairness.
|
|
1368
|
+
*/
|
|
1335
1369
|
evictToBudget() {
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
this.entries.
|
|
1341
|
-
if (
|
|
1370
|
+
if (this.bytes <= this.budgetBytes) return;
|
|
1371
|
+
const oldestFirst = [...this.entries.keys()];
|
|
1372
|
+
for (const key of oldestFirst) {
|
|
1373
|
+
if (this.bytes <= this.budgetBytes || this.entries.size <= 1) break;
|
|
1374
|
+
const entry = this.entries.get(key);
|
|
1375
|
+
if (!entry) continue;
|
|
1376
|
+
const deviceKeys = this.perDeviceKeys.get(entry.deviceId);
|
|
1377
|
+
if (deviceKeys && deviceKeys.length > this.perDeviceFloor) this.dropKey(key);
|
|
1378
|
+
}
|
|
1379
|
+
if (this.bytes <= this.budgetBytes) return;
|
|
1380
|
+
for (const key of oldestFirst) {
|
|
1381
|
+
if (this.bytes <= this.budgetBytes || this.entries.size <= 1) break;
|
|
1382
|
+
this.dropKey(key);
|
|
1342
1383
|
}
|
|
1343
1384
|
if (this.bytes < 0) this.bytes = 0;
|
|
1344
1385
|
}
|
|
1386
|
+
/** Remove one frame by key, keeping the byte tally + per-device index exact. */
|
|
1387
|
+
dropKey(key) {
|
|
1388
|
+
const entry = this.entries.get(key);
|
|
1389
|
+
if (!entry) return;
|
|
1390
|
+
this.entries.delete(key);
|
|
1391
|
+
this.bytes -= entry.frame.data.byteLength;
|
|
1392
|
+
const deviceKeys = this.perDeviceKeys.get(entry.deviceId);
|
|
1393
|
+
if (deviceKeys) {
|
|
1394
|
+
const idx = deviceKeys.indexOf(key);
|
|
1395
|
+
if (idx >= 0) deviceKeys.splice(idx, 1);
|
|
1396
|
+
if (deviceKeys.length === 0) this.perDeviceKeys.delete(entry.deviceId);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1345
1399
|
};
|
|
1346
1400
|
/**
|
|
1347
1401
|
* Nearest-neighbour crop + optional downscale of a packed RGB24 frame to a
|
|
@@ -1931,6 +1985,18 @@ function startSessionDecodePump(deps) {
|
|
|
1931
1985
|
iterator.return().catch(() => {});
|
|
1932
1986
|
};
|
|
1933
1987
|
}
|
|
1988
|
+
//#endregion
|
|
1989
|
+
//#region src/session-decode/native-crop-registry.ts
|
|
1990
|
+
/**
|
|
1991
|
+
* Default max entries retained across all active decode sessions on a node. Read
|
|
1992
|
+
* ONCE from `CAMSTACK_NATIVE_CROP_REGISTRY_CAP`; a non-finite / non-positive
|
|
1993
|
+
* value falls back to 256 (was a fixed 64 — too small for a busy multi-camera
|
|
1994
|
+
* node, see class doc).
|
|
1995
|
+
*/
|
|
1996
|
+
var DEFAULT_NATIVE_CROP_REGISTRY_CAP = (() => {
|
|
1997
|
+
const raw = Number(process.env["CAMSTACK_NATIVE_CROP_REGISTRY_CAP"]);
|
|
1998
|
+
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 256;
|
|
1999
|
+
})();
|
|
1934
2000
|
/** Invoke a requester's best-effort `release()`, swallowing any transport error. */
|
|
1935
2001
|
function safeRelease(request) {
|
|
1936
2002
|
try {
|
|
@@ -1940,7 +2006,7 @@ function safeRelease(request) {
|
|
|
1940
2006
|
var NativeCropRegistry = class {
|
|
1941
2007
|
capacity;
|
|
1942
2008
|
entries = /* @__PURE__ */ new Map();
|
|
1943
|
-
constructor(capacity =
|
|
2009
|
+
constructor(capacity = DEFAULT_NATIVE_CROP_REGISTRY_CAP) {
|
|
1944
2010
|
this.capacity = capacity;
|
|
1945
2011
|
}
|
|
1946
2012
|
/** Number of registered handles (tests / metrics). */
|
|
@@ -3106,7 +3172,7 @@ var PipelineRunnerAddon = class extends require_dist.BaseAddon {
|
|
|
3106
3172
|
*/
|
|
3107
3173
|
async getNativeCrop(input) {
|
|
3108
3174
|
const b = input.bbox;
|
|
3109
|
-
if (!(b.x <= .001 && b.y <= .001 && b.w >= .999 && b.h >= .999)) {
|
|
3175
|
+
if (!(b.x <= .001 && b.y <= .001 && b.w >= .999 && b.h >= .999 && input.maxWidth === void 0)) {
|
|
3110
3176
|
const requester = this.nativeCropRegistry.get(input.handle);
|
|
3111
3177
|
if (requester) {
|
|
3112
3178
|
const result = await requester(input.bbox, input.maxWidth);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { B as errMsg, G as createEvent, V as BaseAddon, dt as EventCategory, et as _enum, it as lazy, j as pipelineRunnerCapability, k as nodePin, lt as string, nt as boolean, ot as number, st as object, tt as array, x as defineCustomActions, y as customAction } from "../dist-
|
|
1
|
+
import { B as errMsg, G as createEvent, V as BaseAddon, dt as EventCategory, et as _enum, it as lazy, j as pipelineRunnerCapability, k as nodePin, lt as string, nt as boolean, ot as number, st as object, tt as array, x as defineCustomActions, y as customAction } from "../dist-DkGHtAaK.mjs";
|
|
2
2
|
import { n as profileForStreamId, t as isRemoteRestream } from "../remote-restream-BeHi78PZ.mjs";
|
|
3
3
|
import { r as resolveHubHostname } from "../sheet-geometry-DcpuGTCm.mjs";
|
|
4
4
|
import { t as isWorkerReply } from "../worker-protocol-CyVJTZEO.mjs";
|
|
5
|
-
import { a as getStepDefinition } from "../step-definitions-
|
|
5
|
+
import { a as getStepDefinition } from "../step-definitions-Delhq28w.mjs";
|
|
6
6
|
import { fork } from "node:child_process";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import sharp from "sharp";
|
|
@@ -1242,23 +1242,39 @@ function startGuardedSessionDecode(deps) {
|
|
|
1242
1242
|
/** {@link RETAINED_FRAME_BUDGET_MB} in bytes. */
|
|
1243
1243
|
var RETAINED_FRAME_BUDGET_BYTES = (() => {
|
|
1244
1244
|
const raw = Number(process.env["CAMSTACK_SESSION_RETAIN_MB"]);
|
|
1245
|
-
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) :
|
|
1245
|
+
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 96;
|
|
1246
1246
|
})() * 1024 * 1024;
|
|
1247
|
+
/**
|
|
1248
|
+
* How many of each device's MOST RECENT frames are protected from a busy
|
|
1249
|
+
* neighbour's budget eviction. Sized to cover the late two-plane / cross-process
|
|
1250
|
+
* enrichment horizon (~150-500 ms): 6 frames ≈ 0.6 s @10 fps of guaranteed
|
|
1251
|
+
* survival for every active camera. Read ONCE from
|
|
1252
|
+
* `CAMSTACK_SESSION_RETAIN_FLOOR`; `0` disables the floor (pure global FIFO — the
|
|
1253
|
+
* pre-2026-07-19 behaviour). The hard byte ceiling always overrides the floor,
|
|
1254
|
+
* so this can never push retention past {@link RETAINED_FRAME_BUDGET_BYTES}.
|
|
1255
|
+
*/
|
|
1256
|
+
var RETAINED_FRAME_PER_DEVICE_FLOOR = (() => {
|
|
1257
|
+
const raw = Number(process.env["CAMSTACK_SESSION_RETAIN_FLOOR"]);
|
|
1258
|
+
return Number.isFinite(raw) && raw >= 0 ? Math.floor(raw) : 6;
|
|
1259
|
+
})();
|
|
1247
1260
|
/** Opaque RAM-key prefix stamped into a retained frame's `FrameHandle.shmId`. */
|
|
1248
1261
|
var RETAINED_FRAME_KEY_PREFIX = "ram:";
|
|
1249
1262
|
/** A retention frame is uniquely identified by its key + slot + committed seq. */
|
|
1250
1263
|
function keyOf(handle) {
|
|
1251
1264
|
return `${handle.shmId}#${handle.slot}#${handle.seq}`;
|
|
1252
1265
|
}
|
|
1253
|
-
/**
|
|
1254
|
-
* Node-level RAM store of retained rgb detection frames, keyed by
|
|
1255
|
-
* `FrameHandle` identity. Latest-wins with a byte budget.
|
|
1256
|
-
*/
|
|
1257
1266
|
var RetainedFrameStore = class RetainedFrameStore {
|
|
1258
1267
|
nodeId;
|
|
1259
1268
|
budgetBytes;
|
|
1260
|
-
|
|
1269
|
+
perDeviceFloor;
|
|
1270
|
+
/** Insertion-ordered (Map) → globally oldest is `keys().next()`. */
|
|
1261
1271
|
entries = /* @__PURE__ */ new Map();
|
|
1272
|
+
/**
|
|
1273
|
+
* Per-device insertion-ordered keys (oldest→newest). Mirrors {@link entries}
|
|
1274
|
+
* so the floor can be enforced in O(1) per eviction candidate without scanning
|
|
1275
|
+
* the global map for a device's frame count.
|
|
1276
|
+
*/
|
|
1277
|
+
perDeviceKeys = /* @__PURE__ */ new Map();
|
|
1262
1278
|
bytes = 0;
|
|
1263
1279
|
seq = 0;
|
|
1264
1280
|
/** Ring width used only to spread the `slot` field; the map key is authoritative. */
|
|
@@ -1266,6 +1282,7 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1266
1282
|
constructor(options) {
|
|
1267
1283
|
this.nodeId = options.nodeId;
|
|
1268
1284
|
this.budgetBytes = options.budgetBytes ?? RETAINED_FRAME_BUDGET_BYTES;
|
|
1285
|
+
this.perDeviceFloor = options.perDeviceFloor ?? RETAINED_FRAME_PER_DEVICE_FLOOR;
|
|
1269
1286
|
}
|
|
1270
1287
|
/** Number of retained frames (tests / metrics). */
|
|
1271
1288
|
get size() {
|
|
@@ -1298,14 +1315,21 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1298
1315
|
nodeId: this.nodeId,
|
|
1299
1316
|
slotCount: RetainedFrameStore.SLOT_SPREAD
|
|
1300
1317
|
};
|
|
1301
|
-
|
|
1318
|
+
const key = keyOf(handle);
|
|
1319
|
+
this.entries.set(key, {
|
|
1320
|
+
frame,
|
|
1321
|
+
deviceId
|
|
1322
|
+
});
|
|
1323
|
+
const deviceKeys = this.perDeviceKeys.get(deviceId);
|
|
1324
|
+
if (deviceKeys) deviceKeys.push(key);
|
|
1325
|
+
else this.perDeviceKeys.set(deviceId, [key]);
|
|
1302
1326
|
this.bytes += byteLength;
|
|
1303
1327
|
this.evictToBudget();
|
|
1304
1328
|
return handle;
|
|
1305
1329
|
}
|
|
1306
1330
|
/** The retained frame for `handle`, or `null` if never retained / already evicted. */
|
|
1307
1331
|
getFrame(handle) {
|
|
1308
|
-
return this.entries.get(keyOf(handle)) ?? null;
|
|
1332
|
+
return this.entries.get(keyOf(handle))?.frame ?? null;
|
|
1309
1333
|
}
|
|
1310
1334
|
/**
|
|
1311
1335
|
* Crop (and optionally downscale) the retained rgb frame for `handle` to the
|
|
@@ -1316,26 +1340,56 @@ var RetainedFrameStore = class RetainedFrameStore {
|
|
|
1316
1340
|
* decode worker's surface (`getNativeCrop`), not here.
|
|
1317
1341
|
*/
|
|
1318
1342
|
crop(handle, bbox, maxWidth) {
|
|
1319
|
-
const
|
|
1320
|
-
if (!
|
|
1321
|
-
return cropRgb(frame, bbox, maxWidth);
|
|
1343
|
+
const entry = this.entries.get(keyOf(handle));
|
|
1344
|
+
if (!entry || entry.frame.format !== "rgb") return null;
|
|
1345
|
+
return cropRgb(entry.frame, bbox, maxWidth);
|
|
1322
1346
|
}
|
|
1323
1347
|
/** Drop every retained frame (node/addon shutdown). */
|
|
1324
1348
|
clear() {
|
|
1325
1349
|
this.entries.clear();
|
|
1350
|
+
this.perDeviceKeys.clear();
|
|
1326
1351
|
this.bytes = 0;
|
|
1327
1352
|
}
|
|
1328
|
-
/**
|
|
1353
|
+
/**
|
|
1354
|
+
* Evict frames until the retained bytes fit the budget (keep ≥1).
|
|
1355
|
+
*
|
|
1356
|
+
* Pass 1 (fairness): walk globally oldest→newest and drop only frames whose
|
|
1357
|
+
* device still holds MORE than {@link perDeviceFloor} frames — so a busy
|
|
1358
|
+
* camera's excess is reclaimed before any camera's protected recent window.
|
|
1359
|
+
* Pass 2 (OOM guard): if still over budget (every remaining frame is
|
|
1360
|
+
* floor-protected yet the ceiling is exhausted), drop globally oldest-first
|
|
1361
|
+
* regardless of the floor. The ceiling ALWAYS wins over fairness.
|
|
1362
|
+
*/
|
|
1329
1363
|
evictToBudget() {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
this.entries.
|
|
1335
|
-
if (
|
|
1364
|
+
if (this.bytes <= this.budgetBytes) return;
|
|
1365
|
+
const oldestFirst = [...this.entries.keys()];
|
|
1366
|
+
for (const key of oldestFirst) {
|
|
1367
|
+
if (this.bytes <= this.budgetBytes || this.entries.size <= 1) break;
|
|
1368
|
+
const entry = this.entries.get(key);
|
|
1369
|
+
if (!entry) continue;
|
|
1370
|
+
const deviceKeys = this.perDeviceKeys.get(entry.deviceId);
|
|
1371
|
+
if (deviceKeys && deviceKeys.length > this.perDeviceFloor) this.dropKey(key);
|
|
1372
|
+
}
|
|
1373
|
+
if (this.bytes <= this.budgetBytes) return;
|
|
1374
|
+
for (const key of oldestFirst) {
|
|
1375
|
+
if (this.bytes <= this.budgetBytes || this.entries.size <= 1) break;
|
|
1376
|
+
this.dropKey(key);
|
|
1336
1377
|
}
|
|
1337
1378
|
if (this.bytes < 0) this.bytes = 0;
|
|
1338
1379
|
}
|
|
1380
|
+
/** Remove one frame by key, keeping the byte tally + per-device index exact. */
|
|
1381
|
+
dropKey(key) {
|
|
1382
|
+
const entry = this.entries.get(key);
|
|
1383
|
+
if (!entry) return;
|
|
1384
|
+
this.entries.delete(key);
|
|
1385
|
+
this.bytes -= entry.frame.data.byteLength;
|
|
1386
|
+
const deviceKeys = this.perDeviceKeys.get(entry.deviceId);
|
|
1387
|
+
if (deviceKeys) {
|
|
1388
|
+
const idx = deviceKeys.indexOf(key);
|
|
1389
|
+
if (idx >= 0) deviceKeys.splice(idx, 1);
|
|
1390
|
+
if (deviceKeys.length === 0) this.perDeviceKeys.delete(entry.deviceId);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1339
1393
|
};
|
|
1340
1394
|
/**
|
|
1341
1395
|
* Nearest-neighbour crop + optional downscale of a packed RGB24 frame to a
|
|
@@ -1925,6 +1979,18 @@ function startSessionDecodePump(deps) {
|
|
|
1925
1979
|
iterator.return().catch(() => {});
|
|
1926
1980
|
};
|
|
1927
1981
|
}
|
|
1982
|
+
//#endregion
|
|
1983
|
+
//#region src/session-decode/native-crop-registry.ts
|
|
1984
|
+
/**
|
|
1985
|
+
* Default max entries retained across all active decode sessions on a node. Read
|
|
1986
|
+
* ONCE from `CAMSTACK_NATIVE_CROP_REGISTRY_CAP`; a non-finite / non-positive
|
|
1987
|
+
* value falls back to 256 (was a fixed 64 — too small for a busy multi-camera
|
|
1988
|
+
* node, see class doc).
|
|
1989
|
+
*/
|
|
1990
|
+
var DEFAULT_NATIVE_CROP_REGISTRY_CAP = (() => {
|
|
1991
|
+
const raw = Number(process.env["CAMSTACK_NATIVE_CROP_REGISTRY_CAP"]);
|
|
1992
|
+
return Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 256;
|
|
1993
|
+
})();
|
|
1928
1994
|
/** Invoke a requester's best-effort `release()`, swallowing any transport error. */
|
|
1929
1995
|
function safeRelease(request) {
|
|
1930
1996
|
try {
|
|
@@ -1934,7 +2000,7 @@ function safeRelease(request) {
|
|
|
1934
2000
|
var NativeCropRegistry = class {
|
|
1935
2001
|
capacity;
|
|
1936
2002
|
entries = /* @__PURE__ */ new Map();
|
|
1937
|
-
constructor(capacity =
|
|
2003
|
+
constructor(capacity = DEFAULT_NATIVE_CROP_REGISTRY_CAP) {
|
|
1938
2004
|
this.capacity = capacity;
|
|
1939
2005
|
}
|
|
1940
2006
|
/** Number of registered handles (tests / metrics). */
|
|
@@ -3100,7 +3166,7 @@ var PipelineRunnerAddon = class extends BaseAddon {
|
|
|
3100
3166
|
*/
|
|
3101
3167
|
async getNativeCrop(input) {
|
|
3102
3168
|
const b = input.bbox;
|
|
3103
|
-
if (!(b.x <= .001 && b.y <= .001 && b.w >= .999 && b.h >= .999)) {
|
|
3169
|
+
if (!(b.x <= .001 && b.y <= .001 && b.w >= .999 && b.h >= .999 && input.maxWidth === void 0)) {
|
|
3104
3170
|
const requester = this.nativeCropRegistry.get(input.handle);
|
|
3105
3171
|
if (requester) {
|
|
3106
3172
|
const result = await requester(input.bbox, input.maxWidth);
|