ComfyUI Node
CV Stereo Disparity (SGBM)
Per-pixel disparity from a RECTIFIED stereo pair (cv2.StereoSGBM): how far each point shifts between the left and right view - inversely proportional to depth. StereoSGBM is a cv2 class the raw wrappers cannot expose, so this node manages it: both frames are grayscaled, the P1/P2 smoothness terms are derived from block_size (OpenCV's documented heuristic) and the int16 result is converted to float disparity in pixels. The pair MUST be rectified (epipolar lines horizontal) - run cv2.stereoRectify + initUndistortRectifyMap + cv2.remap first. Preview the disparity with 'Preview CV Array' (normalize / heatmap); larger disparity = closer.
CV Stereo Disparity (SGBM)
- left
- right
- disparity
- valid
◄num_disparities64►
◄block_size7►
◄min_disparity0►
◄modeSGBM (balanced)►
◄uniqueness_ratio10►
◄speckle_window_size100►
◄speckle_range2►
◄disp12_max_diff-1►
Categoryimage/CV/features
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| left | NPARRAY,IMAGE | Left rectified frame (grayscaled internally). Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| right | NPARRAY,IMAGE | Right rectified frame; resized to left if sizes differ. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| num_disparities | INT | 6416–512 | Disparity search range (0..num_disparities), rounded up to a multiple of 16. Larger covers nearer objects / wider baselines but is slower. |
| block_size | INT | 71–21 | Matched block size in pixels (forced odd; 3-11 is typical). Smaller = more detail but noisier. |
| min_disparity | INT | 0-256–256 | Smallest disparity to search from (usually 0). |
| mode | COMBO | SGBM (balanced) | SGBM is the standard; 3-way is faster at lower quality; HH runs the full-scale two-pass (best, slowest). |
| uniqueness_ratioopt | INT | 100–100 | Margin (%) by which the best match must beat the runner-up to be accepted. |
| speckle_window_sizeopt | INT | 1000–1000 | Largest smooth disparity blob treated as speckle noise and invalidated (0 = off). |
| speckle_rangeopt | INT | 20–64 | Max disparity variation within a speckle component. |
| disp12_max_diffopt | INT | -1-1–64 | Left-right consistency check, in pixels: a match whose reverse match disagrees by more than this is invalidated. -1 (cv2's default) turns it off and leaves occlusion junk in the map; 1 is the usual setting when the disparity is about to be interpolated or turned into 3D points. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| disparity | NPARRAY | HxW float32 disparity in pixels; invalid pixels are below min_disparity (see 'valid'). |
| valid | NPARRAY | uint8 0/255 mask of pixels with a valid disparity. |