@camstack/addon-pipeline 1.2.196 → 1.2.198
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 +2 -2
- package/dist/audio-analyzer/index.mjs +2 -2
- package/dist/{default-detection-model-CJdc8j83.js → default-detection-model-B5v8qEI0.js} +1 -1
- package/dist/{default-detection-model-BGBAmtEp.mjs → default-detection-model-CASpAESz.mjs} +1 -1
- package/dist/detection-pipeline/index.js +5 -5
- package/dist/detection-pipeline/index.mjs +4 -4
- package/dist/{dist-HG5geL9t.js → dist-BxP0SvPz.js} +215 -58
- package/dist/{dist-mYDK58Jp.mjs → dist-oFIHnD88.mjs} +198 -59
- package/dist/{lazy-sharp-DmAwZ0s9.js → lazy-sharp-VKOG3WW4.js} +1 -1
- package/dist/motion-wasm/index.js +2 -2
- package/dist/motion-wasm/index.mjs +1 -1
- package/dist/{node-xRsaPwBa.mjs → node-B4zETsJ9.mjs} +1 -1
- package/dist/{node--my8JTOW.js → node-BIKrNEtS.js} +1 -1
- package/dist/pipeline-runner/index.js +363 -6
- package/dist/pipeline-runner/index.mjs +362 -5
- package/dist/{retire-root-keys-KE6D6Xh_.js → prebuffer-DmBYRQWg.mjs} +83 -12
- package/dist/{retire-root-keys-DMolfhsP.mjs → prebuffer-DqdeLSsk.js} +118 -1
- package/dist/{process-memory-CoCSce63.js → process-memory-CMHOmj75.js} +1 -1
- package/dist/{process-memory-BDHR3lxe.mjs → process-memory-D9xYwm6L.mjs} +1 -1
- package/dist/recorder/index.js +152 -31
- package/dist/recorder/index.mjs +148 -27
- package/dist/{segment-demux-js-CBynn9Gh.js → segment-demux-js-DLwL1vmq.js} +1 -1
- package/dist/{segment-demux-js-CXvgKfsn.mjs → segment-demux-js-DZysrgdC.mjs} +1 -1
- package/dist/session-decode/decode-worker-child.js +2 -2
- package/dist/session-decode/decode-worker-child.mjs +1 -1
- package/dist/stream-broker/_stub.js +29 -32
- package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BMsB2MVD.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-C2eTdxvd.mjs} +3 -3
- package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-B_NVJXAy.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BcjLrxhF.mjs} +1 -1
- package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CBxobiZW.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Dj_qoc1e.mjs} +1 -1
- package/dist/stream-broker/demux-worker-child.js +1 -1
- package/dist/stream-broker/demux-worker-child.mjs +1 -1
- package/dist/stream-broker/{hostInit-CZig_taJ.mjs → hostInit-C8tu7NS4.mjs} +3 -3
- package/dist/stream-broker/index.js +452 -541
- package/dist/stream-broker/index.mjs +448 -537
- package/dist/stream-broker/remoteEntry.js +1 -1
- package/dist/{worker-protocol-DCsi4YS1.js → worker-protocol-D2mMjUXv.js} +1 -1
- package/dist/{worker-protocol-C0R1DDC0.mjs → worker-protocol-DFlZm_wr.mjs} +1 -1
- package/package.json +1 -1
|
@@ -2,12 +2,12 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_dist = require("../dist-
|
|
6
|
-
const require_node = require("../node
|
|
7
|
-
const require_default_detection_model = require("../default-detection-model-
|
|
8
|
-
const require_worker_protocol = require("../worker-protocol-
|
|
5
|
+
const require_dist = require("../dist-BxP0SvPz.js");
|
|
6
|
+
const require_node = require("../node-BIKrNEtS.js");
|
|
7
|
+
const require_default_detection_model = require("../default-detection-model-B5v8qEI0.js");
|
|
8
|
+
const require_worker_protocol = require("../worker-protocol-D2mMjUXv.js");
|
|
9
9
|
const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
|
|
10
|
-
const require_lazy_sharp = require("../lazy-sharp-
|
|
10
|
+
const require_lazy_sharp = require("../lazy-sharp-VKOG3WW4.js");
|
|
11
11
|
const require_restream_intent = require("../restream-intent-Cv9x3jmu.js");
|
|
12
12
|
const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-DaUBcb13.js");
|
|
13
13
|
const require_remote_restream = require("../remote-restream-CO36Sr30.js");
|
|
@@ -1977,6 +1977,169 @@ function buildBenchRunPipelineInput(req) {
|
|
|
1977
1977
|
...req.plane ? { plane: req.plane } : {}
|
|
1978
1978
|
};
|
|
1979
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* How long a box stays "seen".
|
|
1982
|
+
*
|
|
1983
|
+
* Sized on the gate's own clock, not on a guess: `maxDeferralMs` defaults to
|
|
1984
|
+
* 2 000 ms, so a birth's whole life as a candidate is 2 s. A window shorter
|
|
1985
|
+
* than that would re-cut the same subject inside one deferral; a much longer
|
|
1986
|
+
* one would stop a subject that genuinely left and returned from being cut
|
|
1987
|
+
* again. 3 000 ms is the deferral budget plus one 1 s margin.
|
|
1988
|
+
*/
|
|
1989
|
+
var BIRTH_EVIDENCE_NOVELTY_WINDOW_MS = 3e3;
|
|
1990
|
+
/**
|
|
1991
|
+
* Padding around the box, as a fraction of its size.
|
|
1992
|
+
*
|
|
1993
|
+
* 0.15 deliberately equals `CONFIRMATION_CROP_PADDING` in post-analysis: the
|
|
1994
|
+
* gate promotes a secondary subject by mapping a crop-space box back into the
|
|
1995
|
+
* frame through the rectangle the crop was cut from, and the two derivations
|
|
1996
|
+
* disagreeing is how a promoted box lands somewhere the pixels never were.
|
|
1997
|
+
*/
|
|
1998
|
+
var BIRTH_EVIDENCE_PADDING = .15;
|
|
1999
|
+
/**
|
|
2000
|
+
* Boxes remembered per camera. A frame with more subjects than this keeps the
|
|
2001
|
+
* most recent — the cap is about bounding a crowd, and a box that fell out is
|
|
2002
|
+
* merely eligible for a cut it will not get twice (the encode budget above is
|
|
2003
|
+
* the real spend). 64 is 16x the tile tier's per-frame subject cap.
|
|
2004
|
+
*/
|
|
2005
|
+
var REMEMBERED_BOXES_PER_DEVICE = 64;
|
|
2006
|
+
/**
|
|
2007
|
+
* Per-camera memory of the boxes recently on screen.
|
|
2008
|
+
*
|
|
2009
|
+
* Per CAMERA and never global: a box on 617 says nothing about 615, and a
|
|
2010
|
+
* shared structure would make one camera's traffic decide another's cuts —
|
|
2011
|
+
* which is the exact shape of the node-wide sharing this whole change moves
|
|
2012
|
+
* away from.
|
|
2013
|
+
*
|
|
2014
|
+
* Judged per CLASS. A dog at its owner's knee is 100% contained in the person's
|
|
2015
|
+
* box; a class-blind test would call it "already seen" and it would reach the
|
|
2016
|
+
* gate with no pixels — the failure D372, D377 and D378 each fought at a
|
|
2017
|
+
* different layer.
|
|
2018
|
+
*/
|
|
2019
|
+
var BirthNoveltyMemory = class {
|
|
2020
|
+
byDevice = /* @__PURE__ */ new Map();
|
|
2021
|
+
/**
|
|
2022
|
+
* Is this box a subject the camera has not been showing?
|
|
2023
|
+
*
|
|
2024
|
+
* Pure: it does not record anything. The caller records the whole frame with
|
|
2025
|
+
* {@link note}, once, so a box that lost the encode budget is still counted
|
|
2026
|
+
* as seen — otherwise the cap turns into a permanent re-cut of the same
|
|
2027
|
+
* subjects.
|
|
2028
|
+
*/
|
|
2029
|
+
isNovel(deviceId, box, macroClass, nowMs) {
|
|
2030
|
+
const boxes = this.byDevice.get(deviceId);
|
|
2031
|
+
if (!boxes) return true;
|
|
2032
|
+
for (const remembered of boxes) {
|
|
2033
|
+
if (nowMs - remembered.atMs > 3e3) continue;
|
|
2034
|
+
if (remembered.macroClass !== macroClass) continue;
|
|
2035
|
+
if (iou(remembered.rect, box) >= .3) return false;
|
|
2036
|
+
}
|
|
2037
|
+
return true;
|
|
2038
|
+
}
|
|
2039
|
+
/** Record a frame's detections and drop everything past the window / the cap. */
|
|
2040
|
+
note(deviceId, detections, nowMs) {
|
|
2041
|
+
const kept = (this.byDevice.get(deviceId) ?? []).filter((b) => nowMs - b.atMs <= BIRTH_EVIDENCE_NOVELTY_WINDOW_MS);
|
|
2042
|
+
for (const d of detections) {
|
|
2043
|
+
if (!isUsable$1(d.bbox)) continue;
|
|
2044
|
+
kept.push({
|
|
2045
|
+
rect: d.bbox,
|
|
2046
|
+
macroClass: d.macroClass,
|
|
2047
|
+
atMs: nowMs
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
this.byDevice.set(deviceId, kept.length > REMEMBERED_BOXES_PER_DEVICE ? kept.slice(kept.length - REMEMBERED_BOXES_PER_DEVICE) : kept);
|
|
2051
|
+
}
|
|
2052
|
+
/** How many boxes this camera currently remembers (tests / diagnostics). */
|
|
2053
|
+
rememberedCount(deviceId) {
|
|
2054
|
+
return this.byDevice.get(deviceId)?.length ?? 0;
|
|
2055
|
+
}
|
|
2056
|
+
/** Forget a camera wholesale (detach, pipeline reset). */
|
|
2057
|
+
clearDevice(deviceId) {
|
|
2058
|
+
this.byDevice.delete(deviceId);
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
/**
|
|
2062
|
+
* The cuts worth taking on this frame, highest confidence first, capped.
|
|
2063
|
+
*
|
|
2064
|
+
* Records EVERY usable detection in `memory` — including the ones the cap
|
|
2065
|
+
* refused — so the budget bounds the spend without turning into a leak.
|
|
2066
|
+
*/
|
|
2067
|
+
function planBirthEvidence(deviceId, detections, frame, memory, nowMs, maxPerFrame = 2) {
|
|
2068
|
+
if (frame.width <= 0 || frame.height <= 0) return [];
|
|
2069
|
+
const usable = detections.map((d, index) => ({
|
|
2070
|
+
d,
|
|
2071
|
+
index
|
|
2072
|
+
})).filter(({ d }) => isUsable$1(d.bbox));
|
|
2073
|
+
const novel = usable.filter(({ d }) => memory.isNovel(deviceId, d.bbox, d.macroClass, nowMs));
|
|
2074
|
+
memory.note(deviceId, usable.map(({ d }) => ({
|
|
2075
|
+
bbox: d.bbox,
|
|
2076
|
+
macroClass: d.macroClass
|
|
2077
|
+
})), nowMs);
|
|
2078
|
+
const plan = [];
|
|
2079
|
+
for (const { d, index } of [...novel].sort((a, b) => b.d.score - a.d.score)) {
|
|
2080
|
+
if (plan.length >= maxPerFrame) break;
|
|
2081
|
+
const rect = padAndClamp(d.bbox, frame);
|
|
2082
|
+
if (rect === null) continue;
|
|
2083
|
+
plan.push({
|
|
2084
|
+
index,
|
|
2085
|
+
rect,
|
|
2086
|
+
target: targetFor(rect)
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
return plan.sort((a, b) => a.index - b.index);
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* The padded, clamped source rectangle — or `null` for a box that is not worth
|
|
2093
|
+
* an encode. A degenerate box is DROPPED rather than clamped: a zero-area crop
|
|
2094
|
+
* serves nothing and a NaN one would poison the encoder's geometry.
|
|
2095
|
+
*/
|
|
2096
|
+
function padAndClamp(box, frame) {
|
|
2097
|
+
if (Math.min(box.width, box.height) < 128) return null;
|
|
2098
|
+
const padX = box.width * BIRTH_EVIDENCE_PADDING;
|
|
2099
|
+
const padY = box.height * BIRTH_EVIDENCE_PADDING;
|
|
2100
|
+
const left = Math.max(0, Math.floor(box.x - padX));
|
|
2101
|
+
const top = Math.max(0, Math.floor(box.y - padY));
|
|
2102
|
+
const right = Math.min(frame.width, Math.ceil(box.x + box.width + padX));
|
|
2103
|
+
const bottom = Math.min(frame.height, Math.ceil(box.y + box.height + padY));
|
|
2104
|
+
const width = right - left;
|
|
2105
|
+
const height = bottom - top;
|
|
2106
|
+
if (width <= 0 || height <= 0) return null;
|
|
2107
|
+
return {
|
|
2108
|
+
x: left,
|
|
2109
|
+
y: top,
|
|
2110
|
+
width,
|
|
2111
|
+
height
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
/** Encoded size: capped, aspect-preserving, never upscaled. */
|
|
2115
|
+
function targetFor(rect) {
|
|
2116
|
+
if (rect.width <= 320) return {
|
|
2117
|
+
width: rect.width,
|
|
2118
|
+
height: rect.height
|
|
2119
|
+
};
|
|
2120
|
+
const scale = 320 / rect.width;
|
|
2121
|
+
return {
|
|
2122
|
+
width: 320,
|
|
2123
|
+
height: Math.max(1, Math.round(rect.height * scale))
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
/** A box with finite, positive extent. */
|
|
2127
|
+
function isUsable$1(box) {
|
|
2128
|
+
return Number.isFinite(box.x) && Number.isFinite(box.y) && Number.isFinite(box.width) && Number.isFinite(box.height) && box.width > 0 && box.height > 0;
|
|
2129
|
+
}
|
|
2130
|
+
/** Intersection over union of two absolute-pixel rectangles. */
|
|
2131
|
+
function iou(a, b) {
|
|
2132
|
+
const left = Math.max(a.x, b.x);
|
|
2133
|
+
const top = Math.max(a.y, b.y);
|
|
2134
|
+
const right = Math.min(a.x + a.width, b.x + b.width);
|
|
2135
|
+
const bottom = Math.min(a.y + a.height, b.y + b.height);
|
|
2136
|
+
const w = right - left;
|
|
2137
|
+
const h = bottom - top;
|
|
2138
|
+
if (w <= 0 || h <= 0) return 0;
|
|
2139
|
+
const intersection = w * h;
|
|
2140
|
+
const union = a.width * a.height + b.width * b.height - intersection;
|
|
2141
|
+
return union <= 0 ? 0 : intersection / union;
|
|
2142
|
+
}
|
|
1980
2143
|
//#endregion
|
|
1981
2144
|
//#region src/pipeline-runner/capacity/capacity-runner.ts
|
|
1982
2145
|
/**
|
|
@@ -5539,6 +5702,15 @@ var PACKAGE_ZONE_UNION_TTL_MS = 6e4;
|
|
|
5539
5702
|
var MAX_BOUND_FRAME_CUTTERS = 256;
|
|
5540
5703
|
/** How often a camera reports its undispatched cuts. */
|
|
5541
5704
|
var TILE_CUT_DROP_LOG_INTERVAL_MS = 6e4;
|
|
5705
|
+
/**
|
|
5706
|
+
* How often a camera reports what carrying its birth evidence COST (D379).
|
|
5707
|
+
*
|
|
5708
|
+
* The cost of this change is the one thing that must be measured rather than
|
|
5709
|
+
* estimated, so the report is per camera, states encodes / bytes / encode-ms
|
|
5710
|
+
* over the window, and drains its counters — a camera that cut nothing says
|
|
5711
|
+
* nothing until it does.
|
|
5712
|
+
*/
|
|
5713
|
+
var BIRTH_EVIDENCE_REPORT_INTERVAL_MS = 6e5;
|
|
5542
5714
|
var DEFAULT_CONFIG = {
|
|
5543
5715
|
maxQueueDepth: 30,
|
|
5544
5716
|
maxConcurrentInferences: 16,
|
|
@@ -5900,6 +6072,15 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
|
|
|
5900
6072
|
tileCutDrops = /* @__PURE__ */ new Map();
|
|
5901
6073
|
tileCutDropLoggedAt = /* @__PURE__ */ new Map();
|
|
5902
6074
|
/**
|
|
6075
|
+
* Per-camera memory of the boxes recently on screen — what decides whether a
|
|
6076
|
+
* detection is worth cutting its own evidence for (D379). Per CAMERA, never
|
|
6077
|
+
* global: one camera's traffic must never decide another's cuts.
|
|
6078
|
+
*/
|
|
6079
|
+
birthNovelty = new BirthNoveltyMemory();
|
|
6080
|
+
/** Per-camera cost of the carried evidence, drained by its report line. */
|
|
6081
|
+
birthEvidenceCost = /* @__PURE__ */ new Map();
|
|
6082
|
+
birthEvidenceReportedAt = /* @__PURE__ */ new Map();
|
|
6083
|
+
/**
|
|
5903
6084
|
* Node-level RAM store of retained rgb detection frames, keyed by the
|
|
5904
6085
|
* `FrameHandle` that rides the inference-result event (shm-ring removal
|
|
5905
6086
|
* 2026-07-16 — replaces the `csr.` shm retention ring). Backs the
|
|
@@ -6177,7 +6358,8 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
|
|
|
6177
6358
|
this.runner.onResult(async (deviceId, frame, result, _streamType, handle) => {
|
|
6178
6359
|
this.retention?.noteInferenceResult(deviceId, handle, result);
|
|
6179
6360
|
this.cutSubjectTiles(deviceId, result, handle);
|
|
6180
|
-
this.
|
|
6361
|
+
const carried = await this.attachBirthEvidence(deviceId, frame, result);
|
|
6362
|
+
this.emitInferenceResult(deviceId, frame, carried, handle);
|
|
6181
6363
|
const detectionCount = result.detections?.length ?? 0;
|
|
6182
6364
|
this.runner?.noteDetectionResult(deviceId, detectionCount);
|
|
6183
6365
|
if (detectionCount > 0 && this.occupancyBurstInFlight.has(deviceId)) this.occupancyBurstFound.add(deviceId);
|
|
@@ -7165,6 +7347,178 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
|
|
|
7165
7347
|
* stays at debug; a miss the caller is handed as `null` is lost work and is a
|
|
7166
7348
|
* warn, carrying the numbers that decide the fix.
|
|
7167
7349
|
*/
|
|
7350
|
+
/**
|
|
7351
|
+
* Cut each candidate birth's own pixels from the frame that produced it, and
|
|
7352
|
+
* return a result carrying them (D379).
|
|
7353
|
+
*
|
|
7354
|
+
* Returns the SAME result object when there is nothing to cut, which is the
|
|
7355
|
+
* overwhelming majority of frames: a subject already on screen is not a
|
|
7356
|
+
* birth, so it costs a novelty lookup and no encode. A new result object is
|
|
7357
|
+
* built when there is — never a mutation of the one the executor produced.
|
|
7358
|
+
*
|
|
7359
|
+
* Every drop is counted and reported per camera. A branch that silently
|
|
7360
|
+
* dropped the evidence would be indistinguishable from a camera with no
|
|
7361
|
+
* births at all, which is the shape of failure this whole change exists to
|
|
7362
|
+
* remove.
|
|
7363
|
+
*/
|
|
7364
|
+
async attachBirthEvidence(deviceId, frame, result) {
|
|
7365
|
+
const detections = result.detections;
|
|
7366
|
+
if (detections.length === 0) return result;
|
|
7367
|
+
const plan = planBirthEvidence(deviceId, detections.map((d) => ({
|
|
7368
|
+
bbox: d.bbox,
|
|
7369
|
+
score: d.score,
|
|
7370
|
+
macroClass: d.macroClass
|
|
7371
|
+
})), {
|
|
7372
|
+
width: result.width,
|
|
7373
|
+
height: result.height
|
|
7374
|
+
}, this.birthNovelty, Date.now());
|
|
7375
|
+
if (plan.length === 0) return result;
|
|
7376
|
+
const cost = this.birthEvidenceCost.get(deviceId) ?? {
|
|
7377
|
+
cut: 0,
|
|
7378
|
+
failed: 0,
|
|
7379
|
+
skippedNoPixels: 0,
|
|
7380
|
+
bytes: 0,
|
|
7381
|
+
encodeMs: 0
|
|
7382
|
+
};
|
|
7383
|
+
this.birthEvidenceCost.set(deviceId, cost);
|
|
7384
|
+
const byIndex = /* @__PURE__ */ new Map();
|
|
7385
|
+
if (!(frame.frameRef !== void 0 || frame.format === "rgb" && frame.data.byteLength >= result.width * result.height * 3)) {
|
|
7386
|
+
cost.skippedNoPixels += plan.length;
|
|
7387
|
+
this.reportBirthEvidenceCost(deviceId);
|
|
7388
|
+
return result;
|
|
7389
|
+
}
|
|
7390
|
+
for (const entry of plan) {
|
|
7391
|
+
const startedAt = Date.now();
|
|
7392
|
+
const jpeg = await this.encodeEvidenceCrop(frame, result, entry);
|
|
7393
|
+
if (jpeg === null) {
|
|
7394
|
+
cost.failed += 1;
|
|
7395
|
+
continue;
|
|
7396
|
+
}
|
|
7397
|
+
cost.cut += 1;
|
|
7398
|
+
cost.bytes += jpeg.byteLength;
|
|
7399
|
+
cost.encodeMs += Date.now() - startedAt;
|
|
7400
|
+
byIndex.set(entry.index, {
|
|
7401
|
+
jpegBase64: jpeg.toString("base64"),
|
|
7402
|
+
rect: entry.rect,
|
|
7403
|
+
tier: "analysis"
|
|
7404
|
+
});
|
|
7405
|
+
}
|
|
7406
|
+
this.reportBirthEvidenceCost(deviceId);
|
|
7407
|
+
if (byIndex.size === 0) return result;
|
|
7408
|
+
return {
|
|
7409
|
+
...result,
|
|
7410
|
+
detections: detections.map((d, i) => {
|
|
7411
|
+
const evidence = byIndex.get(i);
|
|
7412
|
+
return evidence === void 0 ? d : {
|
|
7413
|
+
...d,
|
|
7414
|
+
birthEvidence: evidence
|
|
7415
|
+
};
|
|
7416
|
+
})
|
|
7417
|
+
};
|
|
7418
|
+
}
|
|
7419
|
+
/**
|
|
7420
|
+
* One evidence crop, or `null` when neither raster can serve it.
|
|
7421
|
+
*
|
|
7422
|
+
* The process-local frame LEASE is tried first. On the co-located path
|
|
7423
|
+
* `DecodedFrame.data` is deliberately empty and the pixels live only behind
|
|
7424
|
+
* `frameRef` — reading `data` there produced `skippedNoPixels` on roughly half
|
|
7425
|
+
* the cluster's cameras in the first minutes after this shipped, which is
|
|
7426
|
+
* exactly the silent gap this whole change exists to close. It is also the
|
|
7427
|
+
* same lease the recovery pass resolves its views from, so it costs no new
|
|
7428
|
+
* mechanism and no new copy of the frame.
|
|
7429
|
+
*
|
|
7430
|
+
* The raw buffer is the fallback for a frame delivered inline. `format` is
|
|
7431
|
+
* checked rather than assumed: a planar frame read as RGB would produce a crop
|
|
7432
|
+
* of noise that re-detects as nothing — a false SUPPRESSION, the one error
|
|
7433
|
+
* this path must never make.
|
|
7434
|
+
*/
|
|
7435
|
+
async encodeEvidenceCrop(frame, result, entry) {
|
|
7436
|
+
const fromLease = frame.frameRef ? await this.encodeEvidenceFromLease(frame.frameRef, entry) : null;
|
|
7437
|
+
if (fromLease !== null) return fromLease;
|
|
7438
|
+
const expectedBytes = result.width * result.height * 3;
|
|
7439
|
+
if (frame.format !== "rgb" || frame.data.byteLength < expectedBytes) return null;
|
|
7440
|
+
try {
|
|
7441
|
+
let pipeline = (await require_lazy_sharp.getSharp())(frame.data, { raw: {
|
|
7442
|
+
width: result.width,
|
|
7443
|
+
height: result.height,
|
|
7444
|
+
channels: 3
|
|
7445
|
+
} }).extract({
|
|
7446
|
+
left: entry.rect.x,
|
|
7447
|
+
top: entry.rect.y,
|
|
7448
|
+
width: entry.rect.width,
|
|
7449
|
+
height: entry.rect.height
|
|
7450
|
+
});
|
|
7451
|
+
if (entry.target.width !== entry.rect.width) pipeline = pipeline.resize(entry.target.width, entry.target.height, { fit: "fill" });
|
|
7452
|
+
return await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
7453
|
+
} catch {
|
|
7454
|
+
return null;
|
|
7455
|
+
}
|
|
7456
|
+
}
|
|
7457
|
+
/** The evidence crop from the process-local lease, JPEG-encoded by the view. */
|
|
7458
|
+
async encodeEvidenceFromLease(ref, entry) {
|
|
7459
|
+
const lease = require_default_detection_model.localFrameRegistry.acquire(ref);
|
|
7460
|
+
if (!lease) return null;
|
|
7461
|
+
let reason = "error";
|
|
7462
|
+
try {
|
|
7463
|
+
const view = await lease.resolve({
|
|
7464
|
+
crop: {
|
|
7465
|
+
left: entry.rect.x,
|
|
7466
|
+
top: entry.rect.y,
|
|
7467
|
+
width: entry.rect.width,
|
|
7468
|
+
height: entry.rect.height
|
|
7469
|
+
},
|
|
7470
|
+
content: {
|
|
7471
|
+
width: entry.target.width,
|
|
7472
|
+
height: entry.target.height
|
|
7473
|
+
},
|
|
7474
|
+
fit: "stretch",
|
|
7475
|
+
format: "jpeg"
|
|
7476
|
+
});
|
|
7477
|
+
if (view.kind !== "view") {
|
|
7478
|
+
reason = "drop";
|
|
7479
|
+
return null;
|
|
7480
|
+
}
|
|
7481
|
+
reason = "success";
|
|
7482
|
+
return Buffer.from(view.data);
|
|
7483
|
+
} catch {
|
|
7484
|
+
return null;
|
|
7485
|
+
} finally {
|
|
7486
|
+
lease.release(reason);
|
|
7487
|
+
}
|
|
7488
|
+
}
|
|
7489
|
+
/**
|
|
7490
|
+
* State, per camera, what carrying the evidence cost over the window — and
|
|
7491
|
+
* drain it. The operator's acceptance condition for D379 is that the runner's
|
|
7492
|
+
* memory and the frame path do not grow beyond a declared budget, and a
|
|
7493
|
+
* budget nobody measures is an estimate.
|
|
7494
|
+
*/
|
|
7495
|
+
reportBirthEvidenceCost(deviceId) {
|
|
7496
|
+
const cost = this.birthEvidenceCost.get(deviceId);
|
|
7497
|
+
if (!cost) return;
|
|
7498
|
+
const now = Date.now();
|
|
7499
|
+
const lastAt = this.birthEvidenceReportedAt.get(deviceId) ?? 0;
|
|
7500
|
+
if (lastAt !== 0 && now - lastAt < BIRTH_EVIDENCE_REPORT_INTERVAL_MS) return;
|
|
7501
|
+
const windowMs = lastAt === 0 ? BIRTH_EVIDENCE_REPORT_INTERVAL_MS : now - lastAt;
|
|
7502
|
+
this.birthEvidenceReportedAt.set(deviceId, now);
|
|
7503
|
+
this.ctx.logger.info("birth evidence carried", {
|
|
7504
|
+
tags: { deviceId },
|
|
7505
|
+
meta: {
|
|
7506
|
+
cut: cost.cut,
|
|
7507
|
+
failed: cost.failed,
|
|
7508
|
+
skippedNoPixels: cost.skippedNoPixels,
|
|
7509
|
+
kb: Math.round(cost.bytes / 1024),
|
|
7510
|
+
encodeMs: cost.encodeMs,
|
|
7511
|
+
meanKb: cost.cut > 0 ? Math.round(cost.bytes / cost.cut / 1024) : 0,
|
|
7512
|
+
meanEncodeMs: cost.cut > 0 ? Math.round(cost.encodeMs / cost.cut) : 0,
|
|
7513
|
+
windowMs
|
|
7514
|
+
}
|
|
7515
|
+
});
|
|
7516
|
+
cost.cut = 0;
|
|
7517
|
+
cost.failed = 0;
|
|
7518
|
+
cost.skippedNoPixels = 0;
|
|
7519
|
+
cost.bytes = 0;
|
|
7520
|
+
cost.encodeMs = 0;
|
|
7521
|
+
}
|
|
7168
7522
|
async resolveNativeCropPixels(input) {
|
|
7169
7523
|
const b = input.bbox;
|
|
7170
7524
|
const isFullFrame = b.x <= .001 && b.y <= .001 && b.w >= .999 && b.h >= .999;
|
|
@@ -7688,6 +8042,9 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
|
|
|
7688
8042
|
this.lastMotionAt.delete(deviceId);
|
|
7689
8043
|
this.lastEmittedCameraMetrics.delete(deviceId);
|
|
7690
8044
|
this.retention?.forgetDevice(deviceId);
|
|
8045
|
+
this.birthNovelty.clearDevice(deviceId);
|
|
8046
|
+
this.birthEvidenceCost.delete(deviceId);
|
|
8047
|
+
this.birthEvidenceReportedAt.delete(deviceId);
|
|
7691
8048
|
this.runner?.unregisterCamera(deviceId);
|
|
7692
8049
|
this.ctx?.logger.info("detachCamera", {
|
|
7693
8050
|
tags: { deviceId },
|