fix: offline report shows identity names in trace tooltips

- Load trace_to_identity mapping from SQLite face_detections
- Query identity names from identities table
- Show 'identity: PERSON_xxx' in each trace bar tooltip
- Works in both full view and --identity filtered view
This commit is contained in:
Accusys
2026-05-13 03:14:49 +08:00
parent bbf8e64752
commit 8d4d29ce6e

View File

@@ -75,6 +75,19 @@ density = {r[0]: r[1] for r in c.fetchall()}
c.execute(f"SELECT COUNT(*) FROM face_detections WHERE 1=1{identity_filter}", identity_params)
total_detections = c.fetchone()[0]
# Trace-to-identity mapping (for tooltips)
trace_to_identity = {}
c.execute("SELECT DISTINCT trace_id, identity_id FROM face_detections WHERE trace_id IS NOT NULL AND identity_id IS NOT NULL")
for tid, iid in c.fetchall():
trace_to_identity[tid] = iid
# Get identity names
id_names = {}
if trace_to_identity:
unique_ids = set(trace_to_identity.values())
placeholders = ",".join(["?" for _ in unique_ids])
c.execute(f"SELECT id, name FROM identities WHERE id IN ({placeholders})", list(unique_ids))
id_names = {r[0]: r[1] for r in c.fetchall()}
# Identity info
identity_info = None
if IDENTITY is not None:
@@ -214,7 +227,12 @@ def build_html():
width = max(3, int((t1 - t0) / duration * (w_px - 20)))
top = i * (bar_h + 1) + 5
opacity = 1.0 if cnt > 5 else 0.3
h.append('<span class="bar" style="left:{}px;top:{}px;width:{}px;height:{}px;opacity:{}" title="T{}: {:.0f}s{:.0f}s, {} faces"></span>'.format(left, top, width, bar_h, opacity, tid, t0, t1, cnt))
identity_note = ""
iid = trace_to_identity.get(tid)
if iid and iid in id_names:
identity_note = ", identity: {}".format(id_names[iid])
h.append('<span class="bar" style="left:{}px;top:{}px;width:{}px;height:{}px;opacity:{}" title="T{}: {:.0f}s{:.0f}s, {} faces{}"></span>'.format(
left, top, width, bar_h, opacity, tid, t0, t1, cnt, identity_note))
h.append('</div>')
# 3. Top identities