CV Track Window
One tracking step of cv2.meanShift / cv2.CamShift: slides the window uphill on a density map until it sits on the local mass peak. The density is typically 'CV Back Project' output (histogram tracking), but any single-channel likelihood map works (a threshold mask, a heatmap...). Chain one node per frame: this window output -> the next frame's window input; seed the first frame with a 'CV Scalar' literal like '(x, y, w, h)'. The raw cv2_meanShift wrapper cannot chain (its rect comes out as a text literal) - this node keeps the window as a wireable NPARRAY. Failure-tolerant: a window off the image, a degenerate size or a density with no mass under the result yields found=false and echoes the INPUT window unchanged (the track holds its last position instead of erroring) - branch on 'found' with if/else. Visualize: bbox -> the core 'Draw BBoxes' node; box_edges -> 'CV Draw Segments' (shows CamShift's rotated box).
- density
- window
- window
- bbox
- box_edges
- center
- found
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| density | NPARRAY,IMAGE | Density/likelihood map the window climbs on - usually an 'CV Back Project' map. Color input is converted to grayscale. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| window | NPARRAY | Search window as 4 numbers (x, y, w, h): a 'CV Scalar' literal for the first frame, the previous 'CV Track Window' window output afterwards. | |
| method | COMBO | meanShift (fixed-size window) | meanShift keeps the window size fixed (steady, needs a roughly constant object size); CamShift also fits size + orientation (box_edges shows the rotated box) but can balloon on weak densities. |
| iterations | INT | 101–1000 | Maximum hill-climbing iterations per step; 10 is the classic tracking value. |
| epsilon | FLOAT | 1.00–100 | Stop when the window center moves less than this many pixels between iterations. |
| min_density | FLOAT | 00–255 | Minimum AVERAGE density inside the result window for 'found' to be true. 0 accepts any non-zero mass; raise it (e.g. 32 on a 0-255 back-projection) so a few stray matching pixels do not count as a locked track. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| window | NPARRAY | Tracked window (x, y, w, h) as int32 - wire into the next frame's window input. Echoes the input window when found=false. |
| bbox | BOUNDING_BOX | The same window as core BOUNDING_BOX data ({x, y, width, height}) - chain into the core 'Draw BBoxes' node. |
| box_edges | NPARRAY | The box outline as 4 segments (4x4 endpoint quadruples) for 'CV Draw Segments' - CamShift's actual rotated box, meanShift's window rectangle. |
| center | NPARRAY | Box center as a 1x2 float array - collect centers to draw the trajectory with 'CV Draw Points' or 'CV Draw Segments'. |
| found | BOOLEAN | — |