Nodes/opencv-comfyui/OpenCV findEssentialMat_1
ComfyUI Node

OpenCV findEssentialMat_1

Find how two camera views relate — cv2.findEssentialMat without the pain

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV findEssentialMat_1
  • points1
  • points2
  • cameraMatrix
  • mask
  • nparray_0
  • nparray_1
method
prob
threshold
maxIters

If your workflow ever needs to know "how did the camera move between these two frames," this is the node. The essential matrix E is a 3x3 matrix that encodes the rotation and translation between two camera poses - it's the heart of structure-from-motion, pose estimation, and a lot of 3D-from-2D work. OpenCV findEssentialMat_1 is the ComfyUI wrapper around cv2.findEssentialMat, and it's the variant you want when you have a real camera matrix.

First, the honest setup. This pack (opencv-comfyui) auto-generates a node for almost every top-level OpenCV function, straight from the cv2 type stubs. That means the nodes are ugly, the parameters are raw OpenCV enums, and the author's own README opens with "Expect dragons!" - but the underlying machinery is battle-tested OpenCV, so once you get past the plumbing it just works.

How it works

You give it two lists of matching points (points1, points2) - the same physical scene point seen in both views - plus the camera's intrinsic matrix. OpenCV runs RANSAC over the correspondences and hands back two things:

  • nparray_0 - the essential matrix E (3x3), which encodes rotation + translation up to scale.
  • nparray_1 - an inlier mask, one value per input point, marking which matches survived RANSAC.

The essential matrix is a calibrated beast: it works in normalized image coordinates, so it needs the camera matrix to map pixels into camera space. If you don't have calibration, that's what findFundamentalMat is for (raw pixels, no intrinsics needed).

The inputs that matter

Most of these are raw OpenCV parameters, but a beginner only touches a few:

  • points1 / points2 - NPARRAY of corresponding points, shape Nx1x2 or Nx2. This is the hard part, more on that below.
  • cameraMatrix - your 3x3 intrinsic matrix as an NPARRAY. Focal lengths on the diagonal, principal point at [0][2], [1][2].
  • method - the RANSAC method enum as an int. 8 is RANSAC, which is what you want when your matches have outliers (they always do). Leave the defaults on prob (confidence, 0.999), threshold (1.0), and maxIters (1000) unless you're tuning.
  • mask - optional, lets you force certain matches in or out.

Where people get stuck

Getting the points is the real job. The node takes already-matched correspondences, but matching features across two views is a two-step dance (detect → match), and the pack generates top-level functions only - feature matchers like BFMatcher and the SIFT/ORB classes were skipped because they're classes, not functions. In practice you either chain goodFeaturesToTrack or chessboard detection from this same pack and hand-build the pairs, or you compute matches in a separate step and feed the arrays in.

Also: both outputs are NPARRAY, and neither is an image. E is a 3x3 float matrix. Wire it into Nparrays2Image and you'll get the classic 'NoneType' object has no attribute 'shape' error, because OpenCV isn't handing you a picture. That's not a bug - check the OpenCV docs for what the function actually returns.

Installing

In ComfyUI Manager, search opencv-comfyui, install, restart. Or the manual way:

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

Then restart ComfyUI. The pack's requirements.txt pulls in opencv-contrib-python, numpy, and torch. The contrib flavor matters, and the pack does import cv2 at load time - if OpenCV isn't importable, the whole pack fails to register. If you hit Cannot import name 'guidedFilter' from 'cv2.ximgproc', you have conflicting OpenCV installs fighting each other; clean up the duplicates and it settles down.

Verdict

Reach for _1 (or its twin _0) when you have a calibrated camera and need rotation/translation between views. If you only know focal length, use _2/_3; if you have two different calibrated cameras, _4/_5. No camera info at all? findFundamentalMat is your friend instead. Don't expect pretty pictures out of this node - expect numbers, and that's exactly what a pose-estimation workflow needs.

Categoryimage/OpenCV

Inputs (8)

NameTypeDefaultDescription
points1NPARRAY
points2NPARRAY
cameraMatrixNPARRAY
methodINT
probFLOAT
thresholdFLOAT
maxItersINT
maskoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY