Nodes/ComfyUI_SwiftCut/Image Color Track Bind (Pro)
ComfyUI Node

Image Color Track Bind (Pro)

Pin an Image to a Moving Colored Object, the OpenCV Way

By yichengup·Created about a year ago·Updated 8 months ago· 10
Image Color Track Bind (Pro)
  • image
  • video_frames
  • mask
  • output_frames
target_color#FF0000
color_tolerance30
smoothing_factor0.10
processing_width640
anchor_offset_x0
anchor_offset_y0
base_scale1.00
enable_rotationfalse
rotation_offset0.00
enable_auto_scalefalse
motion_blur_strength0.0

Want to stick a logo onto a moving coffee cup, or attach a sprite to someone's red hat across a whole video clip - without drawing masks every frame? Image Color Track Bind (Pro) is SwiftCut's attempt at that: classic OpenCV color tracking, packaged as one node. Feed it a still image (the thing you want pasted) and a video batch (the footage), pick a color, and it tracks the biggest blob of that color through every frame and keeps your image glued to it.

"Pro" is doing a lot of work here. This isn't a learned object detector - no model, no weights, no GPU. It's the old-school technique: match pixels near a color, find contours, track the biggest one, paste. That's both the appeal (instant, zero setup) and the ceiling (one color, one blob, and it loses hard objects that blend into the background).

How it works, under the hood

For every frame of video_frames it:

  1. Converts to HSV and masks pixels within color_tolerance of target_color (hex, default #FF0000 red).
  2. Erodes/dilates to kill noise, finds contours, and scores candidates by area - with a distance penalty from the previous frame's center so it doesn't jump to a random blob mid-clip.
  3. Rescales your overlay image by base_scale, rotates it if enable_rotation is on, and pastes it centered on the tracked point, plus anchor_offset_x/y in pixels for fine positioning.
  4. Also optional: mask controls the overlay's alpha (where the sticker is actually visible), not the tracking region.

The tracking data gets smoothed with an exponential moving average (smoothing_factor, lower = more stable, higher = more jittery) and any frames where the color disappears get linear-interpolated positions rather than dropped - so a couple of bad frames won't rip your sticker off the object.

The extras are where "Pro" earns its name: enable_auto_scale sizes the overlay to the contour's area (so the sticker grows as the object gets closer), rotation_offset fixes the starting angle, and motion_blur_strength smears the overlay along its own motion vector - the touch that makes a glued-on PNG look less fake. Processing happens at processing_width (default 640px) for speed, then centers get mapped back to full resolution.

The install gotcha that will bite you

Here's the thing nobody tells you: this node imports cv2, and the pack's requirements.txt doesn't list opencv. If you don't already have opencv-python in your ComfyUI environment, the node simply won't appear in your menu. The pack's __init__.py loads each node file in a try/except and skips the ones that fail, so the rest of SwiftCut shows up fine and ColorTrack silently vanishes. Fix:

cd ComfyUI/custom_nodes/ComfyUI_SwiftCut
pip install opencv-python

then restart ComfyUI. If you see every other SwiftCut node but not this one, that's your culprit.

Using it well

target_color is a hex string (#FF0000 default). color_tolerance is the single knob for how much shade variation counts as "the color" - start at 30 and raise it if tracking drops out under lighting changes, but know that a high tolerance starts swallowing everything near that hue. Smoothing at 0.1 is a sane starting point; push it toward 0.9 only if the sticker is wiggling too much, and accept lag in return.

Install is otherwise the standard pack dance - ComfyUI Manager, search "ComfyUI_SwiftCut", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI_SwiftCut

The realistic use cases are stickers, subtitles-as-sprites, logo burns, or attaching labels to a colored prop in an AI-generated clip. Just don't expect it to track a face - for that you'd want a real tracker. This is a color matcher with a paste-on-top habit, and for exactly that job it's remarkably capable for being three dozen lines of OpenCV.

CategoryYC_VideoCutHelper/Image

Inputs (14)

NameTypeDefaultDescription
imageIMAGE
video_framesIMAGE
target_colorSTRING#FF0000
color_toleranceINT300–255
smoothing_factorFLOAT0.100–0.99
processing_widthINT640100–4096
anchor_offset_xINT0
anchor_offset_yINT0
base_scaleFLOAT1.000.1–10
enable_rotationBOOLEANfalse
rotation_offsetFLOAT0.00-360–360
enable_auto_scaleBOOLEANfalse
motion_blur_strengthFLOAT0.00–5
maskoptMASK

Outputs (1)

NameTypeDescription
output_framesIMAGE