OpenCV initUndistortRectifyMap_1
InitUndistortRectifyMap_1 — the identical twin of the calibration map builder
- cameraMatrix
- distCoeffs
- R
- newCameraMatrix
- map1
- map2
- nparray_0
- nparray_1
The short version, before anything else: initUndistortRectifyMap_1 and initUndistortRectifyMap_0 are the same node. This pack generates one class per OpenCV function overload, numbered _0, _1, and when the overloads are duplicates - as they are here - you get two identical wrappers around cv2.initUndistortRectifyMap. Same inputs, same outputs, same behavior. There's no reason to prefer one; if this page is your first stop, the companion article on initUndistortRectifyMap_0 has the full story.
Which is, in one paragraph: this node builds the remap tables that correct lens distortion in calibrated photographs. It takes the camera intrinsics (cameraMatrix), the distortion coefficients (distCoeffs), a rectification matrix (R, identity if unused), an adjusted camera matrix (newCameraMatrix), an output size (as a Python literal like (1920, 1080)), and a m1type (5 = CV_32FC1 for precision, 3 = CV_16SC2 for speed). It produces two maps that you feed into remap_0, which does the actual per-frame correction. It's the setup half of a camera-calibration pipeline - the kind of thing you build once per camera and reuse on every frame.
A candid gate for beginners. This node only makes sense if you have real calibration data, which comes from cv2.calibrateCamera on a photographed checkerboard. If you don't have a camera matrix and distortion vector, there's nothing here to work with - this is not an auto-fix node, and nothing in ComfyUI generates those matrices for you. If you're here because you saw "undistort" and hoped to straighten a slightly warped image, stop: this is the wrong tool, and the math behind it assumes an actual calibrated camera.
Inputs/outputs. cameraMatrix, distCoeffs, R, newCameraMatrix (NPARRAY), size (STRING), m1type (INT). Optional map1/map2 are out-parameters to leave unwired. Outputs are two NPARRAYs - nparray_0 (map1) and nparray_1 (map2) - that plug into remap_0.
Installing. ComfyUI Manager → search "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
Restart ComfyUI; the node is under image/OpenCV.
Where people get burned. size must be a valid Python tuple literal - (1920, 1080) - or the pack's parser raises the invalid syntax error. Wrong-shaped matrices produce OpenCV assertion errors with terse messages. And don't overthink the _0/_1 choice: it doesn't exist. Either node is the same function.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| cameraMatrix | NPARRAY | — | |
| distCoeffs | NPARRAY | — | |
| R | NPARRAY | — | |
| newCameraMatrix | NPARRAY | — | |
| size | STRING | — | |
| m1type | INT | — | |
| map1opt | NPARRAY | — | |
| map2opt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |