Nodes/opencv-comfyui/OpenCV findEssentialMat_2
ComfyUI Node

OpenCV findEssentialMat_2

Essential matrix when you only know the focal length

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

OpenCV findEssentialMat_2 is the "I don't have a full camera calibration, but I know the focal length" version of the essential-matrix estimation. Same goal as findEssentialMat_1 - recover the rotation and translation between two camera views from matching points - but instead of feeding it a full 3x3 intrinsic matrix, you hand it two numbers: focal and pp.

That's the whole point of this variant. OpenCV builds a simplified camera matrix internally assuming a square pixel (fx = fy = focal) with the principal point pp sitting wherever you say. It's a legit shortcut for phone-camera and webcam work where you know the lens spec but never bothered with a checkerboard calibration, and it's the variant the OpenCV docs describe as findEssentialMat(points1, points2, focal, pp, ...).

Inputs

  • points1 / points2 - matching points across the two views, as NPARRAY (Nx1x2 or Nx2).
  • focal - focal length in pixels, a FLOAT. For most real lenses this is roughly image_width for a normal lens, more for telephoto. If you genuinely have no idea, start there and accept the result is approximate.
  • pp - the principal point, as a STRING composite literal. This is the one that trips people up: OpenCV expects a Point2d, and this pack passes composite types around as Python literals parsed with literal_eval. So you type it as (320, 240) - parentheses, comma, no quotes. A bare 320, 240 will throw an invalid syntax error.
  • method - 8 for RANSAC, the only mode you'll realistically use.
  • prob, threshold, maxIters - RANSAC tuning; the defaults are sensible, leave them alone.

The outputs are the same as the other essential-matrix nodes: nparray_0 is the 3x3 essential matrix, nparray_1 is the per-point inlier mask.

What it's actually for

If you're building a pose-estimation or camera-tracking workflow inside ComfyUI, _2 is a solid middle ground between "I have a full calibration matrix" (_1) and "I have nothing, give me the fundamental matrix" (findFundamentalMat). The tradeoff is real: the fx == fy, no-skew assumption is wrong for most real cameras, but for synthetic or game-capture frames it's often exactly right, since the renderer knows the lens.

Just remember the common trap across the whole pack: points and matrices flow as NPARRAY, not ComfyUI IMAGEs, and the output of this node is not a picture - it's geometry. Preview it and you'll get the 'NoneType' object has no attribute 'shape' error. Nparrays2Image is for turning actual image arrays back into viewable frames.

Install and gotchas

It lives in the geroldmeisinger/opencv-comfyui pack. Install via ComfyUI Manager (search opencv-comfyui) or:

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

then restart. requirements.txt installs opencv-contrib-python, numpy, and torch; the pack imports cv2 at startup, so a broken/conflicting OpenCV install means the whole pack won't load. If cvtColor says you need CV_8UC1, your image isn't grayscale - convert with code 6 first.

Note findEssentialMat_3 is byte-for-byte the same node (OpenCV's type stubs declare every function twice, once for MatLike and once for UMat, and the generator emits both). Pick either; _2 is the one people usually reach for.

Categoryimage/OpenCV

Inputs (9)

NameTypeDefaultDescription
points1NPARRAY
points2NPARRAY
focalFLOAT
ppSTRING
methodINT
probFLOAT
thresholdFLOAT
maxItersINT
maskoptNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY