Skip to content

Undistort Image

Overview

Some cameras and lenses introduce distortion that causes straight lines to appear curved. This node removes barrel or pincushion distortion from camera images, which is essential for wide-angle or fisheye lenses where this effect can interfere with accurate geometric measurements.

Barrel-distorted image with visibly curved grid lines
Barrel distortion from a wide-angle lens. The grid lines bow outward from the center.

For background on how camera undistortion works, see the OpenCV camera calibration tutorial.

Use Undistort Image when:

  • You use wide-angle lenses that cause "bowing" at the edges of the frame.
  • Precise alignment or measurement is required across the entire field of view.

💡 Tip

To configure this node correctly, observe how the settings affect the image on a running deployment, then return to the Flow builder or tunables to adjust the coefficients until curved lines in the real world appear straight.

Inputs

NameTypeDescription
imageimageThe distorted original image.

Outputs

NameTypeDescription
undistorted_imageimageThe resulting image with lens distortion removed.

Parameters

ParameterDefaultValid valuesTunable
K10.0float
K20.0float
K30.0float
K40.0float
Post-undistort scale1.0> 0.02.0

K1

Primary radial distortion coefficient. This has the largest visual effect and corrects the most common barrel or pincushion distortion. Negative values correct barrel distortion (edges bow outward); positive values correct pincushion distortion (edges bow inward). Typical values range from -1 to 1 (including decimals).

K2

Secondary radial distortion coefficient. Provides finer correction on top of k1, particularly at the edges of the frame.

K3

Tangential distortion coefficient (corresponds to OpenCV's p1). Tangential distortion occurs when the lens is not perfectly centered or aligned with the image sensor — instead of symmetric bending around the center, the image gets slightly skewed or stretched unevenly. In most industrial setups this value is close to zero.

K4

Tangential distortion coefficient (corresponds to OpenCV's p2). Works together with K3 to correct the uneven skew caused by lens-to-sensor misalignment.

Post-undistort scale

Zooms the image in or out after undistorting. Undistortion sometimes leaves black areas where the distorted pixels used to be. Values greater than 1.0 zoom in, which crops away those black borders. Values less than 1.0 zoom out, preserving more of the original field of view but potentially introducing black areas at the edges.

Example

Correcting barrel distortion on a PCB inspection camera

A wide-angle camera used for PCB inspection introduces barrel distortion, causing the board edges and reference grid to bow outward. The node is configured with a negative K1 to straighten the image.

Configuration:

  • K1: -0.25
  • Post-undistort scale: 1.05
Barrel-distorted PCB image with curved grid lines
Barrel-distorted image from a wide-angle lens. Grid lines bow outward from center
Corrected PCB image with straight grid lines
After undistortion, grid lines are straight and the PCB geometry is restored

Result: The grid lines that were visibly curved in the input now appear straight, and the PCB boards regain their correct rectangular shape.

External:

Reference: