OpenCV findEssentialMat_4
Essential matrix for two different calibrated cameras
- points1
- points2
- cameraMatrix1
- distCoeffs1
- cameraMatrix2
- distCoeffs2
- mask
- nparray_0
- nparray_1
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,Nx1x2orNx2).cameraMatrix1/cameraMatrix2- a 3x3 intrinsic matrix for each camera, asNPARRAYs. Same shape as_1's singlecameraMatrix, just twice of them.distCoeffs1/distCoeffs2- the distortion vectors. These areNPARRAYs too, typically 4 or 5 floats. If your cameras are distortion-free (synthetic renders, some game captures), an empty or zero vector works.method-8for RANSAC. Keep the defaults onprobandthreshold.
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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| points1 | NPARRAY | — | |
| points2 | NPARRAY | — | |
| cameraMatrix1 | NPARRAY | — | |
| distCoeffs1 | NPARRAY | — | |
| cameraMatrix2 | NPARRAY | — | |
| distCoeffs2 | NPARRAY | — | |
| method | INT | — | |
| prob | FLOAT | — | |
| threshold | FLOAT | — | |
| maskopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |