Nodes/opencv-comfyui/OpenCV writeOpticalFlow_1
ComfyUI Node

OpenCV writeOpticalFlow_1

The second .flo writer overload — same file format, same two inputs

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV writeOpticalFlow_1
  • flow
  • bool
path

This is the _1 overload of cv2.writeOpticalFlow, and like every overloaded pair in this pack, writeOpticalFlow_1 and writeOpticalFlow_0 are functionally the same node. Same inputs, same .flo output, same bool return. If ComfyUI surfaced this one to you, use it - there's no meaningful difference to shop between them.

The function underneath is genuinely useful if you work with video motion. It serializes an optical flow field (a float32 2-channel NPARRAY where each pixel holds (dx, dy)) to the Middlebury .flo format - PIEH header, width, height, raw floats. That's the interchange format frame-interpolation tools, motion-analysis scripts, and academic toolkits actually read, so this node is your bridge from a ComfyUI pipeline out to the rest of the video ecosystem. You'd typically feed it the output of the pack's own calcOpticalFlowFarneback_0, computed between two frames.

Inputs and outputs

  • path - STRING filesystem path, e.g. /home/you/flow.flo. It's a plain text widget, not a folder picker - absolute paths, and the file is silently overwritten if it exists.
  • flow - the NPARRAY flow field: float32, 2 channels.
  • Output: bool - True on successful write. Informational.

The matching reader, readOpticalFlow_0, takes a .flo path and returns the flow as an NPARRAY, so you can round-trip flow through disk.

Installing

Pack-standard:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

or ComfyUI Manager, search "opencv-comfyui", install, restart. Dependencies: opencv-contrib-python, numpy, torch.

The one thing to get right

Dtype and channel count. .flo is a fixed binary layout - the writer assumes float32 2-channel input, and the format has no tolerance for anything else. Feed it an 8-bit or single-channel array and you'll get an error or a file other tools reject. Confirm your flow came out of calcOpticalFlowFarneback_0 (or an equivalent float32 2-channel source) and it just works. That's the whole node, honestly: two inputs, one path on disk, and a clean handoff to every frame-interpolation tool that speaks .flo.

Categoryimage/OpenCV

Inputs (2)

NameTypeDefaultDescription
pathSTRING
flowNPARRAY

Outputs (1)

NameTypeDescription
boolBOOLEAN