Nodes/opencv-comfyui/OpenCV findEssentialMat_4
ComfyUI Node

OpenCV findEssentialMat_4

Essential matrix for two different calibrated cameras

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV findEssentialMat_4
  • points1
  • points2
  • cameraMatrix1
  • distCoeffs1
  • cameraMatrix2
  • distCoeffs2
  • mask
  • nparray_0
  • nparray_1
method
prob
threshold

Most essential-matrix code assumes both views came from the same camera. OpenCV findEssentialMat_4 is the version for when that's a lie - when the left view and right view were shot with different cameras, or when the same camera changed lenses, so each side needs its own intrinsic matrix and its own distortion coefficients.

Under the hood it calls cv2.findEssentialMat(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, method, prob, threshold, mask). OpenCV undistorts each side with its own coefficients, maps both into normalized camera coordinates, then runs RANSAC to estimate the essential matrix E. The full five-parameter distortion vector (k1, k2, p1, p2, k3) is the standard here - if your lens is mild, you can pass a small vector and let it do its thing.

Inputs that matter

  • points1 / points2 - matching points across the two views (NPARRAY, Nx1x2 or Nx2).
  • cameraMatrix1 / cameraMatrix2 - a 3x3 intrinsic matrix for each camera, as NPARRAYs. Same shape as _1's single cameraMatrix, just twice of them.
  • distCoeffs1 / distCoeffs2 - the distortion vectors. These are NPARRAYs too, typically 4 or 5 floats. If your cameras are distortion-free (synthetic renders, some game captures), an empty or zero vector works.
  • method - 8 for RANSAC. Keep the defaults on prob and threshold.

Outputs: nparray_0 is the 3x3 essential matrix, nparray_1 is the inlier mask. As with every geometry node in this pack, neither output is an image - trying to preview them via Nparrays2Image gives the familiar 'NoneType' object has no attribute 'shape' error, because OpenCV is returning matrices, not frames.

When you'd actually use this

Honestly? Rarely, in a ComfyUI context. Single-camera essential-matrix work (_1 or _2) covers most pose and motion workflows, and true stereo rigs with two separately-calibrated cameras are a niche in the image-generation world. This node exists because the generator wraps every OpenCV overload, not because it's a common need - think depth-from-stereo pipelines and multi-camera capture setups.

If you do have two calibrated cameras and both intrinsic matrices handy, this is the mathematically correct tool and it will beat the single-matrix versions. Just be prepared for the input count: six NPARRAYs before you even get to the RANSAC knobs, all flowing as numpy arrays rather than ComfyUI images.

Install

Same pack, same routine. ComfyUI Manager → search opencv-comfyui → install → restart, or:

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

requirements.txt installs opencv-contrib-python, numpy, torch. The pack needs a working cv2 import at startup - a conflicting or missing OpenCV install means the entire pack fails to register, and you'll often see the Cannot import name 'guidedFilter' error pointing at a duplicate-package fight.

Note findEssentialMat_5 is the byte-identical UMat twin of _4. Same signature, same behavior. Pick whichever your workflow references; they're interchangeable on the canvas.

Categoryimage/OpenCV

Inputs (10)

NameTypeDefaultDescription
points1NPARRAY
points2NPARRAY
cameraMatrix1NPARRAY
distCoeffs1NPARRAY
cameraMatrix2NPARRAY
distCoeffs2NPARRAY
methodINT
probFLOAT
thresholdFLOAT
maskoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY