Nodes/opencv-comfyui/OpenCV solvePnP_1
ComfyUI Node

OpenCV solvePnP_1

SolvePnP_1 — the same pose solver, from the duplicate overload

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV solvePnP_1
  • objectPoints
  • imagePoints
  • cameraMatrix
  • distCoeffs
  • rvec
  • tvec
  • bool
  • nparray_1
  • nparray_2
useExtrinsicGuess
flags

Quick answer so you don't waste the afternoon: solvePnP_1 and solvePnP_0 are the same node. The opencv-comfyui pack parses OpenCV's type stubs and generates one node per overload, and cv2.solvePnP's (objectPoints, imagePoints, cameraMatrix, distCoeffs, rvec, tvec, useExtrinsicGuess, flags) signature is declared twice in slightly different forms - so you get a _0 and a _1 with identical schemas and identical behavior. Display name "OpenCV solvePnP_1" versus "OpenCV solvePnP_0" is the entire difference.

For the full explanation of PnP - what it solves, how to set up the camera matrix, which flags value to start with - read the solvePnP_0 article. This page is the short version: use either node.

What it takes

The inputs, unchanged:

  • objectPoints (NPARRAY) - known 3D points, N×3.
  • imagePoints (NPARRAY) - their 2D projections, N×2.
  • cameraMatrix (NPARRAY) - 3×3 intrinsic matrix.
  • distCoeffs (NPARRAY) - distortion coefficients; zeros means none.
  • useExtrinsicGuess (BOOLEAN) - false unless you're refining a known pose.
  • flags (INT) - OpenCV solver enum; 0 (ITERATIVE) is the safe start.
  • rvec / tvec (optional NPARRAY) - out-parameters / initial guesses.

Outputs: bool (success - check it), nparray_1 (rvec), nparray_2 (tvec).

Why the numbering exists at all

The pack's README explains the whole design: functions are extracted from cv2/__init__.pyi with ast.parse(), "most functions are overloaded and they were numbered." When OpenCV declares the same overload twice (which it does - the .pyi often lists the MatLike and UMat variants separately, plus near-identical re-statements), the generator doesn't deduplicate. You get _0 and _1 that are twins. It's not a bug, it's the cost of automation, and it's the same story across solvePnPRefineLM, sort, sortIdx and friends in this pack.

So there is no "which one is better" decision here. Grab whichever ComfyUI's search bar offers first and move on.

The practical bits still apply

Everything about wiring is pack-standard: this node eats and spits NPARRAY, not IMAGE. Convert with Image2Nparray in, Nparrays2Image out, keep batch size at 1, and remember the cvtColor codes from the README (6 = BGR2GRAY, 8 = GRAY2BGR) if you hit a CV_8UC1 assertion error.

Install

One pack, one install:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

(Or ComfyUI Manager → "opencv-comfyui"). Restart. Dependencies: opencv-contrib-python, numpy, torch - no downloads.

Troubleshooting

  • bool output False → pose solve failed; check point counts and the camera matrix.
  • NaNs in rvec/tvec → degenerate 3D points or a bad flags; try 0.
  • guidedFilter import error at startup → conflicting OpenCV packages; README links the fix.

One node, two names. If you understand solvePnP_0, you understand this one completely.

Categoryimage/OpenCV

Inputs (8)

NameTypeDefaultDescription
objectPointsNPARRAY
imagePointsNPARRAY
cameraMatrixNPARRAY
distCoeffsNPARRAY
useExtrinsicGuessBOOLEAN
flagsINT
rvecoptNPARRAY
tvecoptNPARRAY

Outputs (3)

NameTypeDescription
boolBOOLEAN
nparray_1NPARRAY
nparray_2NPARRAY