diff --git a/scripts/render_offline_report.py b/scripts/render_offline_report.py index 07095cf..1ef5481 100644 --- a/scripts/render_offline_report.py +++ b/scripts/render_offline_report.py @@ -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(''.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(''.format( + left, top, width, bar_h, opacity, tid, t0, t1, cnt, identity_note)) h.append('') # 3. Top identities