Nodes/opencv-comfyui/OpenCV calcOpticalFlowPyrLK_1
ComfyUI Node

OpenCV calcOpticalFlowPyrLK_1

The twin of sparse flow tracking

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV calcOpticalFlowPyrLK_1
  • prevImg
  • nextImg
  • prevPts
  • nextPts
  • status
  • err
  • nparray_0
  • nparray_1
  • nparray_2
winSize
maxLevel
criteria
flags
minEigThreshold

OpenCV calcOpticalFlowPyrLK_1 is calcOpticalFlowPyrLK_0 under a second overload number. Same function, same inputs, same outputs, same quirks - the opencv-comfyui generator emitted a node per overload it found in OpenCV's type stubs, and cv2.calcOpticalFlowPyrLK has two. There is nothing to choose between them.

So what does it do? Sparse optical flow: you hand it two frames and a set of starting points, and it returns where each point moved, a per-point success flag, and an error estimate. It's the pyramidal Lucas–Kanade tracker - the workhorse behind object tracking, video stabilization, and feature matching for decades. Compared to the dense Farneback node, this one's output is friendlier: points and status flags, not a two-channel field you must visualize.

Inputs

  • prevImg / nextImg - NPARRAY frames, grayscale uint8. RGB in → img.type() == CV_8UC1 assertion, the README's own troubleshooting entry; convert with cvtColor (code 6).
  • prevPts - NPARRAY, your (N, 2) float32 starting points.
  • nextPts - NPARRAY: an out-parameter surfaced as a required input (the generator's roughness). Wire a same-size array; it gets overwritten and the tracked points come back on the first output.
  • winSize - STRING literal, (21, 21) (a Size).
  • maxLevel - INT, pyramid depth; 3 typical.
  • criteria - STRING literal, (3, 30, 0.01) (TermCriteria: EPS+COUNT, 30 iters, 0.01).
  • flags - INT, 0 (1 = OPTFLOW_LK_GET_MIN_EIGENVALS, 2 = OPTFLOW_USE_INITIAL_FLOW).
  • minEigThreshold - FLOAT, 1e-4 typical.
  • status / err (optional) - out-parameters; leave unwired.

Outputs: nparray_0 (tracked points), nparray_1 (status 1.0/0.0), nparray_2 (error). None are images.

Install and the verdict

ComfyUI Manager → opencv-comfyui, or clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart; needs opencv-contrib-python. Batch size 1, NPARRAY conventions, same as everywhere in this pack.

It's a genuine CV primitive for people who already have points to track - for them it's the real deal, and the _1/_0 distinction is pure pack artifact. For everyone else, the grayscale requirement plus the required-out-parameter nextPts make it more ceremony than most ComfyUI workflows justify. Know it exists, know it's a real Lucas–Kanade tracker, and reach for it when your graph actually does feature tracking.

Categoryimage/OpenCV

Inputs (11)

NameTypeDefaultDescription
prevImgNPARRAY
nextImgNPARRAY
prevPtsNPARRAY
nextPtsNPARRAY
winSizeSTRING
maxLevelINT
criteriaSTRING
flagsINT
minEigThresholdFLOAT
statusoptNPARRAY
erroptNPARRAY

Outputs (3)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY
nparray_2NPARRAY