Nodes/opencv-comfyui/OpenCV readOpticalFlow_0
ComfyUI Node

OpenCV readOpticalFlow_0

Load a .flo optical-flow file straight into your graph

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV readOpticalFlow_0
    • nparray
    path

    readOpticalFlow loads a precomputed optical-flow field from disk and drops it into your graph as a numpy array. Optical flow is the "who moved where between frame A and frame B" data - for every pixel you get a (u, v) displacement vector. If you're doing video or animation work, that's genuinely interesting stuff: warping frames along a flow field is how a lot of interpolation and motion-transfer pipelines work. This node reads the Middlebury .flo format, the standard on-disk encoding for flow fields, and hands you a two-channel float array.

    A note on scope, because it matters: this node doesn't compute flow. It reads a file. To compute flow between two frames you'd need OpenCV's calcOpticalFlowFarneback or a learned method, and those aren't in this pack. So readOpticalFlow is the input side of a motion-data pipeline - either you produced a .flo elsewhere (Python script, another tool) and want it in the graph, or you skip this node entirely.

    The one input

    • path - a plain STRING file path to a .flo file on disk, e.g. C:\flows\frame_0001.flo or /home/you/flows/out.flo. This is a filesystem path, not a ComfyUI file input widget - you type the path, and the node loads it at execution time.

    The output nparray is an H×W×2 float32 array of (u, v) displacements. That's not an image, and here's the practical trap: this pack's Nparrays2Image converter expects 1, 2, or 3 channels and will happily try to convert a 2-channel float array - the README specifically warns about the 'NoneType' object has no attribute 'shape' error you get when you feed a non-image array to the image converter. A raw flow field isn't viewable without being visualized as colors or arrows first (that conversion isn't in this pack either). So plan the pipeline: read the flow, use it mathematically (warp, analyze), and only convert to something visible if you've turned it into a proper image yourself.

    Gotchas

    • If the path is wrong or the file isn't a valid .flo, the node fails at execution - there's no graceful "file not found" widget state.
    • .flo is a specific binary format (Middlebury). Generic motion-vector files from other tools won't load; check what your exporter writes.
    • batch_size==1 rules still apply on the output side.

    Install

    Nothing special - this pack is wrappers over OpenCV, no models:

    cd ComfyUI/custom_nodes
    git clone https://github.com/geroldmeisinger/opencv-comfyui
    pip install opencv-contrib-python
    

    Or search "OpenCV" in ComfyUI Manager, restart, look under image/OpenCV. If you hit Cannot import name 'guidedFilter' from 'cv2.ximgproc' at load, that's conflicting OpenCV installs - known issue, fix in the README.

    Bottom line: this is a niche-but-legit node for people already working with flow data, and a confusing dead end for everyone else. Know what a .flo file is before you reach for it.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    nparrayNPARRAY