From 941f0678a1a373b33ac116c41c23d00ffdb67767 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Mon, 27 Jul 2026 16:30:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=91=8A=E8=AD=A6=E9=98=88=E5=80=BC?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy/relax-alarms.py | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/deploy/relax-alarms.py diff --git a/scripts/deploy/relax-alarms.py b/scripts/deploy/relax-alarms.py new file mode 100644 index 0000000..db3be63 --- /dev/null +++ b/scripts/deploy/relax-alarms.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +"""调整生产环境告警阈值——降低人脸误报和劳保鞋告警频率。 + 运行后重新下发设备配置即生效。""" +import sqlite3, json + +DB = '/opt/safesightd/data/app.db' +TEMPLATE = 'std_workshop_face_recognition_shoe_alarm' + +c = sqlite3.connect(DB) +body = json.loads(c.execute("SELECT body_json FROM templates WHERE name=?", (TEMPLATE,)).fetchone()[0]) +nodes = body['template']['nodes'] + +for n in nodes: + if n.get('id') != 'alarm_violation': + continue + cfg = n['config'] + cfg['cooldown_ms'] = 60000 + cfg['min_score'] = 0.5 + cfg['min_duration_ms'] = 1500 + cfg['min_hits'] = 3 + cfg['hit_window_ms'] = 3000 + + # 劳保鞋 + for r in cfg.get('rules', []): + if r['name'] == 'non_compliant_workshoe': + r['min_score'] = 0.5 + r['cooldown_ms'] = 60000 + r['min_hits'] = 3 + r['min_duration_ms'] = 1500 + + # 陌生人脸 + for r in cfg.get('face_rules', []): + if r['name'] == 'unknown_face': + r['cooldown_ms'] = 30000 + r['max_known_sim'] = 0.2 + r['min_hits'] = 4 + r['hit_window_ms'] = 3000 + elif r['name'] == 'known_person': + r['cooldown_ms'] = 30000 + r['min_sim'] = 0.75 + r['min_hits'] = 3 + r['hit_window_ms'] = 2000 + +c.execute("UPDATE templates SET body_json=? WHERE name=?", (json.dumps(body, ensure_ascii=False), TEMPLATE)) +c.commit() +c.close() +print('OK — 重新下发设备配置即生效')