Nodes/opencv-comfyui/OpenCV correctMatches_0
ComfyUI Node

OpenCV correctMatches_0

CorrectMatches_0 — enforce the epipolar constraint on your point pairs

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV correctMatches_0
  • F
  • points1
  • points2
  • newPoints1
  • newPoints2
  • nparray_0
  • nparray_1

correctMatches_0 wraps cv2.correctMatches, and it's one of the least glamorous but most satisfying nodes in this pack: it takes two sets of matched points from two views of the same scene, plus the fundamental matrix F relating those views, and nudges the points so they actually satisfy the epipolar constraint. That's the geometric rule that a point in one image must lie on a specific line in the other - real matches obey it (in theory), sloppy matches don't. This node fixes the sloppiness.

Why would a ComfyUI user care? If you're doing anything with structure-from-motion, stereo reconstruction, or multi-view alignment - recovering 3D from a few frames, registering images shot from different angles - your downstream math is brutal about inconsistent point pairs. Triangulation, 3D reconstruction, and homography estimation all get measurably better when you feed them geometrically-consistent points first. It's the "clean your data before the solver" step, and it's the kind of deterministic primitive that belongs in a geometry stage, not anywhere near a sampler.

How it works

You give it:

  • F - a 3×3 fundamental matrix (from findFundamentalMat_0 in this pack, or findEssentialMat).
  • points1, points2 - the matched point coordinates from view 1 and view 2.

It returns two outputs: nparray_0 (corrected points1) and nparray_1 (corrected points2). The correction moves each point pair the minimum distance needed so that x2ᵀ·F·x1 = 0 holds within numerical tolerance. OpenCV treats the optional newPoints1/newPoints2 inputs as out-parameters - the pack exposes them as optional inputs you should simply leave unconnected, per the README's standing advice.

The inputs that matter

  • F - the 3×3 fundamental matrix. Must be float (usually float64). Wrong dtype is a classic silent breakage here.
  • points1, points2 - matched points, N×2 or N×1×2, float32. They must be pairs in the same order.

Outputs are corrected points of the same shape - data, not images. Don't feed them to Nparrays2Image.

Install

Part of opencv-comfyui (geroldmeisinger). ComfyUI Manager → search opencv-comfyui → install, or:

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

Restart. Needs opencv-contrib-python (+ numpy, torch). No model files.

Common issues

  • Outputs look unchanged → at low noise the corrections are sub-pixel. That's success, not a bug; compare numerically.
  • F from the wrong solvercorrectMatches assumes F is a true fundamental matrix. If you fed it an essential matrix or a homography, the geometry is wrong and the "corrections" are meaningless.
  • Dtype errors → keep F as float, points as float32.
  • _0 vs _1 → identical overload twins from the generator; pick either.

The pack is auto-generated and rough - "expect dragons" - but the underlying epipolar math is classical and exact. Get F right, feed matched pairs, and this is the most quietly reliable geometry node in the pack.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
FNPARRAY
points1NPARRAY
points2NPARRAY
newPoints1optNPARRAY
newPoints2optNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY