Skip to content

SAM3: Support running on video frames - #26

Draft
mrpositron wants to merge 1 commit into
mainfrom
sam3-video-frames
Draft

mrpositron wants to merge 1 commit into
mainfrom
sam3-video-frames

Conversation

@mrpositron

Copy link
Copy Markdown
Contributor

What has changed and why?

The SAM3 plugin only ran on images. On a video frame collection it found no samples. This PR lets it run on video frames too.

  • Add OperatorScope.VIDEO_FRAME to the supported scopes.
  • On a video frame collection, fetch frames with video_frame_resolver and map the view filter to a VideoFrameFilter. The image path is unchanged.
  • Frames have no file of their own. _read_video_frames decodes them from the parent video with OpenCV and keeps one capture open per video. The resolver already returns frames grouped by video.
  • Frames are rotated by rotation_deg before segmentation, the same way lightly_studio displays them. Without this, masks on portrait phone videos would not line up.
  • The image size now comes from the decoded image. For images this is equal to the stored width/height.
  • Add opencv-python-headless as a direct dependency. It was already installed through lightly_studio.

Not in scope: cloud video paths (the image path is also local only) and SAM3 video tracking. Each frame is segmented independently.

How has it been tested?

  • mypy passes. ruff reports the same 3 BLE001 warnings as on main.
  • Ran _read_video_frames on a generated 5-frame video: correct frame content after seeking, width and height swapped for a 90° frame, RGB channel order, and an out-of-range frame is skipped with a warning.
  • TODO: run end to end in Lightly Studio on a video dataset, including a rotated video.

Did you update Readme.md and plugins.toml?

  • Yes
  • Not needed

Updated the plugin README. The root README.md and plugins.toml descriptions still say "image" only.

Decode frames from the parent video with OpenCV, applying the stored rotation so masks match the displayed frame.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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