Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
undistortion.h File Reference

Functions for undistorting camera images. More...

#include "std.h"
+ Include dependency graph for undistortion.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool Dhane_distortion (float x_n, float y_n, float *x_nd, float *y_nd, float k)
 Distort normalized image coordinates with the invertible Dhane method. More...
 
bool Dhane_undistortion (float x_nd, float y_nd, float *x_n, float *y_n, float k)
 Undistort distorted normalized image coordinates with the invertible Dhane method. More...
 
void normalized_to_pixels (float x_n_, float y_n_, float *x_p, float *y_p, const float *K)
 Transform normalized coordinates to pixel coordinates. More...
 
void pixels_to_normalized (float x_p, float y_p, float *x_n_, float *y_n_, const float *K)
 Transform pixel coordinates to normalized coordinates. More...
 
bool distorted_pixels_to_normalized_coords (float x_pd, float y_pd, float *x_n, float *y_n, float k, const float *K)
 Transform distorted pixel coordinates to normalized coordinates. More...
 
bool normalized_coords_to_distorted_pixels (float x_n, float y_n, float *x_pd, float *y_pd, float k, const float *K)
 Transform normalized coordinates to distorted pixel coordinates. More...
 

Detailed Description

Functions for undistorting camera images.

The lenses of most cameras distort the image, in the sense that it does not represent a linear projection of points in the world. Specifically, straight lines in the world get curved in the image, as the lens compresses the data more and more towards the edges of the image.

Reading:

  1. https://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html (for normal cameras)
  2. https://docs.opencv.org/trunk/db/d58/group__calib3d__fisheye.html (for fisheye cameras)
  3. Dhane, P., Kutty, K., & Bangadkar, S. (2012). A generic non-linear method for fisheye correction. International Journal of Computer Applications, 51(10). (invertible fisheye model)

Some definitions:

  • x_n, y_n: Normalized coordinates, i.e., with no distortion, with (0,0) the center of the image, and x_n = X / Z
  • x_nd, y_nd: Distorted normalized coordinates, i.e., with (0,0) the center of the image, but x_nd and y_nd are a nonlinear function of X/Z
  • x_n_, y_n_: Normalized coordinates, whether distorted or undistorted.
  • x_p, y_p: Pixel coordinates, with (0,0) the start of the image, and x_pd, y_pd in the range [0,width] and [0,height], respectively.
  • k: distortion parameters
  • K: camera calibration matrix, as a single array in row-major form, so K00, K01, K02, K10, K11, ...

Definition in file undistortion.h.

Function Documentation

◆ Dhane_distortion()

bool Dhane_distortion ( float  x_n,
float  y_n,
float *  x_nd,
float *  y_nd,
float  k 
)

Distort normalized image coordinates with the invertible Dhane method.

This can be useful for undistorting an entire image. We assume f, the focal length, to be 1 here. That is why it is missing from the below formula.

Parameters
[in]x_nThe undistorted normalized x coordinate
[in]y_nThe undistorted normalized y coordinate
[in]kThe single parameter of Dhane's model, typically found empirically by checking if straight lines in the world are straight in an undistorted image.
[out]*x_ndThe distorted normalized x coordinate
[out]*y_ndThe distorted normalized y coordinate
Returns
Whether the distortion was successful

Definition at line 57 of file undistortion.c.

Referenced by normalized_coords_to_distorted_pixels().

+ Here is the caller graph for this function:

◆ Dhane_undistortion()

bool Dhane_undistortion ( float  x_nd,
float  y_nd,
float *  x_n,
float *  y_n,
float  k 
)

Undistort distorted normalized image coordinates with the invertible Dhane method.

We assume f, the focal length, to be 1 here. That is why it is missing from the below formula.

Parameters
[out]*x_nThe undistorted normalized x coordinate
[out]*y_nThe undistorted normalized y coordinate
[in]kThe single parameter of Dhane's model, typically found empirically by checking if straight lines in the world are straight in an undistorted image.
[in]x_ndThe distorted normalized x coordinate
[in]y_ndThe distorted normalized y coordinate
Returns
Whether the distortion was successful

Definition at line 76 of file undistortion.c.

Referenced by distorted_pixels_to_normalized_coords().

+ Here is the caller graph for this function:

◆ distorted_pixels_to_normalized_coords()

bool distorted_pixels_to_normalized_coords ( float  x_pd,
float  y_pd,
float *  x_n,
float *  y_n,
float  k,
const float *  K 
)

Transform distorted pixel coordinates to normalized coordinates.

Parameters
[out]*x_nThe undistorted normalized x coordinate
[out]*y_nThe undistorted normalized y coordinate
[in]kThe single parameter of Dhane's model, typically found empirically by checking if straight lines in the world are straight in an undistorted image.
[in]*KThe camera calibration matrix, as a single array in row-major form, so K00, K01, K02, K10, K11, ...
[in]x_pdThe distorted pixel x coordinate
[in]y_pdThe distorted pixel y coordinate
Returns
Whether the transformation was successful

Definition at line 128 of file undistortion.c.

References Dhane_undistortion(), K, and pixels_to_normalized().

Referenced by get_world_position_from_image_points(), and predict_flow_vectors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalized_coords_to_distorted_pixels()

bool normalized_coords_to_distorted_pixels ( float  x_n,
float  y_n,
float *  x_pd,
float *  y_pd,
float  k,
const float *  K 
)

Transform normalized coordinates to distorted pixel coordinates.

Parameters
[in]x_nThe undistorted normalized x coordinate
[in]y_nThe undistorted normalized y coordinate
[in]kThe single parameter of Dhane's model, typically found empirically by checking if straight lines in the world are straight in an undistorted image.
[in]*KThe camera calibration matrix, as a single array in row-major form, so K00, K01, K02, K10, K11, ...
[out]*x_pdThe distorted pixel x coordinate
[out]*y_pdThe distorted pixel y coordinate
Returns
Whether the transformation was successful

Definition at line 146 of file undistortion.c.

References Dhane_distortion(), K, and normalized_to_pixels().

Referenced by predict_flow_vectors(), and undistort_image_func().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalized_to_pixels()

void normalized_to_pixels ( float  x_n_,
float  y_n_,
float *  x_p,
float *  y_p,
const float *  K 
)

Transform normalized coordinates to pixel coordinates.

Parameters
[in]x_nThe undistorted normalized x coordinate
[in]y_nThe undistorted normalized y coordinate
[in]*KThe camera calibration matrix, as a single array in row-major form, so K00, K01, K02, K10, K11, ...
[out]*x_pThe pixel x coordinate
[out]*y_pThe pixel y coordinate

Definition at line 100 of file undistortion.c.

References K.

Referenced by normalized_coords_to_distorted_pixels().

+ Here is the caller graph for this function:

◆ pixels_to_normalized()

void pixels_to_normalized ( float  x_p,
float  y_p,
float *  x_n_,
float *  y_n_,
const float *  K 
)

Transform pixel coordinates to normalized coordinates.

Parameters
[out]*x_nThe undistorted normalized x coordinate
[out]*y_nThe undistorted normalized y coordinate
[in]*KThe camera calibration matrix, as a single array in row-major form, so K00, K01, K02, K10, K11, ...
[in]x_pThe pixel x coordinate
[in]y_pThe pixel y coordinate

Definition at line 113 of file undistortion.c.

References K.

Referenced by distorted_pixels_to_normalized_coords().

+ Here is the caller graph for this function: