Skip to content

FEATURE: Spline Annotations - #1919

Merged
SkalskiP merged 7 commits into
roboflow:developfrom
Ashp116:feature/spline-tracer
Jul 31, 2025
Merged

SkalskiP merged 7 commits into
roboflow:developfrom
Ashp116:feature/spline-tracer

Conversation

@Ashp116

@Ashp116 Ashp116 commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

Description

Added a spline annotation to smooth tracking detections by fitting a spline curve through the detected points. This helps reduce noise and jitter in the tracking paths, resulting in cleaner and more visually appealing traces. The spline annotation improves the quality of annotation for object tracking by producing smoother motion paths compared to raw point connections. This feature addresses issues related to noisy and jittery tracking visualization.

I will attach 2 videos showcasing spline vs tracer annotations:

RED - SplineAnnotator
BLUE - TracerAnnotations

output-annotator.mp4
output-annotator-1.mp4

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

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

Use this code to test out the spline tracer

import supervision as sv
from supervision.assets import VideoAssets, download_assets
from ultralytics import YOLO

model = YOLO('yolo11n.pt')
spline_annotator = sv.SplineAnnotator(thickness=2, color=sv.Color.RED, smoothing_factor=20)
trace_annotator = sv.TraceAnnotator(thickness=4, color=sv.Color.BLUE)

vid_path = VideoAssets.BASKETBALL.value # Use your own video path
download_assets(VideoAssets.BASKETBALL.value)

video_info = sv.VideoInfo.from_video_path(video_path=vid_path)
frames_generator = sv.get_video_frames_generator(source_path=vid_path)
tracker = sv.ByteTrack()

with sv.VideoSink(target_path='output-annotator-1.mp4', video_info=video_info) as sink:
    for frame in frames_generator:
        result = model(frame, verbose=False)[0]
        detections = sv.Detections.from_ultralytics(result)
        detections = tracker.update_with_detections(detections)
        
        # Overlay both trace and spline
        annotated_frame = trace_annotator.annotate(
            scene=frame.copy(),
            detections=detections)
        annotated_frame = spline_annotator.annotate(
            scene=annotated_frame,
            detections=detections)
        sink.write_frame(frame=annotated_frame)

Any specific deployment considerations

None. This is an additive feature without breaking changes or new dependencies.

Docs

  • Docs updated? What were the changes:

@Ashp116
Ashp116 requested a review from SkalskiP as a code owner July 30, 2025 07:06
@SkalskiP

Copy link
Copy Markdown
Collaborator

Hi @Ashp116 👋🏻 Thanks for coming back with more great feature ideas! I love to see contributors coming back to add even more! 🔥

Quick question before we dive in: are you on LinkedIn or X? I wanted to tag you in the supervision-0.26.0 release post, but I couldn't match your GitHub account to any social profiles.

Regarding your PR, this is a fantastic idea! How about we update the TraceAnnotator to include a smooth flag? Is there any reason user would like to manipulate smoothing_factor and spline_order?

@Ashp116

Ashp116 commented Jul 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Hi @SkalskiP,

Thank you for the kind words!

Regarding socials, I’m on X, but I have a small favor to ask. I'd prefer that any public post only mention my GitHub account. However, if you'd like to tag me in a LinkedIn post specifically, feel free to use my LinkedIn profile. I just like to keep things separated.

As for adding a smooth flag — yes, I think that's a good approach to introduce spline annotations. I’ll go ahead and make those changes. Regarding the smoothing_factor and spline_order, I don’t expect users to need to tweak those often; I added them mainly to allow for more flexible spline configurations.

Now that I think about it, adding a smooth: int = 0 parameter would be a better approach than introducing a separate class for spline annotations. While a smooth: bool = True flag isn’t a bad option either, I prefer using smooth as an integer. It gives users finer control over the smoothing behavior, allowing them to specify the level of smoothing directly in their annotations.

Comment thread supervision/annotators/core.py Resolved
@Ashp116
Ashp116 requested a review from SkalskiP July 30, 2025 22:26
@SkalskiP

SkalskiP commented Jul 31, 2025 •

Copy link
Copy Markdown
Collaborator

This is great! I'm merging! Thanks a lot for your contribution 🙏🏻

@SkalskiP
SkalskiP merged commit 90f8582 into roboflow:develop Jul 31, 2025
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.

2 participants