Cameras

#include <gandalf/vision/camera.h>and the single precision version in

#include <gandalf/vision/cameraf.h>The Gandalf camera defines the transformation from camera 3D coordinates into image coordinates and back again. Ten camera models are defined, all using the assumption that the projected position in the image is independent of the depth. The camera structure (double precision floating point version) is as follows:

/** * \brief Structure containing camera parameters. */ typedef struct Gan_Camera { /// Type of camera Gan_CameraType type; /// parameters of linear camera /// focal distance in x/y pixels double fx, fy; /// image centre x/y coordinates double x0, y0; /// third homogeneous image coordinate double zh; /** * \brief Supplementary parameters for non-linear camera models. * * The thresholds are the square \f$ R^2 \f$ of the undistorted radial * camera coordinate \f$ R \f$ where the first reversal of distortion occurs * (\a thres_R2), and the similar threshold on the distorted radial * distance \f$ d\:R \f$, involving both the distortion coefficient * \f$ d \f$ and \f$ F \f$ (thres_dR), at the same reversal point. * Both thresholds are set to \c DBL_MAX if there is no reversal. */ union { struct { /// Distortion coefficients double K1; /// Thresholds on \f$ R^2 \f$ and \f$ d\:R \f$ double thres_R2, thres_dR; /// Outer linear model parameters double outer_a, outer_b; } radial1; struct { /// Distortion coefficients double K1, K2; /// Thresholds on \f$ R^2 \f$ and \f$ d\:R \f$ double thres_R2, thres_dR; /// Outer linear model parameters double outer_a, outer_b; } radial2; struct { /// Distortion coefficients double K1, K2, K3; /// Thresholds on \f$ R^2 \f$ and \f$ d\:R \f$ double thres_R2, thres_dR; /// Outer linear model parameters double outer_a, outer_b; } radial3; struct { double cxx, cxy, cyx, cyy; } xydist4; } nonlinear; /// gamma value of images taken using this camera double gamma; /// point functions struct { /// point projection function Gan_Bool (*project) ( struct Gan_Camera *camera, Gan_Vector3 *X, Gan_Vector3 *p, Gan_Matrix22 *HX, struct Gan_Camera HC[2], int *error_code ); /// point back-projection function Gan_Bool (*backproject) ( struct Gan_Camera *camera, Gan_Vector3 *p, Gan_Vector3 *X, int *error_code ); /// function to add distortion to a point Gan_Bool (*add_distortion) ( struct Gan_Camera *camera, Gan_Vector3 *pu, Gan_Vector3 *p, int *error_code ); /// function to remove distortion from a point Gan_Bool (*remove_distortion) ( struct Gan_Camera *camera, Gan_Vector3 *p, Gan_Vector3 *pu, int *error_code); } point; /// line functions struct { /// line projection function Gan_Bool (*project) ( struct Gan_Camera *camera, Gan_Vector3 *L, Gan_Vector3 *l ); /// line back-projection function Gan_Bool (*backproject) ( struct Gan_Camera *camera, Gan_Vector3 *l, Gan_Vector3 *L ); } line; } Gan_Camera;The single precision version

/** * \brief Camera models supported by Gandalf. */ typedef enum { /// linear camera model GAN_LINEAR_CAMERA, /// one parameter K1 of radial distortion GAN_RADIAL_DISTORTION_1, /// two parameters K1,K2 of radial distortion GAN_RADIAL_DISTORTION_2, /// three parameters K1,K2,K3 of radial distortion */ GAN_RADIAL_DISTORTION_3, /// one parameter K1 of inverse radial distortion GAN_RADIAL_DISTORTION_1_INV, /// stereographic projection GAN_STEREOGRAPHIC_CAMERA, /// equidistant projection GAN_EQUIDISTANT_CAMERA, /// sine-law projection GAN_SINE_LAW_CAMERA, /// equi-solid angle projection GAN_EQUI_SOLID_ANGLE_CAMERA, /// distortion model as used by 3D Equalizer V4 GAN_XY_DISTORTION_4, } Gan_CameraType;The linear and radial distortion models are standard models. The stereographic, equidistant, sine law and equi-solid angle models are wide-angle camera models from [#!Fleck:TR94!#].

The coordinate frames are illustrated in Figure 5.1.

The linear camera model is the simplest standard camera model. It defines
the following model relating camera 3D coordinates to image
coordinates :

The parameter can be eliminated, to recover Equation 5.1. can be set to one, but a good rule of thumb is to set it to roughly half the range of image coordinates, so that all the image coordinates will be scaled in approximately the same way, which can reduce truncation error in certain situations. is known as the

Note the units the elements of . and both represent the same distance, the perpendicular distance from the image plane to the optical centre, but they are measured in image and pixels respectively. is the position of the image centre in the image direction and measured in image pixels, and similarly for . Note also that and do not measure the focal

The linear model is an ``ideal'' model, corresponding to a perfect pinhole
camera. It is safe to use this model when the focal length of the lens is
large. In practice there will be non-linear distortions, and the
simplest model of distortion is that it is purely `radial`,
i.e. directed directly towards or away from the centre of the
image^{5.1}A simple model of this distortion is

Here represents the non-linear distortion. The camera models

- Building cameras
- Projecting points and lines
- Adding/removing camera distortion
- Building the camera calibration matrix
- Converting cameras between precisions