Skip to content

Feat/core/refactor tracklet kalman filter#310

Merged
Borda merged 135 commits into
developfrom
feat/core/refactor-tracklet-kalman-filter
Apr 25, 2026
Merged

Feat/core/refactor tracklet kalman filter#310
Borda merged 135 commits into
developfrom
feat/core/refactor-tracklet-kalman-filter

Conversation

@AlexBodner
Copy link
Copy Markdown
Collaborator

@AlexBodner AlexBodner commented Mar 5, 2026

What does this PR do?

Refactors KalmanBoxTracker to Tracklet classes so decouples Kalman Filter logic from the tracklet, also creating a unique Kalman Filter that will be used by all the algorithms based on the OC-SORT paper implementation of the KF. This also supports swappable kalman filter state coordinates, using the abstraction StateEstimator.

Beware that:

  • OC-SORT and SORT metrics remain the same BUT ByteTrack ones has small changes (at least with default parameters) because it now uses the same kalman filter as OC-SORT (which has slight differences in implementation that make it better in OC-SORT) but here it drops 0.1%. Initialization for bytetrack remains the same as we now support custom initializations per tracker.

  • ByteTrack has a behaviour difference wrt other trackers, to match original it initializes tracklets number_of_successful_consecutive_updates to 1, while in the other ones it is initalized to 0. Also, before this PR our ByteTrack used number_of_updates, instead of counting consecutive updates. Changing this gives different performance (+0.4% HOTA DanceTrack and -0.07% SportMOT reported in test cases and throwing the error). I think this change makes sense for the tracker, so we might have to consider redoing the parameter tuning to have results again with this change or roll this back to keep the same behaviour as the previous version of bytetrack.

Type of Change

  • New feature (non-breaking change that adds functionality BUT modifies behaviour)

SNMOT-118-single-track-xyxy-vs-xcycsr.mp4

closes #359

AlexBodner and others added 30 commits January 29, 2026 13:10
Borda and others added 12 commits April 24, 2026 14:35
…lets

- [resolve #3] Review comment by @Copilot (PR #310):
  "detections.confidence can be None (sv.Detections allows optional confidence).
  _spawn_new_tracklets assumes confidences is an array and indexes into it,
  which will raise if confidence is missing."

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
…ecated trackers alias

- [resolve #4] /review finding by foundry:sw-engineer (report: .temp/output-review-sort-tracker-update-fresh-2026-04-24-2.md):
  "Three names (tracks/trackers/tracklets) for one list is confusing and fragile.
  Use self.tracks as canonical attribute, add @Property trackers as deprecated alias."
- Remove tracks property/setter and tracklets internal attribute
- Make tracks a plain instance attribute in __init__
- Keep @Property trackers as read-only deprecated alias (pyDeprecate)
- Update test_associated_indices to use tracker.tracks

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
…reates independent copy)

- [resolve #18] /review finding by foundry:sw-engineer (report: .temp/output-review-sort-tracker-update-fresh-2026-04-24-2.md):
  "deepcopy added only to OC-SORT not ByteTrack — inconsistency; supervision fancy indexing already copies"
- Remove deepcopy after slicing detections; slice result is already independent
- Remove unused `from copy import deepcopy` import

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
…ment]

- [resolve #17] /review finding by foundry:linting-expert (report: .temp/output-review-sort-tracker-update-fresh-2026-04-24-2.md):
  "type: ignore[assignment] on alive-tracklet calls — variance issue; return type should use TypeVar"
- Add T_SORTTracklet TypeVar in sort/utils.py and T_ByteTrackTracklet in bytetrack/utils.py
- Remove # type: ignore[assignment] from both tracker files

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
…new tracklet tests

- [resolve #7] Add shape validation to set_kf_covariances (R/Q/P checked against dim_z/dim_x)
- [resolve #16] Document that state estimators require external noise config via set_kf_covariances
- [resolve #15] Document maturity attr difference: SORT uses total updates, ByteTrack uses consecutive
- [resolve #19] Add test/core/test_tracklets.py: SORTTracklet, ByteTrackTracklet, BaseTracklet unit tests
- [resolve #20] Clarify state-estimators.md: XYXYStateEstimator is new configurable default, not historical

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
---
Co-authored-by: Claude Code <noreply@anthropic.com>
Comment thread docs/learn/state-estimators.md Outdated
@Borda Borda self-assigned this Apr 24, 2026
@Borda Borda merged commit 4f0d055 into develop Apr 25, 2026
16 checks passed
@Borda Borda deleted the feat/core/refactor-tracklet-kalman-filter branch April 25, 2026 18:25
@Borda Borda mentioned this pull request Apr 25, 2026
7 tasks
@Borda Borda mentioned this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify internal tracker container name across trackers (tracks vs trackers)

4 participants