ComfyUI Node
cv2.calcOpticalFlowPyrLK
Raw wrapper of cv2.calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, winSize?, maxLevel?, criteria?, flags?, minEigThreshold?). Parameters marked '?' are optional; blank means OpenCV default. See the OpenCV documentation for details.
cv2.calcOpticalFlowPyrLK
- prevImg
- nextImg
- prevPts
- nextPts
- winSize
- nextPts
- status
- err
◄maxLevel3►
◄criteria_typemax count or epsilon (whichever first)►
◄criteria_max_count30►
◄criteria_epsilon0.00►
◄flagsnone (0)►
◄minEigThreshold0.0001►
Categoryimage/CV/low-level/cv2 C
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| prevImg | NPARRAY,IMAGE,MASK | first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid. 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. | |
| nextImg | NPARRAY,IMAGE,MASK | second input image or pyramid of the same size and the same type as prevImg. 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. | |
| prevPts | NPARRAY | vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers. A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. | |
| nextPts | NPARRAY | output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input. A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. | |
| winSizeopt | CV_TUPLE | 0,0 | size of the search window at each pyramid level. One value with 2 components (w, h) - it travels as a whole, so it cannot arrive half-connected. Wire it from 'CV Tuple' or type the components in place. |
| maxLevelopt | INT | 3-2147483648–2147483647 | 0-based maximal pyramid level number; if set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on; if pyramids are passed to input then algorithm will use as many levels as pyramids have but no more than maxLevel. Preset to the OpenCV default (3). |
| criteria_typeopt | COMBO | max count or epsilon (whichever first) | When to stop iterating: after max_count iterations, when the change drops below epsilon, or whichever comes first. |
| criteria_max_countopt | INT | 301–2147483647 | Maximum iterations (ignored when 'epsilon only'). |
| criteria_epsilonopt | FLOAT | 0.000–1e+38 | Target accuracy / smallest change worth continuing for (ignored when 'max count only'). |
| flagsopt | STRING | none (0) | operation flags: - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is not set, then prevPts is copied to nextPts and is considered the initial estimate. - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see minEigThreshold description); if the flag is not set, then L1 distance between patches around the original and a moved point, divided by number of pixels in a window, is used as a error measure. cv2.calcOpticalFlowPyrLK flags: one of none (0) plus any of OPTFLOW_USE_INITIAL_FLOW, OPTFLOW_LK_GET_MIN_EIGENVALS, pipe-joined (e.g. "none (0) | OPTFLOW_USE_INITIAL_FLOW"). In the UI this renders as a dropdown with one toggle per flag. |
| minEigThresholdopt | FLOAT | 0.0001-1e+38–1e+38 | the algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in ), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost. The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See Preset to the OpenCV default (0.0001). |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| nextPts | NPARRAY | — |
| status | NPARRAY | — |
| err | NPARRAY | — |