Guides/Video & streaming/08 Follow moving objects

Follow moving objects

1from lynx import LYNX
2
3model = LYNX("lynx-basic", track=True)
4for results in model.stream("clip.mp4"):
5 for i, track_id in enumerate(results.track_ids):
6 print(f"track={track_id} label={results.labels[i]}")

Bare detection tells you "there's a person at (x, y) in frame N". Tracking turns that into "person #47 has been here for 3 minutes" — you get identity persistence across frames, which is what makes counting, dwell time, behavior recognition, and zone-entry logic possible.

Required for behavior=True (the temporal behavior classifier fires per track_id), on_enter_zone() / on_exit_zone() (boundary logic needs a stable identity to know who just crossed), and any "how many unique X did I see today" counter.

Track IDs are stable across frames as long as the object stays visible. If an object goes behind something and re-emerges, it can come back with a new ID — that's a fundamental tracker limitation, not a LYNX bug. For dense scenes with lots of occlusion, plan around this (e.g., count entries to a zone rather than counting unique IDs over a window).

results.track_history(track_id, n=30) returns the last N frames for a single track — useful for behavior models, debugging "where did this track go", or building a motion vector for predicted-trajectory logic.

Next
Make a model callable over HTTP
Expose LYNX as a web service so any language can call it.