ComfyUI Node
cv2.calcOpticalFlowFarneback
Raw wrapper of cv2.calcOpticalFlowFarneback(prev, next, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags). Parameters marked '?' are optional; blank means OpenCV default. See the OpenCV documentation for details.
cv2.calcOpticalFlowFarneback
- prev
- next
- flow
- nparray
◄pyr_scale0.0000►
◄levels0►
◄winsize0►
◄iterations0►
◄poly_n0►
◄poly_sigma0.0000►
◄flagsnone (0)►
Categoryimage/CV/low-level/cv2 C
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prev | NPARRAY,IMAGE,MASK | first 8-bit single-channel input image. 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. | |
| next | NPARRAY,IMAGE,MASK | second input image of the same size and the same type as prev. 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. | |
| flow | NPARRAY,IMAGE,MASK | computed flow image that has the same size as prev and type CV_32FC2. 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. | |
| pyr_scale | FLOAT | 0.0000-1e+38–1e+38 | parameter, specifying the image scale (<1) to build pyramids for each image; pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous one. |
| levels | INT | 0-2147483648–2147483647 | number of pyramid layers including the initial image; levels=1 means that no extra layers are created and only the original images are used. |
| winsize | INT | 0-2147483648–2147483647 | averaging window size; larger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field. |
| iterations | INT | 0-2147483648–2147483647 | number of iterations the algorithm does at each pyramid level. |
| poly_n | INT | 0-2147483648–2147483647 | size of the pixel neighborhood used to find polynomial expansion in each pixel; larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field, typically poly_n =5 or 7. |
| poly_sigma | FLOAT | 0.0000-1e+38–1e+38 | standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a good value would be poly_sigma=1.5. |
| flags | STRING | none (0) | operation flags that can be a combination of the following: - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian $\texttt{winsize}\times\texttt{winsize}$ filter instead of a box filter of the same size for optical flow estimation; usually, this option gives z more accurate flow than with a box filter, at the cost of lower speed; normally, winsize for a Gaussian window should be set to a larger value to achieve the same level of robustness. The function finds an optical flow for each prev pixel using the algorithm so that $$\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])$$ cv2.calcOpticalFlowFarneback flags: one of none (0) plus any of OPTFLOW_USE_INITIAL_FLOW, OPTFLOW_FARNEBACK_GAUSSIAN, pipe-joined (e.g. "none (0) | OPTFLOW_USE_INITIAL_FLOW"). In the UI this renders as a dropdown with one toggle per flag. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |