Skip to content

feat: Add ByteTrack tracker with IoU matching and Kalman motion#6950

Open
omkar-334 wants to merge 10 commits into
open-edge-platform:feature/getitrackfrom
omkar-334:getitrack-bytetrack
Open

feat: Add ByteTrack tracker with IoU matching and Kalman motion#6950
omkar-334 wants to merge 10 commits into
open-edge-platform:feature/getitrackfrom
omkar-334:getitrack-bytetrack

Conversation

@omkar-334

@omkar-334 omkar-334 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This pr adds the ByteTrack tracking algorithm and the matching and motion primitives it builds on.

Changes

  • matching/: IoU distance, score fusion, and threshold-gated Hungarian assignment (scipy.optimize.linear_sum_assignment).
  • motion/: a constant-velocity Kalman filter in xyah state, with xyxy conversions.
  • algorithms/bytetrack.py: ByteTrackTracker (two-stage high/low-score association, lost-track recovery, class-aware duplicate suppression) and ByteTrackConfig, registered under bytetrack.
  • Config loading dispatches on the algorithm name, so TrackerConfig.from_yaml and BaseTracker.from_config resolve to ByteTrackConfig and construct ByteTrackTracker.
  • scipy added to dependencies;

Behavior

  • Two-stage association matches confirmed tracks against high-score detections, then unmatched active tracks against low-score detections.
  • Output contains ACTIVE tracks only; lost tracks coast internally until they recover or age out.
  • Thresholds follow the reference: high/low split at high_score_threshold, new tracks require a score 0.1 above it.

Checklist

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

@github-actions github-actions Bot added DEPENDENCY Any changes in any dependencies (new dep or its version) should be produced via Change Request on PM TEST Any changes in tests BUILD labels Jul 1, 2026
@kprokofi kprokofi requested review from kprokofi and removed request for Radwan-Ibrahim and samet-akcay July 1, 2026 07:46
@kprokofi kprokofi self-assigned this Jul 1, 2026
@kprokofi kprokofi added the GSoC label Jul 1, 2026
@kprokofi kprokofi requested a review from Copilot July 1, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the ByteTrack multi-object tracking algorithm into libraries/getitrack, adding the matching (IoU + Hungarian assignment) and motion (constant-velocity Kalman filter in xyah) primitives it depends on, along with configuration defaults and unit tests.

Changes:

  • Added ByteTrack tracker implementation + config variant and algorithm registration (bytetrack).
  • Added matching utilities (IoU matrix / score fusion / threshold-gated Hungarian assignment) and a Kalman motion model with xyxyxyah conversions.
  • Added SciPy as a dependency (for linear_sum_assignment and scipy.linalg) and introduced test coverage for matching, Kalman, config defaults, and ByteTrack behavior.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
libraries/getitrack/uv.lock Locks SciPy (marker-split by Python version) and updates resolution markers.
libraries/getitrack/pyproject.toml Adds scipy>=1.13 runtime dependency.
libraries/getitrack/configs/default.yaml Updates defaults for ByteTrack split threshold and motion velocity decay.
libraries/getitrack/src/getitrack/init.py Ensures bundled algorithms are imported/registered on package import; keeps default logging disabled.
libraries/getitrack/src/getitrack/algorithms/init.py Exposes bundled algorithms package and imports ByteTrack to register it.
libraries/getitrack/src/getitrack/algorithms/bytetrack.py Implements ByteTrackTracker + ByteTrackConfig, including association, lifecycle handling, and duplicate suppression.
libraries/getitrack/src/getitrack/matching/init.py Exports matching helpers (IoU + assignment).
libraries/getitrack/src/getitrack/matching/iou.py Implements IoU computation, score fusion, and threshold-gated Hungarian assignment.
libraries/getitrack/src/getitrack/motion/init.py Exports Kalman filter + bbox conversion helpers.
libraries/getitrack/src/getitrack/motion/kalman.py Implements constant-velocity Kalman filter and xyxyxyah conversions.
libraries/getitrack/src/getitrack/config.py Updates MotionConfig.velocity_decay default to 1.0 (no damping) and adjusts docstring.
libraries/getitrack/tests/unit/test_matching.py Adds unit tests for IoU, score fusion, and gated assignment behavior.
libraries/getitrack/tests/unit/test_kalman.py Adds unit tests for Kalman filter behavior and bbox conversions.
libraries/getitrack/tests/unit/test_config.py Updates unit test expectation for motion default velocity decay.
libraries/getitrack/tests/unit/test_bytetrack.py Adds ByteTrack behavior tests (registry dispatch, lifecycle, low-score recovery, duplicate suppression, det_indices).

Comment thread libraries/getitrack/src/getitrack/matching/iou.py
Comment on lines +115 to +118
motion_cov = self._predict_noise_cov(mean[3])
new_mean = self._motion_mat @ mean
new_covariance = self._motion_mat @ covariance @ self._motion_mat.T + motion_cov
return new_mean, new_covariance
"""
if means.shape[0] == 0:
return means, covariances
motion_covs = np.stack([self._predict_noise_cov(h) for h in means[:, 3]], axis=0)
Comment thread libraries/getitrack/src/getitrack/algorithms/bytetrack.py Outdated
Comment thread libraries/getitrack/src/getitrack/algorithms/bytetrack.py Outdated
Comment thread libraries/getitrack/src/getitrack/algorithms/bytetrack.py Outdated
"""Per-frame velocity damping in ``(0, 1]``. Values below 1.0 simulate gradual deceleration."""
velocity_decay: Annotated[float, Field(gt=0.0, le=1.0)] = 1.0
"""Per-frame velocity damping in ``(0, 1]``. The default 1.0 matches the
reference (no damping); values below 1.0 simulate gradual deceleration."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reference?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference is the bytetrack code - https://github.com/FoundationVision/ByteTrack
image

Comment thread libraries/getitrack/src/getitrack/motion/kalman.py Outdated
Comment thread libraries/getitrack/src/getitrack/motion/kalman.py Outdated
Comment thread libraries/getitrack/pyproject.toml Outdated
Comment thread libraries/getitrack/src/getitrack/algorithms/bytetrack.py Outdated
self._first_frame_id = None
self._frame_det_index.clear()

def _update_impl(self, detections: Detections) -> TrackedDetections:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to keep all methods and variables private except for "reset"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at BaseTracker - three methods are public - reset, update and from_config, so this same convention is followed in downstream trackers. Only these 3 are prublic and rest are private since they are not user-facing

Comment thread libraries/getitrack/src/getitrack/matching/iou.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the the Kalman filter, have you considered off-the-shelf implementations like pykalman or similar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider pykalman specifically, but i still had to write code for batch-prediction, conversions and other things. it also seems to have reduced maintenance over the last year. so i went with writing our own kalman implementation, since other algorithms can also reuse this

@omkar-334 omkar-334 requested a review from a team as a code owner July 5, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BUILD DEPENDENCY Any changes in any dependencies (new dep or its version) should be produced via Change Request on PM GSoC TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants