ComfyUI Node
CV Optical Flow (RLOF, Dense)
Dense optical flow by Robust Local Optical Flow (cv2.optflow.calcOpticalFlowDenseRLOF): it tracks a GRID of points with an illumination-robust local solver, then interpolates them into a dense field with the same edge-aware interpolators as 'CV Disparity Interpolate'. That makes it the quality/speed middle ground between DIS and TV-L1, and the best of the three when the two frames differ in EXPOSURE, because the illumination model is part of the per-point solve. Unlike every other flow node here it needs COLOUR: the cross-based support region segments on colour, so a grayscale input is expanded to BGR and the method loses its main advantage. Raise 'grid_step' for speed, lower it for detail.
CV Optical Flow (RLOF, Dense)
- frame_a
- frame_b
- flow
- magnitude
- angle
◄grid_step6►
◄interpolationEPIC (edge-preserving, default)►
◄forward_backward_threshold1.0►
◄use_variational_refinementfalse►
◄use_post_proctrue►
◄epic_k128►
◄epic_sigma0.050►
◄epic_lambda999►
◄ric_superpixel_size15►
◄ric_slic_typeSLIC►
◄fgs_lambda500►
◄fgs_sigma1.5►
◄solver_typebilinear (accurate, default)►
◄support_regioncross-based segmentation (default)►
◄small_win_size9►
◄large_win_size21►
◄max_level4►
◄max_iterations30►
◄use_m_estimatorfalse►
◄use_illumination_modeltrue►
◄use_global_motion_priortrue►
◄cross_segmentation_threshold25►
◄min_eigen_value0.0001►
◄global_motion_ransac_threshold10.0►
Categoryimage/CV/contrib
Inputs (26)
| Name | Type | Default | Description |
|---|---|---|---|
| frame_a | NPARRAY,IMAGE | First frame. Kept in COLOUR (8-bit BGR) - RLOF uses the colour to grow its support regions. 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, same size as frame_a. 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. | |
| grid_step | INT | 61–64 | Spacing in pixels of the point grid that is actually tracked; everything between is interpolated. The dominant speed/detail knob (cv2 default 6). |
| interpolation | COMBO | EPIC (edge-preserving, default) | How the tracked grid becomes a dense field. EPIC fits a local affine model along image edges, RIC fits one plane per SLIC superpixel (sharpest at motion boundaries, slowest, and it RANDOMIZES its model fitting so its output varies slightly run to run), GEO is a plain geodesic weighting and is the fastest. |
| forward_backward_threshold | FLOAT | 1.00–30 | Drop a grid point when re-tracking it back misses its origin by more than this many pixels. 0 disables the check and keeps every point, including the ones that ran into an occlusion. |
| use_variational_refinement | BOOLEAN | false | Run a variational polish over the interpolated field (the same refinement DIS ends with). Sharpens boundaries at a noticeable cost; cv2's default is off. |
| use_post_procopt | BOOLEAN | true | Run the fast global smoother after interpolation. Recommended - without it the per-region models stay visible as blocky steps. |
| epic_kopt | INT | 1281–512 | EPIC/GEO: neighbouring tracked points used to fit each local model. Larger = smoother, slower. |
| epic_sigmaopt | FLOAT | 0.0500.001–1 | EPIC/GEO: falloff of the geodesic distance weighting. |
| epic_lambdaopt | FLOAT | 9990–5000 | EPIC/GEO: regularization of the local affine fit. |
| ric_superpixel_sizeopt | INT | 154–64 | RIC only: average SLIC superpixel side in pixels. Smaller follows finer structure at more cost. |
| ric_slic_typeopt | COMBO | SLIC | RIC only: superpixel algorithm. SLIC is the baseline, SLICO adapts its compactness automatically, MSLIC is the manifold variant. |
| fgs_lambdaopt | FLOAT | 5001–10000 | Post-processing smoother strength (ignored when use_post_proc is off). |
| fgs_sigmaopt | FLOAT | 1.50.01–100 | Post-processing edge sensitivity in colour units (ignored when use_post_proc is off). |
| solver_typeopt | COMBO | bilinear (accurate, default) | Iteration scheme. 'bilinear' interpolates sub-pixel and is more accurate; 'standard' samples on the pixel grid and is faster. |
| support_regionopt | COMBO | cross-based segmentation (default) | Shape of the region matched around each point. 'cross-based' grows the window along colour-similar pixels, which is what keeps RLOF sharp at motion boundaries; 'fixed window' is the classic square block. |
| small_win_sizeopt | INT | 93–51 | Window used at the finest level / inside a support region. |
| large_win_sizeopt | INT | 213–101 | Largest matching window; bigger tolerates bigger motion and blurs fine detail. |
| max_levelopt | INT | 40–8 | Pyramid levels (0 = no pyramid). More levels track larger displacements. |
| max_iterationsopt | INT | 301–200 | Iterations per level before giving up on a point. |
| use_m_estimatoropt | BOOLEAN | false | Use the robust Lorentzian norm instead of plain L2. cv2's own default is OFF (the parameter object ships with the norm sigmas at FLT_MAX). Turning it on costs time and helps when the two frames contain outlier motion. |
| use_illumination_modelopt | BOOLEAN | true | Solve for a per-region brightness/contrast change as well as the motion - the 'robust' in RLOF. Turn it off only if the exposure is provably constant and you need the speed. |
| use_global_motion_prioropt | BOOLEAN | true | Estimate a global (camera) motion first and start every point from it. Helps a panning camera, hurts nothing much. |
| cross_segmentation_thresholdopt | INT | 250–255 | Colour difference at which the cross-based support region stops growing (ignored for a fixed window). |
| min_eigen_valueopt | FLOAT | 0.00010–1 | Points whose structure tensor is flatter than this are declared untrackable. |
| global_motion_ransac_thresholdopt | FLOAT | 10.00–100 | RANSAC inlier threshold used when fitting the global motion prior (ignored when that prior is off). |
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. |