OpenCV solvePnPRefineVVS_1
SolvePnPRefineVVS_1 — the virtual-servoing refiner's duplicate
- objectPoints
- imagePoints
- cameraMatrix
- distCoeffs
- rvec
- tvec
- nparray_0
- nparray_1
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) -
TermCriteriaas a tuple literal parsed withast.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 thecriteriatuple 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.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| objectPoints | NPARRAY | — | |
| imagePoints | NPARRAY | — | |
| cameraMatrix | NPARRAY | — | |
| distCoeffs | NPARRAY | — | |
| rvec | NPARRAY | — | |
| tvec | NPARRAY | — | |
| criteria | STRING | — | |
| VVSlambda | FLOAT | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |