LineZone counts detections with tracker_id = -1 as one shared track (silent count inflation with roboflow/trackers)

Author: zachsplatCreated Sep 15, 2026Updated Sep 15, 2026
Labelsbughelp wanted

Description

LineZone.trigger() keys its crossing state by tracker_id, and treats every detection with tracker_id = -1 as the same track. roboflow/trackers (e.g. ByteTrackTracker) returns -1 for tracks it has not confirmed yet (minimum_consecutive_frames), so on a busy frame many distinct unconfirmed objects all carry -1. Their independent motion makes that single phantom track cross the line over and over, and counts inflate silently.

I hit this moving a working pipeline off the deprecated sv.ByteTrack onto trackers.ByteTrackTracker: the same footage went from a correct ~7/9 to 97/95.

Minimal reproduction

python
import numpy as np
import supervision as sv

def box(tid, y):
    return sv.Detections(
        xyxy=np.array([[80.0, y, 120.0, y + 40]]),
        confidence=np.array([0.9]),
        class_id=np.array([0]),
        tracker_id=np.array([tid]),
    )

# two different unconfirmed objects, both id -1, on opposite sides of the line
lz = sv.LineZone(start=sv.Point(0, 100), end=sv.Point(200, 100))
for tid, y in [(-1, 20), (-1, 160), (-1, 20), (-1, 160), (-1, 20), (-1, 160)]:
    lz.trigger(box(tid, y))
print(lz.in_count, lz.out_count)   # 2 3

# identical motion with real ids is correctly quiet
lz2 = sv.LineZone(start=sv.Point(0, 100), end=sv.Point(200, 100))
for tid, y in [(1, 20), (2, 160), (1, 20), (2, 160), (1, 20), (2, 160)]:
    lz2.trigger(box(tid, y))
print(lz2.in_count, lz2.out_count)  # 0 0

Expected

Unconfirmed detections (tracker_id of -1, or None) should not take part in crossing counts, and certainly should not be collapsed into one shared track.

Suggested fix

In LineZone.trigger(), skip detections whose tracker_id is None or < 0 before updating state, and/or note in the docs that trigger() expects confirmed tracks. I can open a PR if that is welcome.

Environment

supervision 0.29.1, trackers 2.4.0, numpy 2.3.5, Python 3.12.