Nodes/opencv-comfyui/OpenCV CamShift_1
ComfyUI Node

OpenCV CamShift_1

CamShift_1 — the duplicate tracker node, and why the pack is full of these

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV CamShift_1
  • probImage
  • literal_0
  • literal_1
window
criteria

This is the same CamShift tracker as CamShift_0, with a different number on the end. Same three inputs, same two outputs, same behavior. The opencv-comfyui pack auto-generates a node for every overload in OpenCV's type definitions, and OpenCV declares each function once for cv2.typing.MatLike and once for UMat - so you get _0 and _1, functionally identical. This page exists mostly so you don't waste a search thinking you're missing a version with extra features. You're not.

If you haven't read the CamShift_0 article, here's the short version. CamShift ("Continuously Adaptive Mean Shift") is OpenCV's classic real-time object tracker. You give it a probability image - typically a histogram backprojection where bright pixels mean "looks like the thing I'm tracking" - plus a starting window and a termination criteria, and it iteratively shifts, resizes, and rotates the window to chase the probability mass. It's designed for video, one frame at a time, feeding the previous result back in. In a still-image ComfyUI pipeline it has almost no use; in a frame-by-frame video-processing workflow it's the raw primitive you'd build on.

Inputs and outputs (same as _0):

  • probImage - NPARRAY, the probability/backprojection map
  • window - STRING, initial window as a literal, (x, y, w, h) e.g. (100, 100, 200, 200)
  • criteria - STRING, termination criteria literal, e.g. (3, 10, 1.0) (type, max iterations, epsilon)
  • outputs literal_0 (RotatedRect, as a string) and literal_1 (updated window Rect)

The composite-string inputs are the pack's signature quirk: they're parsed with literal_eval, so comma-separated tuples in parentheses, nothing else. Wrong syntax and you'll see the README's invalid syntax (unknown, line 0).

One practical note specific to tracking in ComfyUI: the pack only supports batch_size == 1 images, and a tracker by definition wants a stream of frames. You'll be pulling individual frames with ImageFromBatch, converting each with Image2Nparray, running this, and threading the output window back into the next iteration. That's real plumbing. If your goal is object tracking, a few lines of raw Python will beat this node every time - it exists so the OpenCV surface is complete in the graph, not because it's the comfortable path.

Install: ComfyUI Manager, search "OpenCV", or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Restart after. No models, no downloads beyond OpenCV. And remember the author's own warning: these nodes are auto-generated, ugly, and "expect dragons." A duplicated tracker node is one of the friendlier dragons.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
probImageNPARRAY
windowSTRING
criteriaSTRING

Outputs (2)

NameTypeDescription
literal_0STRING
literal_1STRING