sidewalk_tracks.py
Tested 2026-11-30 · Python 3.15.2 · standard library only
# Summarise one sidewalk clip's tracks: who is in it, and the longest-tracked people and objects.
# usage: python sidewalk_tracks.py roaddata-sidewalk-sample/clips/SW2878_tracks.json
import json, sys
from collections import Counter
t = json.load(open(sys.argv[1]))
first, last, cls = {}, {}, {}
for frame in t["frames"]:
for track_id, class_index, *_box in frame["boxes"]: # box: x0, y0, x1, y1, confidence (normalised 0-1)
first.setdefault(track_id, frame["t"]); last[track_id] = frame["t"]; cls[track_id] = t["classes"][class_index]
print(t["clip"], f'| tracks {t["fps"]:.0f} times a second |', ", ".join(f"{k}: {n}" for k, n in Counter(cls.values()).most_common()))
for k in sorted(cls, key=lambda k: last[k] - first[k], reverse=True)[:3]:
print(f" track {k} ({cls[k]}) in view {first[k]:.1f} to {last[k]:.1f} s")python sidewalk_tracks.py roaddata-sidewalk-sample/clips/SW2878_tracks.json
What it printed when we ran it
SW2878 | tracks 15 times a second | person: 13, stroller: 3, wheelchair: 3
track 3 (person) in view 0.0 to 5.9 s
track 7 (person) in view 0.0 to 5.9 s
track 8 (stroller) in view 0.0 to 5.9 s