## VPI - Vision Programming Interface

#### 1.0 Release

Lens Distortion Correction

## Data Structures

struct  VPIFisheyeLensDistortionModel
Holds coefficients for fisheye lens distortion model. More...

struct  VPIPolynomialLensDistortionModel
Holds coefficients for polynomial lens distortion model. More...

## Typedefs

typedef float VPICameraIntrinsic
Camera intrinsic matrix. More...

typedef float VPICameraExtrinsic
Camera extrinsic matrix. More...

## Enumerations

enum  VPIFisheyeMapping
Supported fisheye lens mapping types. More...

## Functions

VPIStatus vpiWarpMapGenerateFromFisheyeLensDistortionModel (const VPICameraIntrinsic Kin, const VPICameraExtrinsic X, const VPICameraIntrinsic Kout, const VPIFisheyeLensDistortionModel *distModel, VPIWarpMap *warpMap)
Generates a mapping that corrects image distortions caused by fisheye lenses. More...

VPIStatus vpiWarpMapGenerateFromPolynomialLensDistortionModel (const VPICameraIntrinsic Kin, const VPICameraExtrinsic X, const VPICameraIntrinsic Kout, const VPIPolynomialLensDistortionModel *distModel, VPIWarpMap *warpMap)
Generates a mapping that corrects image using polynomial lens distortion model. More...

## ◆ VPIFisheyeLensDistortionModel

 struct VPIFisheyeLensDistortionModel

Holds coefficients for fisheye lens distortion model.

The fisheye lens distortion model is defined by:

\begin{align*} r &= \sqrt{u^2 + v^2} \\ \theta &= \arctan(r) \\ r_d &= D(\theta + k_1 * \theta^3 + k_2 * \theta^5 + k_3 * \theta^7 + k_4 * \theta^9) \\ c_d &= r_d/r \\ u_d &= u*c_d \\ v_d &= v*c_d \end{align*}

where:

• $$k_1,k_2,k_3,k_4$$ are the distortion coefficients.
• $$(u_d,v_d)$$ is the coordinate of a point in the distorted image.
• $$(u,v)$$ is the coordinate of a point in the corrected image.
• $$D(\theta)$$ defines the mapping from point angle and pixel distance to image center. See VPIFisheyeMapping for details.

Definition at line 137 of file LensDistortionModels.h. Collaboration diagram for VPIFisheyeLensDistortionModel:
Data Fields
float k1

Mapping between pixel angle and pixel distance to image center. Fisheye distortion coefficients.

float k2

Mapping between pixel angle and pixel distance to image center. Fisheye distortion coefficients.

float k3

Mapping between pixel angle and pixel distance to image center. Fisheye distortion coefficients.

float k4

Mapping between pixel angle and pixel distance to image center. Fisheye distortion coefficients.

VPIFisheyeMapping mapping

## ◆ VPIPolynomialLensDistortionModel

 struct VPIPolynomialLensDistortionModel

Holds coefficients for polynomial lens distortion model.

The polynomial lens distortion model is defined by:

\begin{align*} r &= \sqrt{u^2 + v^2} \\ k_r &= \frac{1 + k_1r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} \\ u_d &= k_r u + p_1(2uv) + p_2 * (r^2 + 2u^2) \\ v_d &= k_r v + p_1(r^2 + 2v^2) + p_2(2uv) \end{align*}

where:

• $$k_1,k_2,k_3,k_4,k_5,k_6$$ are the radial distortion coefficients.
• $$p_1,p_2$$ are the tangential distortion coefficients.
• $$(u_d,v_d)$$ is the coordinate of a point in the distorted image.
• $$(u,v)$$ is the coordinate of a point in the corrected image.

Definition at line 194 of file LensDistortionModels.h. Collaboration diagram for VPIPolynomialLensDistortionModel:
Data Fields
float k1

float k2

float k3

float k4

float k5

float k6

float p1

Tangential distortion coefficients.

float p2

Tangential distortion coefficients.

## ◆ VPICameraExtrinsic

 typedef float VPICameraExtrinsic

#include <vpi/Types.h>

Camera extrinsic matrix.

\begin{bmatrix} R_{3\times3} & T_{3\times1} \end{bmatrix}

Where: $$R_{3\times3}$$: Rotation matrix. $$T_{3\times1}$$: 3D position of the origin of world coordinate system expressed in coordinates of camera-centered system.

Definition at line 399 of file Types.h.

## ◆ VPICameraIntrinsic

 typedef float VPICameraIntrinsic

#include <vpi/Types.h>

Camera intrinsic matrix.

\begin{bmatrix} f_x & s & c_x \\ 0 & f_y & c_y \end{bmatrix}

Where:

• $$f_x, f_y$$: focal length in pixels.
• $$s$$: skew, used to model slanted pixels.
• $$c_x, c_y$$: principal point.

Definition at line 386 of file Types.h.

## ◆ VPIFisheyeMapping

 enum VPIFisheyeMapping

#include <vpi/LensDistortionModels.h>

Supported fisheye lens mapping types.

Enumerator
VPI_FISHEYE_EQUIDISTANT

Specifies the equidistant fisheye mapping.

Mapping is defined by:

$r = f\theta$

where:

• $$\theta$$ is the angle from the optical axis.
• $$f$$ is the focal length.
• $$r$$ is the distance of a pixel from the image center.
VPI_FISHEYE_EQUISOLID

Specifies the equisolid fisheye mapping.

Mapping is defined by:

$r = 2f\sin\left(\frac{\theta}{2}\right)$

where:

• $$\theta$$ is the angle from the optical axis.
• $$f$$ is the focal length.
• $$r$$ is the distance of a pixel from the image center.
VPI_FISHEYE_ORTHOGRAPHIC

Specifies the orthographic fisheye mapping.

Mapping is defined by:

$r = f\sin(\theta)$

where:

• $$\theta$$ is the angle from the optical axis.
• $$f$$ is the focal length.
• $$r$$ is the distance of a pixel from the image center.
VPI_FISHEYE_STEREOGRAPHIC

Specifies the stereographic fisheye mapping.

Mapping is defined by:

$r = 2f\tan\left(\frac{\theta}{2}\right)$

where:

• $$\theta$$ is the angle from the optical axis.
• $$f$$ is the focal length.
• $$r$$ is the distance of a pixel from the image center.

Definition at line 76 of file LensDistortionModels.h.

## ◆ vpiWarpMapGenerateFromFisheyeLensDistortionModel()

 VPIStatus vpiWarpMapGenerateFromFisheyeLensDistortionModel ( const VPICameraIntrinsic Kin, const VPICameraExtrinsic X, const VPICameraIntrinsic Kout, const VPIFisheyeLensDistortionModel * distModel, VPIWarpMap * warpMap )

#include <vpi/LensDistortionModels.h>

Generates a mapping that corrects image distortions caused by fisheye lenses.

Given camera intrinsic and extrinsic parameters, and fisheye lens distortion model, generates a VPIWarpMap suitable to be used by Remap to undistort images captured by cameras equipped with fisheye lens.

The mapping is defined by the following matrix equation:

$y = (K_{out} L X K_{in}) x$

where:

• $$x$$ is the input homogeneous coordinate
• $$y$$ is the corresponding homogeneous coordinate on the distorted image.
• $$L$$ is the fisheye lens distortion model (not a matrix), see VPIFisheyeLensDistortionModel.
• remaining variables are the input parameters to this function.
Parameters
 [in] Kin Camera intrinsic parameters. [in] X Camera extrinsic parameters that defines the camera center position and its heading in world coordinates. [in] Kout New camera intrinsic parameters applied to the undistorted image. For monocular cameras, Kout is usually equal to Kin. [in] distModel Fisheye lens distortion model. [out] warpMap Resulting warp map that serves as input to Remap algorithm.

## ◆ vpiWarpMapGenerateFromPolynomialLensDistortionModel()

 VPIStatus vpiWarpMapGenerateFromPolynomialLensDistortionModel ( const VPICameraIntrinsic Kin, const VPICameraExtrinsic X, const VPICameraIntrinsic Kout, const VPIPolynomialLensDistortionModel * distModel, VPIWarpMap * warpMap )

#include <vpi/LensDistortionModels.h>

Generates a mapping that corrects image using polynomial lens distortion model.

Given camera intrinsic and extrinsic parameters, and the polynomial lens distortion model, generates a VPIWarpMap suitable to be used by Remap to undistort images.

The mapping is defined by the following matrix equation:

$y = (K_{out} L X K_{in}) x$

where:

• $$x$$ is the input homogeneous coordinate
• $$y$$ is the corresponding homogeneous coordinate on the distorted image.
• $$L$$ is the polynomial lens distortion model (not a matrix), see VPIPolynomialLensDistortionModel
• remaining variables are the input parameters to this function.
Parameters
 [in] Kin Camera intrinsic parameters. [in] X Camera extrinsic parameters that defines the camera center position and its heading in world coordinates. [in] Kout New camera intrinsic parameters applied to the undistorted image. For monocular cameras, Kout is usually equal to Kin. [in] distModel Fisheye lens distortion model. [out] warpMap Resulting warp map that serves as input to Remap algorithm.