Save calibration payload format and live config

This commit is contained in:
Yoilun
2026-05-07 17:58:32 +08:00
parent 96f5c14a26
commit ea5f9b1b07
2 changed files with 16 additions and 12 deletions

View File

@@ -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) => {