Nodes/opencv-comfyui/OpenCV initInverseRectificationMap_1
ComfyUI Node

OpenCV initInverseRectificationMap_1

InitInverseRectificationMap_1 — the same inverse-map builder, one more time

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV initInverseRectificationMap_1
  • cameraMatrix
  • distCoeffs
  • R
  • newCameraMatrix
  • map1
  • map2
  • nparray_0
  • nparray_1
size
m1type

Let's get the naming out of the way first, because it's the question that probably brought you here: initInverseRectificationMap_1 is the identical twin of initInverseRectificationMap_0. This pack emits one node per OpenCV function overload, and when the stub lists the function twice with no real signature difference, you get two copies of the same cv2.initInverseRectificationMap call - same inputs, same outputs, same code. There is no behavioral difference. Use either; the _0 article has the full explanation.

The function itself: it builds the remap tables for inverse rectification - the correction that undoes a previous undistort, projecting a rectified image back into the original distorted camera geometry so it lines up with raw footage. It's the mirror image of initUndistortRectifyMap_0 (which removes lens distortion), and it lives in the same niche: camera calibration, stereo rectification, compositing corrected results back onto the source. If you haven't done camera calibration, this node is not for you, and no amount of tweaking the inputs will make it useful - it needs the real intrinsics and distortion coefficients that come out of cv2.calibrateCamera.

Inputs. All required and all technical:

  • cameraMatrix (NPARRAY) - 3×3 intrinsics.
  • distCoeffs (NPARRAY) - distortion coefficients.
  • R (NPARRAY) - rectification transform; np.eye(3) if not rectifying.
  • newCameraMatrix (NPARRAY) - adjusted matrix for the output.
  • size (STRING) - output size as a Python literal, (width, height), e.g. (1920, 1080). Must be a valid tuple or you'll hit the pack's invalid syntax error.
  • m1type (INT) - 5 (CV_32FC1, float maps, precise) or 3 (CV_16SC2, faster/lighter). 5 for correctness unless you're optimizing.

Optional map1/map2 are out-parameters; per the README's standing advice, leave them unwired.

Outputs. Two NPARRAYs - nparray_0 (map1), nparray_1 (map2) - which feed into remap_0's map1/map2 inputs along with the image to resample.

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. The size literal is the classic tripwire - (w, h), nothing else. Wrong-shape matrices give you terse OpenCV assertion errors. And conceptually: computing an inverse map for a camera you never forward-rectified is asking for garbage. If the _0/_1 choice is your main question, you're in good shape - there is no choice.

Categoryimage/OpenCV

Inputs (8)

NameTypeDefaultDescription
cameraMatrixNPARRAY
distCoeffsNPARRAY
RNPARRAY
newCameraMatrixNPARRAY
sizeSTRING
m1typeINT
map1optNPARRAY
map2optNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY