Nodes/opencv-comfyui/OpenCV validateDisparity_1
ComfyUI Node

OpenCV validateDisparity_1

Same stereo validator, second overload — same inputs, same caveats

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV validateDisparity_1
  • disparity
  • cost
  • nparray
minDisparity
numberOfDisparities
disp12MaxDisp

This is the _1 overload of OpenCV's validateDisparity, and here's the thing you should know before you spend any time on it: in this pack, validateDisparity_0 and validateDisparity_1 are functionally identical. Same inputs, same behavior, same single output. The pack's generator numbered overloads from OpenCV's type stubs, and for this function the two overloads collapsed into the same call. Pick whichever one ComfyUI shows you and move on with your life.

What the node does is worth understanding, though, because it's the least-glamorous but most-important step in a stereo pipeline. Stereo matching hands you a disparity map that's full of wrong pixels - occlusions, textureless patches, regions where the matcher just picked a plausible-but-false shift. validateDisparity cleans that up: it takes the disparity map and its matching cost volume, runs a left-right consistency check with disp12MaxDisp as the tolerance, and resets bad pixels to minDisparity so downstream 3D reconstruction doesn't build geometry from hallucinated matches.

Inputs and outputs

The schema is the whole story:

  • disparity - raw disparity map (NPARRAY).
  • cost - the matching cost volume (NPARRAY).
  • minDisparity, numberOfDisparities - must match the values used when the matcher was created.
  • disp12MaxDisp - tolerance for the left-right check.

Output: one nparray - the validated disparity map.

The caveat that matters

The pack wraps standalone cv2 functions, and StereoBM/StereoSGBM are classes - so they're not here. You can validate a disparity map in ComfyUI, but this pack can't produce one for you. You'd bring disparity and cost in from a script node, a different pack, or a precomputed file. That's a real gap, and it means these two nodes sit in the "for people already doing stereo elsewhere" pile rather than the "quick win" pile.

Installing

Same as every node in the pack. ComfyUI Manager, search "opencv-comfyui", install, restart:

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

Dependencies are opencv-contrib-python, numpy, torch. And the same environment gotcha applies pack-wide: if you see Cannot import name 'guidedFilter' from 'cv2.ximgproc', you've got conflicting OpenCV installs and should fix that before debugging anything else.

Bottom line

If you found validateDisparity_1 first and wondered whether you grabbed the wrong node - you didn't. It's the twin of validateDisparity_0. Use the one that's in your graph, keep minDisparity and numberOfDisparities consistent with your matcher, and remember the real bottleneck is feeding it a disparity map at all.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
disparityNPARRAY
costNPARRAY
minDisparityINT
numberOfDisparitiesINT
disp12MaxDispINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY