OpenCV solvePnPRansac_1
SolvePnPRansac_1 — the RANSAC pose solver's duplicate twin
- objectPoints
- imagePoints
- cameraMatrix
- distCoeffs
- rvec
- tvec
- inliers
- bool
- nparray_1
- nparray_2
- nparray_3
Straight answer: solvePnPRansac_1 is solvePnPRansac_0 under a second name. The pack generates a node per overload in OpenCV's type stubs, and cv2.solvePnPRansac's long signature gets declared twice - once for MatLike and once for UMat - which the generator doesn't deduplicate. Both nodes call the identical function with the identical arguments. There is no behavioral difference. The display-name suffix is the only thing that changes.
If you landed here without reading the solvePnPRansac_0 page, that's the one with the full tutorial - the RANSAC knobs, the inlier output, the "why this beats plain solvePnP on messy detections" argument. This page covers the numbering so you don't go hunting for a difference that isn't there.
What it takes (same as its twin)
- objectPoints (NPARRAY) - 3D points, N×3.
- imagePoints (NPARRAY) - 2D projections, N×2.
- cameraMatrix (NPARRAY) - 3×3 intrinsics.
- distCoeffs (NPARRAY) - distortion coefficients.
- useExtrinsicGuess (BOOLEAN), iterationsCount (INT), reprojectionError (FLOAT), confidence (FLOAT), flags (INT) - the RANSAC and solver settings.
- Optional rvec / tvec / inliers out-parameters.
Outputs: bool (success), nparray_1 (rvec), nparray_2 (tvec), nparray_3 (inlier indices).
The defaults you'd start with are the same: flags = 0 (ITERATIVE), confidence = 0.99, reprojectionError tuned by pixel, iterationsCount in the hundreds.
Why this numbering confusion keeps happening
The README's development section is frank about it: the nodes are "auto-generated from source and so they are ugly and complex to use. Expect dragons!" Overloaded functions get numbered, near-duplicate overloads become near-duplicate nodes, and nobody goes back to clean them up. You'll see the same pattern on solvePnP, solvePnPRefineLM, solvePoly, sort, sortIdx, and spatialGradient in this pack. It's a feature of the generator, not a signal that one variant is "better" or "newer."
The practical pipeline
Everything here is nparray plumbing. The pack doesn't accept IMAGE directly - use Image2Nparray to get arrays and Nparrays2Image to get back to pixels, keep batch size at 1, and use cvtColor code 6 (BGR2GRAY) when a function needs a single channel. RANSAC is pointless on clean synthetic points, so feed it real detections - and watch the bool and the inlier count to know whether it's actually working.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
or ComfyUI Manager → "opencv-comfyui". Restart. opencv-contrib-python, numpy, torch - no weights to download.
Troubleshooting
Falseor a nearly-empty inliers array → too many bad matches orreprojectionErrortoo strict.- NaNs in the pose outputs → degenerate point set or wrong
flags. Cannot import name 'guidedFilter'→ conflicting OpenCV packages; README has the fix.
Use either node. The solver underneath is the same; the name is the only surprise.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| objectPoints | NPARRAY | — | |
| imagePoints | NPARRAY | — | |
| cameraMatrix | NPARRAY | — | |
| distCoeffs | NPARRAY | — | |
| useExtrinsicGuess | BOOLEAN | — | |
| iterationsCount | INT | — | |
| reprojectionError | FLOAT | — | |
| confidence | FLOAT | — | |
| flags | INT | — | |
| rvecopt | NPARRAY | — | |
| tvecopt | NPARRAY | — | |
| inliersopt | NPARRAY | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |
| nparray_1 | NPARRAY | — |
| nparray_2 | NPARRAY | — |
| nparray_3 | NPARRAY | — |