170 lines
6.2 KiB
JavaScript
170 lines
6.2 KiB
JavaScript
import assert from "node:assert/strict";
|
||
import { readFile } from "node:fs/promises";
|
||
import test, { after, before } from "node:test";
|
||
import { createServer } from "vite";
|
||
|
||
let server;
|
||
let fetchE46JRawFisheyeRealtime;
|
||
|
||
before(async () => {
|
||
server = await createServer({
|
||
server: { middlewareMode: true },
|
||
appType: "custom",
|
||
logLevel: "silent",
|
||
});
|
||
({ fetchE46JRawFisheyeRealtime } = await server.ssrLoadModule(
|
||
"/src/core/laboratory/e46jRawFisheyeRealtime.ts",
|
||
));
|
||
});
|
||
|
||
after(async () => {
|
||
await server?.close();
|
||
});
|
||
|
||
test("E46J binds full raw fisheye capacity to an honest visual exception", async () => {
|
||
const identity = "b".repeat(64);
|
||
const resultId = `e46j-raw-fisheye-realtime-${"a".repeat(64)}`;
|
||
const payload = {
|
||
schema_version: "missioncore.e46j-raw-fisheye-realtime-catalog/v1",
|
||
items: [{
|
||
schema_version: "missioncore.e46j-raw-fisheye-realtime-view/v1",
|
||
result_id: resultId,
|
||
created_at_utc: "2026-08-04T18:20:00.000Z",
|
||
status: "realtime-capacity-passed-awaiting-temporal-layer",
|
||
source: {
|
||
camera_source_id: "sensor.camera.right",
|
||
session_id: "20260720T065719Z_viewer_live",
|
||
resolution: [800, 600],
|
||
frame_count: 4489,
|
||
frame_rate: 10.003944527024467,
|
||
calibration_model: "KB4",
|
||
},
|
||
detector: {
|
||
architecture: "YOLOX-S",
|
||
source: "Megvii-BaseDetection/YOLOX release 0.1.1rc0",
|
||
license: "Apache-2.0",
|
||
runtime: "NVIDIA Triton 2.70.0 ONNX Runtime GPU backend",
|
||
},
|
||
detection: { minimum_score: 0.5, nms_iou_threshold: 0.45 },
|
||
metrics: {
|
||
frame_count: 4489,
|
||
failed_frame_count: 0,
|
||
detection_observation_count: 15499,
|
||
class_observation_counts: { car: 14229, person: 625, truck: 608 },
|
||
mean_detections_per_frame: 3.452662,
|
||
max_detections_per_frame: 9,
|
||
zero_detection_frame_count: 181,
|
||
longest_zero_detection_run_frames: 24,
|
||
core_capacity_fps: 47.84049,
|
||
core_path_mean_ms: 20.902796,
|
||
core_path_p95_ms: 25.355265,
|
||
inference_request_mean_ms: 12.437504,
|
||
inference_request_p95_ms: 16.414979,
|
||
gpu_utilization_mean_percent: 26.396947,
|
||
operator_shadow_window_frame_count: 75,
|
||
operator_shadow_person_frame_count: 35,
|
||
},
|
||
visual_review: {
|
||
reviewed_video_range_seconds: [0, 448.723],
|
||
verdict: "realtime-detector-progress-with-known-shadow-exception",
|
||
review_windows: [
|
||
["wall", 6, 10.9, "legacy-background-false-positive-suppressed"],
|
||
["shrub", 178.6, 180.3, "legacy-background-false-positive-suppressed"],
|
||
["ground", 250.7, 265.6, "legacy-background-false-positive-suppressed"],
|
||
["road", 392.2, 400.6, "legacy-background-false-positive-suppressed"],
|
||
["shadow", 419.4, 426.9, "operator-shadow-person-false-positive-observed"],
|
||
["terrace", 440.8, 448.4, "legacy-background-false-positive-suppressed"],
|
||
].map(([id, start, end, verdict]) => ({
|
||
id,
|
||
label: `${start}–${end}`,
|
||
start_seconds: start,
|
||
end_seconds: end,
|
||
verdict,
|
||
})),
|
||
finding: "full raw fisheye retained",
|
||
known_error: "operator shadow becomes person",
|
||
},
|
||
acceptance: {
|
||
ten_hz_capacity_gate_passed: true,
|
||
latency_gate_passed: true,
|
||
full_raw_fisheye_retained: true,
|
||
},
|
||
decision: {
|
||
selected_provider: "megvii-yolox-s-0.1.1rc0",
|
||
realtime_capacity_passed: true,
|
||
ready_for_temporal_bakeoff: true,
|
||
provider_promoted: false,
|
||
next_action: "attach ready temporal tracker",
|
||
},
|
||
method: {
|
||
schema_version: "missioncore.laboratory-method/v1",
|
||
completeness: "complete",
|
||
execution_class: "hybrid",
|
||
pipeline_id: "e46j-k1-right-raw-kb4-yolox-s-one-pass/v1",
|
||
components: [{
|
||
kind: "model",
|
||
name: "YOLOX-S",
|
||
version: "0.1.1rc0",
|
||
role: "ready detector",
|
||
identity_sha256: identity,
|
||
}],
|
||
},
|
||
limitations: ["not truth", "no temporal identity"],
|
||
video: {
|
||
url: `/api/v1/laboratory/e46j/results/${resultId}/overlay.mp4`,
|
||
media_type: "video/mp4",
|
||
byte_length: 150563706,
|
||
sha256: identity,
|
||
width: 800,
|
||
height: 600,
|
||
frame_rate: 10.003944527024467,
|
||
frame_count: 4489,
|
||
duration_seconds: 448.723,
|
||
},
|
||
visuals: Object.fromEntries(
|
||
["full_route", "targeted_windows", "operator_shadow"].map((key) => [key, {
|
||
url: `/visual/${key}.png`,
|
||
media_type: "image/png",
|
||
byte_length: 1000,
|
||
sha256: identity,
|
||
}]),
|
||
),
|
||
ground_truth: false,
|
||
authority: {
|
||
ground_truth: false,
|
||
provider_promoted: false,
|
||
commands_enabled: false,
|
||
navigation_or_safety_accepted: false,
|
||
},
|
||
}],
|
||
};
|
||
const result = await fetchE46JRawFisheyeRealtime({
|
||
fetcher: async () => new Response(JSON.stringify(payload), {
|
||
status: 200,
|
||
headers: { "Content-Type": "application/json" },
|
||
}),
|
||
});
|
||
assert.equal(result.source.frameCount, 4489);
|
||
assert.equal(result.source.resolution.join("x"), "800x600");
|
||
assert.equal(result.metrics.coreCapacityFps, 47.84049);
|
||
assert.equal(result.metrics.operatorShadowPersonFrameCount, 35);
|
||
assert.equal(result.visualReview.reviewWindows.length, 6);
|
||
assert.equal(result.decision.providerPromoted, false);
|
||
assert.doesNotMatch(JSON.stringify(result), /Users|D:\\|runtime\/experiments/);
|
||
});
|
||
|
||
test("E46J uses the fixed LAB anatomy and seekable full video", async () => {
|
||
const [resultView, visual] = await Promise.all([
|
||
readFile(new URL("../src/workspaces/laboratory/E46JRawFisheyeRealtimeResult.tsx", import.meta.url), "utf8"),
|
||
readFile(new URL("../src/workspaces/laboratory/E46JRawFisheyeRealtimeVisual.tsx", import.meta.url), "utf8"),
|
||
]);
|
||
assert.match(resultView, /LaboratorySummary/);
|
||
assert.match(resultView, /LaboratoryEvidence/);
|
||
assert.match(resultView, /LaboratoryResultSummary/);
|
||
assert.match(resultView, /full raw fisheye realtime gate/);
|
||
assert.match(visual, /LaboratoryEvidenceViewer/);
|
||
assert.match(visual, /operator-shadow/);
|
||
assert.match(visual, /<video/);
|
||
assert.match(visual, /\[mode, selectedWindow\]/);
|
||
});
|