OpenCV undistortPointsIter_0
The same lens math, with an iteration budget
- src
- cameraMatrix
- distCoeffs
- R
- P
- dst
- nparray
cv2.undistortPointsIter is the iterative, more controllable cousin of undistortPoints. Same job - take a list of 2D feature points and correct them for lens distortion using the camera's intrinsics - but instead of a one-shot solve it runs an iterative refinement loop, and you get to say when it stops. That buys you a bit more accuracy at the cost of a little more setup, and for most people the answer is "just use undistortPoints." The Iter variant is for the calibration crowd who want the iteration parameters explicit, or who are pushing against the accuracy limits of the plain version on badly distorted optics.
And realistically? If you're in a ComfyUI graph and you need this node, you're doing camera-calibration-grade geometry - feature points from real photos, intrinsics from a checkerboard routine, downstream math that needs honest coordinates. It's a specialist's tool in a pack that auto-generated every top-level OpenCV function, and it's present because completeness, not popularity, is the pack's whole deal.
Inputs and outputs that matter
- src (NPARRAY) - the input points, N×2 or N×1×2 coordinates, not an image.
- cameraMatrix (NPARRAY) - the 3×3 intrinsics matrix.
- distCoeffs (NPARRAY) - the distortion coefficients.
- R (NPARRAY) - the rectification matrix. Unlike the plain variant's optional
R, here it's required, so you'll need to supply an identity-like matrix if you have no rectification. - P (NPARRAY) - the new camera matrix for reprojection.
- criteria (STRING) - the iteration stop condition, and the one input that will bite you. It's a composite OpenCV
TermCriteriaentered as a Python literal:(type, max_iter, epsilon). A sensible start is(3, 30, 0.01)- type3meaning count+epsilon (stop after 30 iterations or when the correction moves less than 0.01), which is what OpenCV's own docs suggest. Malformed syntax throws the pack-wideinvalid syntax (<unknown>, line 0).
The optional dst is an out-parameter - leave it unwired. Output is one nparray of corrected points.
Installation
Pack-wide: ComfyUI Manager (search "OpenCV" or geroldmeisinger/opencv-comfyui), or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Needs opencv-contrib-python (pip install opencv-contrib-python). No models.
Common issues
Three failure modes matter here. First, the criteria literal: it must be valid Python, so (3, 30, 0.01) works and 3 30 0.01 throws invalid syntax. Second, shape discipline: src is a points array, and R/P/cameraMatrix have fixed shapes - an OpenCV assertion error means one of them is off. Third, the pack-wide rules: NPARRAY only, batch size 1, Image2Nparray/Nparrays2Image at the edges, and the output is coordinates, not a viewable image. If you don't specifically need the iteration control, the plain undistortPoints node will treat you more gently.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| cameraMatrix | NPARRAY | — | |
| distCoeffs | NPARRAY | — | |
| R | NPARRAY | — | |
| P | NPARRAY | — | |
| criteria | STRING | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |