Nodes/opencv-comfyui/OpenCV sampsonDistance_1
ComfyUI Node

OpenCV sampsonDistance_1

The same geometric distance, UMat wrapper

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV sampsonDistance_1
  • pt1
  • pt2
  • F
  • float

sampsonDistance_1 is the UMat overload of cv2.sampsonDistance - which is pack-speak for "the same node, numbered twice because OpenCV's type stubs list every function once for numpy arrays and once for UMat." Inside ComfyUI you cannot tell them apart. Feed either one the same inputs and you get the same float out.

What it does

The actual job: compute the Sampson distance between a pair of corresponding points and a fundamental matrix - a cheap first-order measure of how badly the pair violates the epipolar constraint. It's the classic outlier test after computing F, the "should I trust this match" check for stereo and multi-view geometry. The real detail, including why you'd wire it after findFundamentalMat, lives in the sampsonDistance_0 article; nothing there changes for this variant.

Inputs and outputs

Inputs: pt1, pt2 (the two points, each an NPARRAY), and F (the 3×3 fundamental matrix). Output: one float. No optional inputs, no literal-typing pitfalls - one of the cleanest nodes the pack ships.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Install: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python (the pack's declared dependency; no models to download).

Verdict

The one thing worth internalizing about this pair and every _0/_1 pair in the pack: if a workflow you downloaded references sampsonDistance_1 and you grabbed sampsonDistance_0, they're interchangeable. Swap the class name in the JSON or just use the one you have. The duplication is an artifact of how the pack was generated, not a real choice you need to make.

Before you wire it, keep the shapes honest: pt1 and pt2 are single point arrays (2×1 or 1×2), and one call returns one scalar distance - this wrapper isn't a batch matcher, so for a pile of correspondences you're calling it per pair, typically inside an outlier-rejection loop rather than across a list at once.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
pt1NPARRAY
pt2NPARRAY
FNPARRAY

Outputs (1)

NameTypeDescription
floatFLOAT