OpenCV sampsonDistance_0
The geometer's outlier detector
- pt1
- pt2
- F
- float
sampsonDistance_0 wraps cv2.sampsonDistance, and it's the sort of node that makes sense the moment you've done any stereo work and leaves everyone else scratching their head. In epipolar geometry, two matching points in two images and a fundamental matrix F are supposed to line up on an epipolar line. Real correspondences don't quite - they're off by some amount. The Sampson distance is a cheap, first-order approximation of exactly how far a point pair is from satisfying the epipolar constraint. Lower is better. Zero means perfect.
Where it fits
Where that earns a place in a workflow: after you've computed a fundamental matrix (or a homography for a planar scene), you'll want to throw out the bad matches before feeding them to anything downstream. A Sampson distance above some threshold marks a correspondence as garbage - this is the classic RANSAC-quality outlier test for stereo and structure-from-motion. If your ComfyUI graph is doing depth, camera pose, or multi-view reconstruction (the KB's depth-estimation doc covers that whole neighborhood), this is the cleanliness check between "I have matches" and "I can trust them."
Inputs and outputs
Inputs are all NPARRAY and all required: pt1 and pt2 are the two corresponding points (each a 2×1 or 1×2 array, or a set of points), and F is the 3×3 fundamental matrix. Output is a single float - the distance. There are no optional inputs here, no literal-typing traps, nothing to leave unwired; it's one of the cleanest nodes in the pack, which is a nice break from the composite-type dragons elsewhere.
Wiring it up
Because it needs a fundamental matrix, you can't just drop it into a random workflow - you need findFundamentalMat (also in this pack) upstream to produce F, and matched point pairs from a feature-matching or stereo step. Without those, the node has nothing meaningful to compute. And keep in mind the pack's standard plumbing: these are raw numpy NPARRAYs, and neither the points nor F are images, so don't route them into Nparrays2Image and expect a picture.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Install is the pack standard: ComfyUI Manager → search "opencv-comfyui", or the commands above, then pip install opencv-contrib-python for the dependency. No model downloads - pure computation.
Verdict
The _0/_1 pair is the MatLike/UMat overload thing; both behave identically from the UI. And a fair verdict: this is a deeply niche node. If you're doing stereo geometry in ComfyUI - a small, determined club - it's genuinely the right tool. If you're not, it's the one you'll never touch, and that's fine.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pt1 | NPARRAY | — | |
| pt2 | NPARRAY | — | |
| F | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| float | FLOAT | — |