OpenCV getValidDisparityROI_0
The stereo node whose partners don't ship in the pack
- literal
If you're building stereo depth pipelines, getValidDisparityROI_0 is a real OpenCV utility with a narrow, specific job: after stereo matching, it computes which region of the disparity map is actually reliable. It's the function that tells you "your left/right camera ROIs overlap usefully in this rectangle - crop to that." But here's the twist with this particular wrapper: the pack that ships it doesn't ship the stereo matchers that produce disparity maps in the first place. So this node is a part with no assembly.
What it computes
Wrapped cv2.getValidDisparityROI, its inputs map to a StereoBM/StereoSGBM setup:
- roi1 and roi2 (
STRING): the valid ROIs of the left and right images as Python literals,(x, y, width, height). - minDisparity (
INT): the smallest disparity the matcher used. - numberOfDisparities (
INT): the disparity range (must be a multiple of 16 - a classic StereoBM constraint). - blockSize (
INT): the block size you passed to the matcher.
The output is one literal (STRING): the valid ROI as a text tuple, e.g. (64, 32, 180, 220). It's a Rect returned as a string because the pack represents composite types as Python literals - so don't expect an image out. It's metadata about the disparity result, meant to feed downstream cropping.
The gap that makes it awkward
Here's the honest problem: StereoBM and StereoSGBM are classes, and this pack deliberately only wraps top-level standalone functions - the README says classes don't fit the ComfyUI style and are on the "todo" list. No classes means no stereo matcher node in the pack. To make getValidDisparityROI_0 useful you'd need a disparity map from elsewhere: another custom node pack that computes stereo depth, or your own nparray pipeline. If you've got that, this node is a tidy way to get the valid region for cropping. If you don't, it's a set of five inputs waiting for data that never arrives.
Install & troubleshooting
Same pack, same drill:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or ComfyUI Manager (search "opencv-comfyui"), then restart. Needs opencv-contrib-python plus the numpy/torch ComfyUI already has - no models, no keys. Watch the literal-string rule: roi1 and roi2 must be valid tuple syntax, (10, 10, 640, 480), or you get the pack's invalid syntax (<unknown>, line 0) error. And mind the numberOfDisparities multiple-of-16 constraint - OpenCV asserts on it.
The take
Reach for this only if you're already neck-deep in stereo depth work in ComfyUI - a tiny audience, honestly. For the rest of the graph, it's a well-behaved but pointless box: accurate to OpenCV, orphaned by the pack's own class policy. If the author ever ships class nodes, StereoBM → getValidDisparityROI becomes a real chain. Until then, know what it is, and don't build your workflow around it.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| roi1 | STRING | — | |
| roi2 | STRING | — | |
| minDisparity | INT | — | |
| numberOfDisparities | INT | — | |
| blockSize | INT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| literal | STRING | — |