Feature proposal: independent tracker state for interleaved camera frames
Search before asking
I searched current issues and PRs for source-keyed and independent tracker state. Related discussions describe the need, but I did not find an open feature proposal for interleaved, queue-driven frames from multiple cameras. Relevant prior reports are #6563, #19853, and #22483.
Description
Could model.track optionally keep separate tracker state for each explicitly named input source when one model processes frames from several cameras in sequence?
Today, non-stream predictions use one tracker slot. With persist=True, calls in the order A1, B1, A2, B2 advance that one tracker through all four frames. I confirmed the shared frame counter on current main: it advances 1, 2, 3 across three serial array calls. That is correct for frames from one sequence, but it mixes state when a caller knows they came from different cameras. The existing .streams route gives each simultaneous stream its own tracker; separate model instances are the current recommendation for a queue of camera-specific files.
An opt-in source key, illustrated below, could select a stable tracker for each camera while leaving calls without a key unchanged:
model = YOLO("yolo26n.pt")
model.track(frame_a1, persist=True, source_id="camera-a") # proposed API
model.track(frame_b1, persist=True, source_id="camera-b")
model.track(frame_a2, persist=True, source_id="camera-a")
model.track(frame_b2, persist=True, source_id="camera-b")A2 should continue A's state, and B2 should continue B's. This is source isolation, not cross-camera re-identification or shared identity across cameras.
Use case
A service receives short recorded segments or individual frames from multiple cameras through one queue, then processes them serially with one loaded detector. In #6563, the requester specifically asked for alternating frames without threads. In #19853, a user described queued segments from ten cameras and was advised to use separate model instances. #22483 explains why changing the default interpretation of batched arrays would break valid sequential tracking, so this should be explicit and opt-in.
Design questions
- Would an optional per-call
source_idfit the tracking API, or is another way of supplying source identity preferable? - Should this first cover only serial calls with one frame per call? Batched arrays and live
.streamscould keep their current semantics. - What should remove or reset a source's tracker, and should the number of retained sources be bounded or caller-managed?
A useful regression would run A1, B1, A2, B2 through one model and compare each source's tracker progression with the same frames processed by two separate model instances. It should also assert that calls without a source key keep their current behavior.
I would be happy to work on a small implementation if the API and lifecycle fit the project's direction. I have not opened a feature PR because the contribution guide asks for prior maintainer discussion and approval.
AI assistance disclosure
AI assistance was used to audit the tracker path and draft this proposal. The linked reports were checked, and a local CPU reproduction confirmed current behavior.
Source: ultralytics/ultralytics