Video Geometric Lens Distortion

Corrects or applies the radial and tangential distortion of a lens, with the Brown-Conrady model of OpenCV camera calibrations. Straightens the picture of a wide-angle camera before detection or mapping, or pre-distorts content for a short-throw lens or a curved surface.

Example: distort with k1 -0.35 on a checkerboard (top), undistort with k1 -0.25 and zoom 0.9 on a wide-angle camera (bottom).

The defaults show a barrel lens. With every coefficient at 0 and zoom at 1, the module copies its input. A change of the model (mode, the coefficients, the centre, the focal lengths or zoom) rebuilds the distortion map, which takes about 1 ms for a 4K picture: these values can be modulated at every frame, for example by an LFO.

Settings

bypass

Bypasses the module processing when activated (ON).

  • OFF (0): Module processes normally
  • ON (1): Input passes directly to output without processing

video in

Video input flow(s).

video out

Video output flow(s).

process time

Total time used for the calculation of the module.

mode

Direction of the model (default distort).

  • undistort: removes the distortion of a camera: the output is the corrected picture, as OpenCV computes it with the same values.
  • distort: applies the distortion of the model to the picture, to pre-distort content projected through a lens or to imitate a lens.

A module in distort followed by a module in undistort with the same values gives the picture back, apart from the corners lost by the first one.

k1

First radial coefficient, the r^2 term, from -1 to 1 (default -0.25). In distort mode a negative value gives a barrel (lines bowed outwards, background in the corners) and a positive value a pincushion. In undistort mode it is the other way round: a negative value, usual for a wide-angle camera, gives a pincushion look and keeps the frame filled, a positive value a barrel look with background corners. Typed or wired values beyond the fader are accepted, up to 100 in absolute value: a strong barrel never folds back into a mirrored ghost picture, the picture beyond the limit radius is scaled evenly behind a hard circular edge.

k2

Second radial coefficient, the r^4 term, from -1 to 1 (default 0). Acts mostly on the outer part of the picture. Values beyond the fader are accepted.

k3

Third radial coefficient, the r^6 term, from -1 to 1 (default 0). Acts on the far corners; often 0 in calibrations of ordinary lenses. Values beyond the fader are accepted.

p1

First tangential coefficient, from -0.1 to 0.1 (default 0): the distortion of a lens tilted vertically, which makes the picture asymmetric from top to bottom. Values beyond the fader are accepted.

p2

Second tangential coefficient, from -0.1 to 0.1 (default 0): the distortion of a lens tilted horizontally, which makes the picture asymmetric from left to right. Values beyond the fader are accepted.

center x

Horizontal position of the optical centre: cx divided by the width of the picture, from 0 to 1 (default 0.5, the middle).

center y

Vertical position of the optical centre: cy divided by the height of the picture, from 0 to 1 (default 0.5, the middle).

focal x

Focal length fx divided by the width of the picture, from 0.1 to 4 on a logarithmic fader (default 1). The coefficients act on distances measured in focal lengths: a longer focal weakens the effect of the same coefficients. Values beyond the fader are accepted. An OpenCV calibration converts as follows:

camera = 1920 x 1080, fx = 1000, fy = 1000, cx = 960, cy = 540
focal x = 1000 / 1920 = 0.521
focal y = 1000 / 1920 = 0.521
center x = 960 / 1920 = 0.5
center y = 540 / 1080 = 0.5
k1, k2, k3, p1, p2 = the values of the calibration

focal y

Focal length fy divided by the width of the picture too (not by its height), from 0.1 to 4 on a logarithmic fader (default 1): equal to focal x for square pixels. Values beyond the fader are accepted.

zoom

Scale of the output around the optical centre, from 0.25 to 4 on a logarithmic fader (default 1). Above 1 it enlarges the picture and hides the background corners of a barrel: for example undistort with k1 0.3 shows black corners at zoom 1 and none at zoom 1.15. Below 1 it shrinks the picture: after an undistort with a negative k1, the whole source shows inside curved borders.

outside

What the output shows where the model reads outside the picture (default background).

  • background: the background colour.
  • edge: the edge pixels of the picture, stretched outwards.
  • mirror: the picture mirrored at its edges.

background

Colour shown outside the picture when outside is background (default opaque black, $FF000000). A transparent colour gives a picture with alpha: the corners are transparent.

interpolation

How the picture is read between its pixels (default bilinear).

  • bilinear: the four nearest pixels mixed, smooth.
  • nearest: the nearest pixel, crisp and faster, for pixel art and LED content.
Common Settings

info

show manual

Button. Opens the manual page of the selected object (or of its parent module for a control) in the web browser. If no page exists for this object, an error is traced in the trace panel.

For more details about information/help creation, see create-help-file.

description

Free multi-line text attached to the module, saved with the patch. When it is not empty, it is shown as the hint of the module (mouse over the module header in the patch) in place of the default module hint, even when the module hints are disabled.

ID's

visible only in god mode, see setup-panel-tab-expert.

unique ID

Read-only, not saved. Current private numeric ID of the object, used internally to identify it (for example as the target of a bind ID).

preset ID

Read-only, not saved. Private ID used to store and recall the values of this control in presets.

recreate ID

Button. Generates a new unique ID, original ID and preset ID for the object. Use it if you experience difficulties in Polyphonic mode or if two objects share the same ID. Preset values and binds referring to the old IDs are lost.

Object Remote Address

absolute

Read-only, not saved. Absolute address of the object in the Usine objects tree, built from the workspace root. This is the address to use to reach the object from scripts, the objects panel or remote messages. Only shown for objects that are registered in the objects list. See objects-address.

local

Read-only, not saved. Address of the object relative to the current patch, valid inside that patch only. See objects-address.

user addr

Free user-defined address for the object (empty by default). When set, the object is also registered in the objects tree under this name, so it can be reached independently of its position in the workspace (the value is also reported in the mouse-over and mouse-down chunks). Changing it rebuilds the objects list. Only available on objects that support a user address. See objects-address.

See also

version 7.0.250921

Edit All Pages