Nodes/comfyui_cv/CV Fisheye Undistort
ComfyUI Node

CV Fisheye Undistort

Straightens a wide-angle image with the equidistant fisheye model (cv2.fisheye.initUndistortRectifyMap + remap). Feed camera_matrix and the FOUR-coefficient dist_coeffs from 'Fisheye Calibrate' - the five Brown-Conrady coefficients of the pinhole calibrator mean something different and produce a plausible but wrong result. 'new_camera' is the framing knob: 'same K' keeps the original focal length and throws away everything the straightening pushes off-frame, while 'estimate new K' calls estimateNewCameraMatrixForUndistortRectify, whose 'balance' scales the new focal length - 0 keeps the longest focal cv2 considers valid, 1 the shortest (measured on the shipped example: fx 166 against 50). Which of the two leaves black corners depends on the lens, so LOOK at both rather than assuming: on that example balance 0.0 leaves 3.7% of the frame black and 1.0 leaves 0.3%. Also outputs the K the result is expressed in, which is what any later projection needs. NOTE: cv2's estimator returns an all-NaN matrix when the calibration left k3/k4 unconstrained (which a fit can do while still reporting a fine RMS); this node detects that, keeps the original K and logs a warning - calibrate with CALIB_FIX_K3 | CALIB_FIX_K4 to get a usable estimate.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Fisheye Undistort
  • image
  • camera_matrix
  • dist_coeffs
  • image
  • new_camera_matrix
new_camerasame K (crops what straightening pushes off-frame)
balance0.00
fov_scale1.00
Categoryimage/CV/features

Inputs (6)

NameTypeDefaultDescription
imageCOMFY_MATCHTYPE_V3The distorted wide-angle image. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
camera_matrixNPARRAY3x3 K from 'Fisheye Calibrate'.
dist_coeffsNPARRAYFOUR fisheye coefficients (k1..k4). A 5-element pinhole vector is rejected rather than silently truncated.
new_cameraCOMBOsame K (crops what straightening pushes off-frame)Which intrinsics the undistorted image is expressed in. 'same K' is cv2's own default behaviour.
balanceFLOAT0.000–1Only read when new_camera estimates one. Blends between the two focal lengths cv2 derives from the undistorted image bounds: 0 = the longer one, 1 = the shorter one (a wider view, everything smaller). Check the result - which end leaves black corners is lens-dependent.
fov_scaleoptFLOAT1.000.1–5Extra divisor on the estimated focal length: >1 zooms out (more scene, smaller), <1 zooms in.

Outputs (2)

NameTypeDescription
imageCOMFY_MATCHTYPE_V3The straightened image, same size as the input.
new_camera_matrixNPARRAYThe 3x3 K the output image is expressed in - feed this, not the original K, to anything that projects into the undistorted image.