SAMURAI Box Input
Draw a box on the first frame, and SAMURAI tracks the rest
- image
- BOX
- START_FRAME
SAMURAI Box Input is the front end of a three-node video object segmentation pack. You feed it a video (well, a batch of frames), it opens a window, you drag a rectangle around whatever you want to track, and it hands that box plus a start frame to SAMURAI Refine, which does the actual segmentation across the whole clip. If you've rotoscoped by hand before, this is the "just point at the thing" button.
The first thing to know - and the thing that catches everyone off guard - is that this isn't an in-browser widget. The node opens a native OpenCV window on the machine that's actually running ComfyUI. You draw the box there, press Enter, and it moves on. No headless server, no remote box you only reach through a browser tab.
How it works
Under the hood it's about ten lines of code. The node grabs the frame at start_frame from the IMAGE batch, converts it to the BGR color order OpenCV wants, and calls cv2.selectROI - that's the drag-a-rectangle dialog. Press Enter to confirm the box, Esc to cancel. The refresh_input integer is just a trigger: bump it if you want to re-draw, and the window comes back the next time you run the queue.
Inputs and outputs
Three inputs, and you actually set one of them:
image(required) - the video as an IMAGE batch. Wire it from a Load Video node; VideoHelperSuite's "Load Video" outputs exactly this.start_frame(INT, default 0) - which frame of the clip to show when you draw. Frame 0 is the first frame; keep it at 0 unless you have a real reason to start mid-clip.refresh_input(INT, default 0) - the re-draw trigger.
Outputs are BOX and START_FRAME. The box comes back in OpenCV's native x, y, width, height format, and the Refine node converts it to the top-left/bottom-right corners SAM2 expects internally, so you don't touch it. Wire both outputs into SAMURAI Refine's box and start_frame inputs.
Installing it
This pack isn't a normal clone-and-go install, because it wraps the upstream SAMURAI repo rather than vendoring it. The README's recipe:
cd ComfyUI/custom_nodes
git clone https://github.com/takemetosiberia/ComfyUI-SAMURAI--SAM2-.git samurai_nodes
Then copy your whole SAMURAI installation folder into samurai_nodes/ so samurai/sam2/checkpoints/ exists, drop the model weights in there, and pip install hydra-core omegaconf loguru. It wants an NVIDIA GPU with CUDA - SAMURAI itself is CUDA-locked, so no CPU or Apple Silicon runs. The README pushes conda hard and insists you run ComfyUI from a console so you can actually see the logs. None of this is auto-downloaded; it's all on you.
Gotchas
- The popup appears on the server, not in your browser. If ComfyUI runs headless or on a machine you reach only remotely, the window never shows and the queue just sits there waiting for Enter.
- The box is drawn at full resolution, but if the Refine node's
resolutionsetting downsizes your footage, it doesn't rescale the box to match. Keepresolutionat or above your video's longest side and the coordinates stay honest. - The whole pack is a thin, single-commit wrapper around a good model - great if you want the capability, less great if you're expecting something maintained. Treat it as "works if you follow the steps, don't expect updates."
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| start_frame | INT | 0 | — |
| refresh_input | INT | 0 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| BOX | BOX | — |
| START_FRAME | START_FRAME | — |