OpenCV CamShift_0
A real-time tracker that mostly wants a live video feed
- probImage
- literal_0
- literal_1
CamShift is OpenCV's classic object tracker - "Continuously Adaptive Mean Shift" - the one from every computer-vision course that chases a colored object around a webcam feed. This node wraps it for ComfyUI. Before you get excited: in a still-image generator this is one of the pack's more useless nodes. Its whole design assumes a sequence of frames, each one a step in an ongoing search. ComfyUI's normal "generate a picture" workflow has no temporal loop, so CamShift only makes sense in a video or webcam pipeline - think frame-by-frame processing with the previous frame's result feeding the next.
How it works. You hand it a probability image (probImage, NPARRAY), not a normal picture. That's usually a backprojection map - each pixel's value is how strongly it matches some histogram you built (e.g. "skin-colored" or "this object's color"). CamShift starts from an initial window and iteratively shifts that window to the centroid of the probability mass inside it, then re-sizes and re-orients it to fit the distribution. Each call returns the tracked region as a rotated rectangle plus the new window to feed back in for the next frame.
Inputs and outputs. Three inputs, all required:
probImage-NPARRAY, the probability/backprojection mapwindow-STRING, the initial search window as a Python literal, e.g.(100, 100, 200, 200)(x, y, width, height)criteria-STRING, the termination criteria literal, e.g.(3, 10, 1.0)(type=COUNT+EPS, max iterations, epsilon)
Outputs are two strings: literal_0 is the tracked RotatedRect (center, size, angle), literal_1 is the updated window Rect. Neither is an image - if you want the box drawn on the frame you'd parse the rect and feed it to a drawing node.
The honest take. If you're doing genuine video tracking in ComfyUI (there's a thin-but-real niche of people processing video frame-by-frame through custom nodes), this is the raw OpenCV primitive you'd build on. For everyone else it's a curiosity. And note the batch constraint: this pack only handles batch_size == 1, so feeding it a video batch means looping frames through ImageFromBatch first. That's a lot of plumbing for what is, in OpenCV proper, a three-line script. If you control the code, use the code.
Install is the standard pack story: ComfyUI Manager → search "OpenCV", or
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
then restart. No model files. Remember the bridge: Image2Nparray in, Nparrays2Image out, BGR 0..255 uint8 inside. And CamShift_1 next door is the identical twin - the pack numbers overloads from the type definitions, so _0/_1 are duplicates. Expect dragons, as the author warns.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| probImage | NPARRAY | — | |
| window | STRING | — | |
| criteria | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| literal_0 | STRING | — |
| literal_1 | STRING | — |