CV Optical Flow Flags
Set your optical-flow flags once, then fan them out to every flow node in the graph
- flags
- value
This is a plumbing node and it's proud of it. The raw cv2_calcOpticalFlowPyrLK and cv2_calcOpticalFlowFarneback wrappers in this pack take a flags value - an integer built by OR-ing together cv2 constants like OPTFLOW_USE_INITIAL_FLOW. Type that integer by hand in three places and the first time you change one you've got a graph with two different ideas about how flow should work. CV Optical Flow Flags authors that value once and hands it to as many consumers as you like.
This is the same "one source, many consumers" pattern the rest of ComfyUI's plumbing layer exists for - a seed feeding five samplers, a primitive feeding every converted widget. The flags are exactly that kind of value: one authoritative setting that several nodes must agree on.
How it works
The flags input is a STRING, but in the UI it renders as a base dropdown with a toggle per flag (the pack ships a frontend widget for this). You get a pipe-joined list like none (0) | OPTFLOW_USE_INITIAL_FLOW, and each toggle ORs one bit into the result. The node validates the constant names against the OpenCV build you actually have, so a typo is a loud error rather than a wrong number silently flowing downstream.
The two outputs are the same value in two formats. flags (STRING) goes into the flags input of a cv2_calcOpticalFlowPyrLK or cv2_calcOpticalFlowFarneback node - note that this only works on those raw wrappers, not on the curated flow nodes (DIS, TV-L1, RLOF, Farneback-as-a-node), which build their own parameter objects and expose named widgets instead. value (INT) is the resolved integer, for a raw int flag parameter somewhere else or for a Math Expression node.
One thing to know before you set toggles at random: each function ignores the other's bit. LK_GET_MIN_EIGENVALS is PyrLK-only, FARNEBACK_GAUSSIAN is Farneback-only. Setting both isn't conflicting, it's just two settings that each apply to half the graph.
Install
Same as the rest of the pack. In ComfyUI Manager, search ComfyUI CV; manually:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
cd comfyui_cv && pip install "opencv-contrib-python-headless~=5.0.0.93"
Restart. Python ≥ 3.12 and the V3 node API are hard requirements, and the flag names are resolved against your installed OpenCV, so a build missing a constant will reject it by name. The pack declares the headless contrib wheel, but a non-headless contrib build works fine too - what does not work is a non-contrib wheel, which empties the contrib submodules and takes a chunk of this pack's nodes with it.
Common issues
- "unknown flag" on a name that's obviously real - your OpenCV build doesn't expose it. Check the version; the pack is curated against
5.0.0.93. - The widget shows the flags as readable text instead of toggles - the pack's frontend JS didn't load. Hard-refresh the browser; a stale
web/cache is the usual cause. - You wired
flagsinto a curated flow node and it won't connect - right, by design. Only the generatedcv2_*wrappers take this socket.
Worth remembering that this pack carries ~470 auto-generated raw cv2 wrappers and treats them as uncurated: you're expected to know the flag you want. This node is the pack's admission that typing raw integers is a bad interface, and its answer is to make you type them exactly once.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| flags | STRING | none (0) | Pipe-joined cv2 constant names, e.g. "none (0) | OPTFLOW_USE_INITIAL_FLOW". In the UI this renders as a base dropdown with one toggle per flag. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| flags | STRING | The pipe-joined flags string - wire it into the flags input of cv2_calcOpticalFlowPyrLK / cv2_calcOpticalFlowFarneback nodes. |
| value | INT | The resolved integer (constants OR-ed together). |