From 28dfd3255d62a3cbacbf8c24651962c979d98705 Mon Sep 17 00:00:00 2001 From: Momentry Studio Date: Thu, 1 Oct 2026 11:22:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20PeopleView=20=E4=BB=8E=20cluster=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8F=90=E5=8F=96=20trace=5Fids=20=E5=92=8C?= =?UTF-8?q?=20representative=5Ftrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 构建 faceIdToTraceId 映射 - 从 representative_face.face_id 找到 trace_id - 为每个 cluster 设置 trace_ids 字段 - 设置 representative_trace 字段 - 修复 group 缩略图无法显示的问题 --- src/views/PeopleView.vue | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/views/PeopleView.vue b/src/views/PeopleView.vue index 92a1067..a5e4e0f 100644 --- a/src/views/PeopleView.vue +++ b/src/views/PeopleView.vue @@ -2056,6 +2056,8 @@ async function loadClusterResults() { } // Build cluster_id → faces[] mapping from frames const clusterFacesMap: Record = {} + const clusterTraceIdsMap: Record> = {} + const faceIdToTraceId: Record = {} for (const f of frames) { for (const face of (f.faces || [])) { const cid = face.cluster_id @@ -2066,15 +2068,35 @@ async function loadClusterResults() { frame: f.frame, timestamp: f.timestamp, confidence: face.confidence, - cluster_id: cid + cluster_id: cid, + trace_id: face.trace_id }) + if (face.trace_id !== undefined && face.trace_id !== null) { + if (!clusterTraceIdsMap[cid]) clusterTraceIdsMap[cid] = new Set() + clusterTraceIdsMap[cid].add(face.trace_id) + if (face.face_id) { + faceIdToTraceId[face.face_id] = face.trace_id + } + } } } - // Assign faces to each cluster + // Assign faces and trace_ids to each cluster for (const c of groups) { const cid = c.cluster_id || c.group_id c.member_faces = clusterFacesMap[cid] || [] c.face_count = c.member_faces.length + c.trace_ids = Array.from(clusterTraceIdsMap[cid] || []) + // Set representative_trace from representative_face + if (c.representative_face?.face_id) { + const repTraceId = faceIdToTraceId[c.representative_face.face_id] + if (repTraceId !== undefined) { + c.representative_trace = repTraceId + } + } + // Fallback to first trace_id + if (c.representative_trace === undefined && c.trace_ids.length > 0) { + c.representative_trace = c.trace_ids[0] + } } if (groups.length) { setClusterResults(fileUuid, groups)