ComfyUI Node
CV Optical Flow (DIS)
Dense Inverse Search optical flow (cv2.DISOpticalFlow) - the modern replacement for 'CV Optical Flow (Farneback)'. It matches small patches coarse-to-fine, propagates the winners to their neighbours and then runs a variational refinement, which gives noticeably sharper motion boundaries AND runs faster than Farneback at comparable quality. DISOpticalFlow is a cv2 class the raw wrappers cannot expose. Start from a preset, then override individual parameters if needed. Connect 'init_flow' (e.g. the previous frame pair's flow) to warm-start a video sequence - large motions converge far better that way.
CV Optical Flow (DIS)
- frame_a
- frame_b
- init_flow
- flow
- magnitude
- angle
◄presetmedium (most accurate)►
◄finest_scale-1►
◄gradient_iterations-1►
◄refinement_iterations-1►
◄patch_size-1►
◄patch_stride-1►
◄spatial_propagationtrue►
◄mean_normalizationtrue►
Categoryimage/CV/features
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| frame_a | NPARRAY,IMAGE | First frame (earlier in time); 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. | |
| frame_b | NPARRAY,IMAGE | Second frame; resized to frame_a if the sizes differ. 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. | |
| preset | COMBO | medium (most accurate) | Speed/quality preset; it presets finest_scale, patch size/stride and the iteration counts. 'ultrafast' is real-time-video fast, 'medium' is the best quality. |
| finest_scale | INT | -1-1–6 | Finest pyramid level actually computed. -1 keeps the preset's value. 0 = full resolution (sharpest and slowest); raising it blurs and speeds up. |
| gradient_iterations | INT | -1-1–100 | Gradient-descent iterations per patch. -1 keeps the preset's value; more = more accurate, slower. |
| refinement_iterations | INT | -1-1–100 | Variational refinement iterations run after the patch search. -1 keeps the preset's value; 0 turns the refinement off entirely (rawer, blockier flow). |
| init_flowopt | NPARRAY | Optional HxWx2 flow to start from - pass the previous frame pair's flow when processing a video. It is copied, never written to, so the upstream node's cached array is safe. | |
| patch_sizeopt | INT | -1-1–64 | Side of the matched patch in pixels. -1 keeps the preset's value (8 is the usual). |
| patch_strideopt | INT | -1-1–32 | Spacing between patches. -1 keeps the preset's value; smaller = denser and slower. |
| spatial_propagationopt | BOOLEAN | true | Seed each patch from its already-solved neighbour. Almost always worth it - the main reason DIS beats a plain patch search. |
| mean_normalizationopt | BOOLEAN | true | Normalise patch means before matching, which makes the match robust to brightness changes between frames. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| flow | NPARRAY | HxWx2 float32 (dx, dy) displacement per pixel. |
| magnitude | NPARRAY | HxW float32 motion magnitude in pixels. |
| angle | NPARRAY | HxW float32 motion direction in RADIANS - feed 'CV Flow To Color' in its default radians mode. |