Nodes/opencv-comfyui/OpenCV calcOpticalFlowFarneback_1
ComfyUI Node

OpenCV calcOpticalFlowFarneback_1

The duplicate overload of dense flow

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV calcOpticalFlowFarneback_1
  • prev
  • next
  • flow
  • nparray
pyr_scale
levels
winsize
iterations
poly_n
poly_sigma
flags

OpenCV calcOpticalFlowFarneback_1 is the same dense-optical-flow node as calcOpticalFlowFarneback_0, emitted as the second overload of cv2.calcOpticalFlowFarneback. The opencv-comfyui generator numbered every overload it found; this function has two; there is zero practical difference between them. Pick one and move on with your life.

What the function does, in one sentence: it takes two frames and produces a full per-pixel motion field - a two-channel array where every pixel carries how far it moved horizontally and vertically between the frames. Dense flow is the "where did everything go" primitive, and Farneback is the classic algorithm for it: local polynomial approximation, matched across an image pyramid, refined iteratively. It's the kind of deterministic CV computation the pack's author says these nodes are for - small, quick, non-AI transformations - except this one is not small: it needs grayscale input, a specific out-parameter wiring, and the output isn't a viewable image.

Inputs

  • prev / next - NPARRAY frames, grayscale uint8. Feed RGB and you hit the README's own img.type() == CV_8UC1 assertion error; run cvtColor (code 6) first.
  • flow - NPARRAY: the out-parameter, surfaced as a required input. It gets overwritten, but you must wire a (H, W, 2) float32 array into the slot anyway - one of the pack's roughest edges.
  • pyr_scale (FLOAT) - 0.5 standard.
  • levels (INT) - pyramid depth; more = bigger motions.
  • winsize (INT) - averaging window; 15–21 typical.
  • iterations (INT) - 5 typical.
  • poly_n (INT) - polynomial window, 5 or 7.
  • poly_sigma (FLOAT) - 1.1–1.5.
  • flags (INT) - 0 for fresh, 4 to seed from an existing flow.

Output: one nparray, the (H, W, 2) float flow field. Not an image - two-channel arrays don't survive Nparrays2Image cleanly, so visualization is on you.

Install and verdict

ComfyUI Manager → opencv-comfyui, or clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart; needs opencv-contrib-python. Same pack-wide rules (batch size 1, NPARRAY conventions).

This is the honest "for CV heads only" node. If you're doing motion analysis on frames, it's the genuine primitive - and the friction is the pack's, not yours. For motion-aware generation, the video ecosystems in ComfyUI have friendlier purpose-built tools. And the _1 tells you nothing - it's just the redundant twin.

Categoryimage/OpenCV

Inputs (10)

NameTypeDefaultDescription
prevNPARRAY
nextNPARRAY
flowNPARRAY
pyr_scaleFLOAT
levelsINT
winsizeINT
iterationsINT
poly_nINT
poly_sigmaFLOAT
flagsINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY