Skip to content

OP#9534: Add ultralytics BoT-SORT tracker integration#520

Open
Sebastian-Gerken wants to merge 9 commits intomainfrom
feature/botsort-ultralytics-tracker
Open

OP#9534: Add ultralytics BoT-SORT tracker integration#520
Sebastian-Gerken wants to merge 9 commits intomainfrom
feature/botsort-ultralytics-tracker

Conversation

@Sebastian-Gerken
Copy link
Copy Markdown
Contributor

Summary

Adds BoT-SORT as an alternative tracker to the existing IOU tracker, wrapping ultralytics' BOTSORT implementation (v8.3.159). BoT-SORT offers more robust tracking through Kalman-filter motion models, appearance matching, and Global Motion Compensation (GMC).

What changed

OTVision/track/tracker/tracker_plugin_botsort.py — New file (400 lines):

  • BotsortTracker implementing the Tracker ABC with ultralytics adapter pattern
  • Protocol-based typing (BoTSORTTrackerLike, UltralyticsResultsLite) for lazy import isolation
  • OTVision lifecycle semantics (t_min/t_miss_max) with parity to IOU tracker
  • FPS extraction from .otdet metadata (supports numeric and string-encoded values)
  • Explicit multi-video state reset on group boundaries

OTVision/application/config.py — Config model:

  • _TrackBotSortConfig frozen dataclass with t_min, t_miss_max, and tracker_params dict
  • TrackConfig.tracker_type field with polymorphic t_min/t_miss_max properties

OTVision/application/config_parser.py — YAML parsing:

  • parse_track_botsort_config() with UPPERCASE → lowercase key normalization for ultralytics
  • validate_tracker_type() rejects unknown tracker types with clear error message

OTVision/track/builder.py — Factory:

  • Conditional BotsortTracker / IouTracker instantiation based on tracker_type

OTVision/track/cli.py + OTVision/domain/cli.py — CLI:

  • --tracker {iou,botsort} option; TrackCliArgs.tracker_type typed as str | None

OTVision/application/track/update_track_config_with_cli_args.py — CLI override logic:

  • Warns when IOU-specific CLI flags are used in botsort mode

OTVision/application/track/ottrk.py + OTVision/track/parser/frame_group_parser_plugins.py:

  • Store tracker params in .ottrk metadata for reproducibility

Tests:

  • tests/track/test_botsort_tracker.py — E2E tracking, multi-video reset, FPS error paths
  • tests/track/test_botsort_results_lite.py — Adapter stub unit tests, string-encoded FPS
  • tests/cli/test_track_cli.py — BoT-SORT CLI mode selection test

OP#9534

Sebastian-Gerken and others added 9 commits March 20, 2026 13:49
- Add TRACK.BOT_SORT + TRACKER_TYPE parsing and TrackConfig.to_dict() parity
- Sync OTVision/config.py CONFIG defaults (TRACK, DETECT video fields, GUI icon)
- Fix BotsortTracker: BYTETracker.update(results, img) for ultralytics 8.3+
- UltralyticsResultsLite: len/getitem/xyxy for tracker internals
- Tests: botsort results lite, CLI expectations use user_config base config
- user_config: TRACKER_TYPE + BOT_SORT defaults

Made-with: Cursor
Allow uppercase BOT_SORT YAML keys by normalizing to ultralytics-style lowercase in parser, and document BOT_SORT defaults with inline descriptions in user config.

Made-with: Cursor
Read frame rate from .otdet VIDEO metadata (actual_fps then recorded_fps) and hard-fail when metadata is missing or unreadable, instead of silently defaulting to 30 FPS.

Made-with: Cursor
Explain that T_MISS_MAX is applied by OTVision post-processing while TRACK_BUFFER is used inside Ultralytics BoT-SORT.

Made-with: Cursor
The --tracker CLI default was "iou", unconditionally overwriting any
TRACKER_TYPE set in the YAML config. Changed to default=None and use
value_or_default so the YAML setting is honored when the flag is omitted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…T integration tests

The FPS extraction for BoT-SORT now handles string-encoded values
(e.g. "20.0") found in real .otdet files via a new _try_positive_float
helper.  Added integration tests covering E2E tracking, multi-video
group reset, and FPS error paths.  Improved inline documentation for
the sigma_h omission, frame.no==0 reset convention, and image dtype
contract.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cker_type

TrackCliArgs.tracker_type is now `str | None = None` to match the
actual argparse output (None when --tracker is omitted).  Added
validate_tracker_type() in ConfigParser to reject unknown tracker
types from YAML with a clear error message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant