From 0d73c23bd1eeb190b0d7ed158d1d342fcb1b5fd0 Mon Sep 17 00:00:00 2001 From: ericwyuan Date: Fri, 21 Aug 2026 14:47:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(fam-edge):=20=E4=BA=BA=E7=89=A9=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E6=B8=85=E6=B4=97=20-=20=5Fclean=5Fperson=20=E5=8E=BB?= =?UTF-8?q?=E6=8B=AC=E5=8F=B7=E6=B3=A8=E9=87=8A(=E9=98=B2=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E8=BE=93=E5=87=BA'=E4=BA=BA=E7=89=A9A(=E5=88=AB?= =?UTF-8?q?=E5=90=8D/=E6=A0=87=E8=AF=86:=E4=BA=BA=E7=89=A9B)'=E6=B1=A1?= =?UTF-8?q?=E6=9F=93=E4=BA=BA=E7=89=A9=E8=A1=A8)=EF=BC=9Bprompt=20?= =?UTF-8?q?=E6=98=8E=E7=A1=AE=20people=20=E5=8F=AA=E5=A1=AB=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E6=9C=AC=E8=BA=AB=EF=BC=9Bevents.people=20=E4=B8=8E?= =?UTF-8?q?=20people=5Fmentioned=20=E5=9D=87=E6=B8=85=E6=B4=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fam-edge/src/fam_edge/ai_orchestrator/prompts.py | 3 ++- fam-edge/src/fam_edge/video_processor.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fam-edge/src/fam_edge/ai_orchestrator/prompts.py b/fam-edge/src/fam_edge/ai_orchestrator/prompts.py index 72916ce..10e9ffb 100644 --- a/fam-edge/src/fam_edge/ai_orchestrator/prompts.py +++ b/fam-edge/src/fam_edge/ai_orchestrator/prompts.py @@ -72,7 +72,8 @@ def build_video_prompt(known_members: str, event_start_time: str, - 表情/情绪线索(如可辨认:微笑/皱眉/哭泣/平静) - 周围环境与背景物品(电视开着/桌上水杯/地上有玩具等,辅助判断场景) 4. people: 该时刻出现的人物标识。已知成员用真名,未知人物用「人物A」「人物B」 - 本视频内连续编号(同一人保持同一编号)。 + 本视频内连续编号(同一人保持同一编号)。只填标识本身,不要带括号注释 + (如只写"人物A",不要写"人物A(别名/标识:人物B)")。 5. people_mentioned: 必须等于 events 中所有 people 字段出现过的标识去重后的集合。 一致性强制:events 里出现的标识必须都在 people_mentioned 里,反之亦然。 6. is_attention_event: 跌倒、危险动作、异常哭闹、陌生人闯入、身体不适等需关注事件 diff --git a/fam-edge/src/fam_edge/video_processor.py b/fam-edge/src/fam_edge/video_processor.py index 58ad6c2..a62e91a 100644 --- a/fam-edge/src/fam_edge/video_processor.py +++ b/fam-edge/src/fam_edge/video_processor.py @@ -126,6 +126,16 @@ def validate_video(path: str) -> tuple: return False, f"validate_exc: {e}", None +def _clean_person(s: str) -> str: + """清洗人物标识:去掉括号注释(如 "人物A(别名/标识:人物B)" -> "人物A")。""" + s = (s or '').strip() + for sep in ('(', '('): + if sep in s: + s = s.split(sep, 1)[0].strip() + break + return s + + class VideoProcessor: def __init__(self, db: oracle_db.OracleDB): self.config = load_config() @@ -244,11 +254,15 @@ class VideoProcessor: norm_events.append({ "timestamp": abs_ts, "description": str(ev.get('description', '')), - "people": [str(p) for p in ev.get('people', []) if p], + "people": [_clean_person(str(p)) for p in ev.get('people', []) if p], "is_attention_event": bool(ev.get('is_attention_event', False)), }) offsets.append(off) + # 清洗 people_mentioned(去掉括号注释串,防污染人物表/合并) + people = [_clean_person(str(p)) for p in people if p] + people = [p for p in people if p and p not in ('无人', '无')] + event_ids = self.db.mark_video_processed(video_id, summary, norm_events, people, provider) # 缩略图 + 每个事件对应时间点的画面截图(用相对偏移直接定位,避免模型绝对时间误差) if vrow and vrow['local_path']: