Nodes/opencv-comfyui/OpenCV solvePnPRefineVVS_1
ComfyUI Node

OpenCV solvePnPRefineVVS_1

SolvePnPRefineVVS_1 — the virtual-servoing refiner's duplicate

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV solvePnPRefineVVS_1
  • objectPoints
  • imagePoints
  • cameraMatrix
  • distCoeffs
  • rvec
  • tvec
  • nparray_0
  • nparray_1
criteria
VVSlambda

You know the drill by now if you've been in this pack for more than a page: solvePnPRefineVVS_1 is solvePnPRefineVVS_0 under a second auto-generated name. Same overload, same schema, same behavior, different suffix. OpenCV's stubs declare cv2.solvePnPRefineVVS in two forms, the generator numbers them, and you get a pair of interchangeable nodes. There is no "better" one; there isn't even a different one.

The actual content lives in the solvePnPRefineVVS_0 article - what Virtual Visual Servoing does, how to tune VVSlambda, how to write the criteria literal. This page is the duplicate's duplicate reference.

What it takes

  • objectPoints, imagePoints, cameraMatrix, distCoeffs (NPARRAY) - the PnP correspondence set.
  • rvec, tvec (NPARRAY) - the initial pose being refined.
  • criteria (STRING) - TermCriteria as a tuple literal parsed with ast.literal_eval; e.g. (3, 100, 1e-6).
  • VVSlambda (FLOAT) - the servoing gain; tune around 0.5–2 if the refinement oscillates.

Outputs: nparray_0 (rvec), nparray_1 (tvec).

The two real gotchas

First, the criteria string. Composite OpenCV types become literal strings in this pack, and TermCriteria is where you'll actually hit it. invalid syntax (<unknown>, line 0) is the pack-wide error for a malformed literal - make sure criteria is a genuine Python tuple, commas and all.

Second, VVSlambda. Unlike LM refinement, this method has a gain knob that can misbehave. Crank it too high and the virtual camera overshoots; too low and refinement crawls. If your refined pose is jittery or blowing up between runs, this is the first input to touch.

And a reminder that applies to every refinement node here: it polishes, it doesn't rescue. No success flag, so trust the upstream solvePnP's bool before you bet on the output. All nparray plumbing - Image2Nparray in, Nparrays2Image out, batch size 1, cvtColor code 6 for single-channel needs.

Install

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

or ComfyUI Manager → "opencv-comfyui". Restart. Deps: opencv-contrib-python, numpy, torch - no downloads.

Troubleshooting

  • invalid syntax (<unknown>, line 0) → fix the criteria tuple literal.
  • Oscillating pose → lower VVSlambda.
  • Cannot import name 'guidedFilter' at startup → conflicting OpenCV packages; README links the fix.

Same node, second name. If the _0 page made sense, you're done here.

Categoryimage/OpenCV

Inputs (8)

NameTypeDefaultDescription
objectPointsNPARRAY
imagePointsNPARRAY
cameraMatrixNPARRAY
distCoeffsNPARRAY
rvecNPARRAY
tvecNPARRAY
criteriaSTRING
VVSlambdaFLOAT

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY