Skip to content

feat(trackers): Implement OC-SORT #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat(trackers): Implement OC-SORT #101

wants to merge 4 commits into from

Conversation

soumik12345
Copy link
Contributor

@soumik12345 soumik12345 commented Jul 7, 2025

Description

The PR implements the OC-SORT tracking algorithm from the paper Observation-Centric SORT: Rethinking SORT for Robust Multi-Object Tracking.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this change been tested, please provide a testcase or example of how you tested the change?

The code has been tested with the following code snippet:

import supervision as sv
from ultralytics import YOLO

from trackers import OCSORTTracker

model = YOLO("yolo11l.pt")
tracker = OCSORTTracker()

color = sv.ColorPalette.from_hex(
    [
        "#ffff00",
        "#ff9b00",
        "#ff8080",
        "#ff66b2",
        "#ff66ff",
        "#b266ff",
        "#9999ff",
        "#3399ff",
        "#66ffff",
        "#33ff99",
        "#66ff66",
        "#99ff00",
    ]
)

box_annotator = sv.BoxAnnotator(color=color, color_lookup=sv.ColorLookup.TRACK)

trace_annotator = sv.TraceAnnotator(
    color=color, color_lookup=sv.ColorLookup.TRACK, thickness=2, trace_length=100
)

label_annotator = sv.LabelAnnotator(
    color=color,
    color_lookup=sv.ColorLookup.TRACK,
    text_color=sv.Color.BLACK,
    text_scale=0.8,
)


def callback(frame, i):
    result = model(frame, imgsz=1280, verbose=False)[0]
    detections = sv.Detections.from_ultralytics(result)
    detections = tracker.update(detections)

    if not detections.is_empty():
        detections = detections[detections.class_id == 0]

    annotated_image = frame.copy()
    annotated_image = box_annotator.annotate(annotated_image, detections)
    annotated_image = trace_annotator.annotate(annotated_image, detections)
    annotated_image = label_annotator.annotate(
        annotated_image, detections, detections.tracker_id
    )

    return annotated_image


tracker.reset()

sv.process_video(
    source_path="people-walking.mp4",
    target_path="output.mp4",
    callback=callback,
    show_progress=True,
)

Docs

  • [❌] Docs updated? What were the changes

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.

1 participant