From ea5f9b1b07febfcfd7deab4a292b6ac649cfd3c7 Mon Sep 17 00:00:00 2001 From: Yoilun Date: Thu, 7 May 2026 17:58:32 +0800 Subject: [PATCH] Save calibration payload format and live config --- config/example.toml | 20 ++++++++++---------- web/src/main.js | 8 ++++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/config/example.toml b/config/example.toml index 4d6769c..b6146d5 100644 --- a/config/example.toml +++ b/config/example.toml @@ -2,7 +2,7 @@ camera_id = "cold_display_cam_01" timezone = "Asia/Shanghai" [stream] -rtsp_url = "" +rtsp_url = "rtsp://admin:Zxjp2026@192.168.8.9:554/h264/ch1/main/av_stream" [thresholds] max_dwell_seconds = 10800 @@ -15,38 +15,38 @@ zone_ids = ["r1c1", "r1c2", "r1c3", "r1c4", "r2c1", "r2c2", "r2c3", "r2c4"] [[zones]] id = "r1c1" -polygon = [[0.00, 0.00], [0.25, 0.00], [0.25, 0.50], [0.00, 0.50]] +polygon = [[0.441053, 0.344678], [0.475789, 0.372749], [0.453684, 0.455088], [0.404211, 0.428889]] [[zones]] id = "r1c2" -polygon = [[0.25, 0.00], [0.50, 0.00], [0.50, 0.50], [0.25, 0.50]] +polygon = [[0.486316, 0.367135], [0.520000, 0.397076], [0.503158, 0.468187], [0.467368, 0.451345]] [[zones]] id = "r1c3" -polygon = [[0.50, 0.00], [0.75, 0.00], [0.75, 0.50], [0.50, 0.50]] +polygon = [[0.545263, 0.400819], [0.587368, 0.417661], [0.554737, 0.500000], [0.509474, 0.483158]] [[zones]] id = "r1c4" -polygon = [[0.75, 0.00], [1.00, 0.00], [1.00, 0.50], [0.75, 0.50]] +polygon = [[0.581255, 0.408928], [0.717971, 0.468544], [0.711092, 0.574018], [0.556320, 0.500645]] [[zones]] id = "r2c1" -polygon = [[0.00, 0.50], [0.25, 0.50], [0.25, 1.00], [0.00, 1.00]] +polygon = [[0.396842, 0.475673], [0.487368, 0.543041], [0.472632, 0.612281], [0.373684, 0.584211]] [[zones]] id = "r2c2" -polygon = [[0.25, 0.50], [0.50, 0.50], [0.50, 1.00], [0.25, 1.00]] +polygon = [[0.502105, 0.528070], [0.535789, 0.546784], [0.516842, 0.660936], [0.477895, 0.632865]] [[zones]] id = "r2c3" -polygon = [[0.50, 0.50], [0.75, 0.50], [0.75, 1.00], [0.50, 1.00]] +polygon = [[0.555789, 0.552398], [0.602105, 0.569240], [0.580000, 0.657193], [0.535789, 0.645965]] [[zones]] id = "r2c4" -polygon = [[0.75, 0.50], [1.00, 0.50], [1.00, 1.00], [0.75, 1.00]] +polygon = [[0.602105, 0.567368], [0.700000, 0.606667], [0.689474, 0.722690], [0.581053, 0.683392]] [trash] -roi = [[0.80, 0.65], [1.00, 0.65], [1.00, 1.00], [0.80, 1.00]] +roi = [[0.776842, 0.486901], [0.896842, 0.522456], [0.841053, 0.857427], [0.716842, 0.853684]] [event_sink] path = "logs/events.jsonl" diff --git a/web/src/main.js b/web/src/main.js index 26cf818..5a964c0 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -350,12 +350,12 @@ async function saveCalibration() { async function persistCalibration({requireAny}) { const zones = zoneIds - .map((id) => ({id, polygon: state.polygons[id]})) + .map((id) => ({id, polygon: serializePolygon(state.polygons[id])})) .filter((zone) => zone.polygon.length >= 3); const trashPolygon = state.polygons.trash; const payload = {zones, trash: {}}; if (trashPolygon.length >= 3) { - payload.trash.roi = trashPolygon; + payload.trash.roi = serializePolygon(trashPolygon); } if (!zones.length && !payload.trash.roi) { if (requireAny) { @@ -370,6 +370,10 @@ async function persistCalibration({requireAny}) { return true; } +function serializePolygon(points) { + return points.map((point) => [point.x, point.y]); +} + function setTab(tab) { state.activeTab = tab; document.querySelectorAll(".tabs button").forEach((button) => {