![]() |
ARX
1.0
The next-generation open source augmented reality toolkit.
|
artoolkitX functions for handling calibrated camera parameters. More...
#include <ARX/AR/ar.h>
Go to the source code of this file.
Classes | |
struct | ARParam |
Structure holding camera parameters, including image size, projection matrix and lens distortion parameters. More... | |
struct | arParamVersionInfo_t |
struct | ARParamLTf |
Structure holding camera parameters, in lookup table form; floating point version. More... | |
struct | ARParamLT |
Structure holding camera parameters, in lookup table form. More... | |
Macros | |
#define | AR_DIST_FUNCTION_VERSION_DEFAULT 5 |
Default version for functions accepting a "distortion function version" parameter. More... | |
#define | AR_DIST_FUNCTION_VERSION_MAX 5 |
Maximum version allowable for functions accepting a "distortion function version" parameter. More... | |
#define | AR_DIST_FACTOR_NUM_MAX 17 |
Maximum number of values in a distortion factor array. More... | |
#define | AR_PARAM_LT_DEFAULT_OFFSET 15 |
Default padding added around a lookup-table based camera parameter. More... | |
Functions | |
AR_EXTERN int | arParamDisp (const ARParam *param) |
AR_EXTERN int | arParamClear (ARParam *param, int xsize, int ysize, int dist_function_version) |
Create a camera parameter structure representing an idealised lens. More... | |
AR_EXTERN int | arParamDistFactorClear (ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], int xsize, int ysize, int dist_function_version) |
AR_EXTERN int | arParamClearWithFOVy (ARParam *param, int xsize, int ysize, ARdouble FOVy) |
Create a camera parameter structure representing an idealised lens with specified field-of-view. More... | |
AR_EXTERN int | arParamChangeSize (ARParam *source, int xsize, int ysize, ARParam *newparam) |
AR_EXTERN int | arParamDecomp (const ARParam *source, ARParam *icpara, ARdouble trans[3][4]) |
AR_EXTERN int | arParamDecompMat (const ARdouble source[3][4], ARdouble cpara[3][4], ARdouble trans[3][4]) |
AR_EXTERN int | arParamDecompMatf (const ARdouble source[3][4], float cpara[3][4], float trans[3][4]) |
AR_EXTERN int | arParamIdeal2Observ (const ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], const ARdouble ix, const ARdouble iy, ARdouble *ox, ARdouble *oy, const int dist_function_version) |
Use lens distortion parameters to convert idealised (zero-distortion) window coordinates to observed (distorted) coordinates. More... | |
AR_EXTERN int | arParamObserv2Ideal (const ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], const ARdouble ox, const ARdouble oy, ARdouble *ix, ARdouble *iy, const int dist_function_version) |
Use lens distortion parameters to convert observed (distorted) window coordinates to idealised (zero-distortion) coordinates. More... | |
AR_EXTERN int | arParamSave (const char *filename, const int num, const ARParam *param,...) |
Save lens parameters to a file. More... | |
AR_EXTERN int | arParamLoad (const char *filename, int num, ARParam *param,...) |
Load lens parameters from a file. More... | |
AR_EXTERN int | arParamLoadFromBuffer (const void *buffer, size_t bufsize, ARParam *param) |
Load lens parameters from a buffer. More... | |
AR_EXTERN int | arParamGetPerspectiveMat (ARdouble global[][3], ARdouble idealScreen[][2], int data_num, ARdouble mat[3][4]) |
AR_EXTERN int | arParamSaveExt (const char *filename, ARdouble para[3][4]) |
AR_EXTERN int | arParamLoadExt (const char *filename, ARdouble para[3][4]) |
AR_EXTERN int | arParamLoadExtFromBuffer (const void *buffer, size_t bufsize, ARdouble para[3][4]) |
AR_EXTERN int | arParamDispExt (ARdouble para[3][4]) |
AR_EXTERN int | arParamSaveOptical (const char *filename, const ARdouble fovy, const ARdouble aspect, const ARdouble m[16]) |
AR_EXTERN int | arParamLoadOptical (const char *filename, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16]) |
AR_EXTERN int | arParamLoadOpticalFromBuffer (const void *buffer, size_t bufsize, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16]) |
AR_EXTERN int | arParamDispOptical (const ARdouble fovy, const ARdouble aspect, const ARdouble m[16]) |
AR_EXTERN int | arParamLTSave (char *filename, char *ext, ARParamLT *paramLT) |
AR_EXTERN ARParamLT * | arParamLTLoad (char *filename, char *ext) |
AR_EXTERN ARParamLT * | arParamLTCreate (ARParam *param, int offset) |
Allocate and calculate a lookup-table camera parameter from a standard camera parameter. More... | |
AR_EXTERN int | arParamLTFree (ARParamLT **paramLT_p) |
Dispose of a memory allocated to a lookup-table camera parameter. More... | |
AR_EXTERN int | arParamIdeal2ObservLTf (const ARParamLTf *paramLTf, const float ix, const float iy, float *ox, float *oy) |
Use a lookup-table camera parameter to convert idealised (zero-distortion) window coordinates to observed (distorted) coordinates. More... | |
AR_EXTERN int | arParamObserv2IdealLTf (const ARParamLTf *paramLTf, const float ox, const float oy, float *ix, float *iy) |
Use a lookup-table camera parameter to convert observed (distorted) window coordinates to idealised (zero-distortion) coordinates. More... | |
Variables | |
const arParamVersionInfo_t | arParamVersionInfo [AR_DIST_FUNCTION_VERSION_MAX] |
Constant array with parameters applicable to each version of the camera parameter distortion function. More... | |
artoolkitX functions for handling calibrated camera parameters.
#define AR_DIST_FACTOR_NUM_MAX 17 |
Maximum number of values in a distortion factor array.
See function arParamObserv2Ideal() for discussion.
#define AR_DIST_FUNCTION_VERSION_DEFAULT 5 |
Default version for functions accepting a "distortion function version" parameter.
See function arParamObserv2Ideal() for discussion.
#define AR_DIST_FUNCTION_VERSION_MAX 5 |
Maximum version allowable for functions accepting a "distortion function version" parameter.
See function arParamObserv2Ideal() for discussion.
#define AR_PARAM_LT_DEFAULT_OFFSET 15 |
Default padding added around a lookup-table based camera parameter.
See function arParamLTCreate() for discussion.
Create a camera parameter structure representing an idealised lens.
This function creates a camera parameter structure representing an idealised lens, that is, a lens with a symmetrical perspective projection and no distortion. This idealised lens is useful in cases where you wish to match the lens model of an OpenGL camera with the same window dimensions.
param | Pointer to an ARParam structure which will be filled out with the resulting camera parameters. |
xsize | The horizontal dimension of the image. |
ysize | The vertical dimension of the image. |
dist_function_version | Allows creation of parameters with an older version of the lens distortion model. Pass AR_DIST_FUNCTION_VERSION_DEFAULT to create an ARParam with the current lens distortion model, or a lesser integer to use an earlier version. |
Create a camera parameter structure representing an idealised lens with specified field-of-view.
This function creates a camera parameter structure representing an idealised lens, that is, a lens with a symmetrical perspective projection and no distortion. This idealised lens is useful in cases where you wish to match the lens model of an OpenGL camera with the same window dimensions.
param | Pointer to an ARParam structure which will be filled out with the resulting camera parameters. |
xsize | The horizontal dimension of the image. |
ysize | The vertical dimension of the image. |
FOVy | Field-of-view in the vertical (Y) dimension, in radians. If you know only the value in degrees, pass that value multiplied by (M_PI/180.0f). |
AR_EXTERN int arParamDecompMat | ( | const ARdouble | source[3][4], |
ARdouble | cpara[3][4], | ||
ARdouble | trans[3][4] | ||
) |
AR_EXTERN int arParamDecompMatf | ( | const ARdouble | source[3][4], |
float | cpara[3][4], | ||
float | trans[3][4] | ||
) |
AR_EXTERN int arParamDispOptical | ( | const ARdouble | fovy, |
const ARdouble | aspect, | ||
const ARdouble | m[16] | ||
) |
AR_EXTERN int arParamDistFactorClear | ( | ARdouble | dist_factor[AR_DIST_FACTOR_NUM_MAX], |
int | xsize, | ||
int | ysize, | ||
int | dist_function_version | ||
) |
AR_EXTERN int arParamGetPerspectiveMat | ( | ARdouble | global[][3], |
ARdouble | idealScreen[][2], | ||
int | data_num, | ||
ARdouble | mat[3][4] | ||
) |
AR_EXTERN int arParamIdeal2Observ | ( | const ARdouble | dist_factor[AR_DIST_FACTOR_NUM_MAX], |
const ARdouble | ix, | ||
const ARdouble | iy, | ||
ARdouble * | ox, | ||
ARdouble * | oy, | ||
const int | dist_function_version | ||
) |
Use lens distortion parameters to convert idealised (zero-distortion) window coordinates to observed (distorted) coordinates.
See function arParamObserv2Ideal() for full discussion.
This function is the output function of the pair. It's inputs are idealised coordinates, e.g. taken from OpenGL. The outputs are the location where in a distorted image where the same point would lie.
dist_factor | An array of ARdouble values holding the lens distortion parameters. These values are generated as part of the camera calibration process in artoolkitX. The exact number of values from the array used by the function is determined by the distortion function version, but does not exceed AR_DIST_FACTOR_NUM_MAX. |
ix | Input idealised normalised window coordinate x axis value. |
iy | Input idealised normalised window coordinate y axis value. |
ox | Pointer to ARdouble, which on return will hold the observed normalised window coordinate x axis value. |
oy | Pointer to ARdouble, which on return will hold the observed normalised window coordinate y axis value. |
dist_function_version | An integer, in the range [1, AR_DIST_FUNCTION_VERSION_MAX] which determines the algorithm used to interpret the dist_factor values. |
See function arParamObserv2Ideal() for full discussion.
AR_EXTERN int arParamIdeal2ObservLTf | ( | const ARParamLTf * | paramLTf, |
const float | ix, | ||
const float | iy, | ||
float * | ox, | ||
float * | oy | ||
) |
Use a lookup-table camera parameter to convert idealised (zero-distortion) window coordinates to observed (distorted) coordinates.
See function arParamObserv2IdealLTf() for full discussion.
This function is the output function of the pair. It's inputs are idealised coordinates, e.g. taken from OpenGL. The outputs are the location where in a distorted image where the same point would lie.
paramLTf | A lookup-table based version of the lens distortion parameters. These values are generated as part of the camera calibration process in artoolkitX, and converted to a lookup table by arParamLTCreate(). |
ix | Input idealised normalised window coordinate x axis value. |
iy | Input idealised normalised window coordinate y axis value. |
ox | Pointer to ARdouble, which on return will hold the observed normalised window coordinate x axis value. |
oy | Pointer to ARdouble, which on return will hold the observed normalised window coordinate y axis value. |
Load lens parameters from a file.
See the discussion under ARParam for more info.
filename | Path to file from which to load the parameters. The file pointed to should be a file saved with arParamSave. |
num | Number of ARParams to be loaded, normally 1. |
param | Pointer to the ARParam structure into which the parameters will be read. |
Load lens parameters from a buffer.
See the discussion under ARParam for more info.
buffer | Buffer from which the parameter(s) will be loaded. The buffer could be (for example) the contents of a parameter file read with fread(). |
bufsize | Size of the contents of buffer. |
param | Pointer to the ARParam structure into which the parameters will be read. |
AR_EXTERN int arParamLoadOptical | ( | const char * | filename, |
ARdouble * | fovy_p, | ||
ARdouble * | aspect_p, | ||
ARdouble | m[16] | ||
) |
AR_EXTERN int arParamLoadOpticalFromBuffer | ( | const void * | buffer, |
size_t | bufsize, | ||
ARdouble * | fovy_p, | ||
ARdouble * | aspect_p, | ||
ARdouble | m[16] | ||
) |
Allocate and calculate a lookup-table camera parameter from a standard camera parameter.
A lookup-table based camera parameter offers significant performance savings in certain artoolkitX operations (including unwarping of pattern spaces) compared to use of the standard camera parameter.
The original ARParam camera parameters structure is copied into the ARParamLT structure, and is available as paramLT->param.
param | A pointer to an ARParam structure from which the lookup table will be generaeted. This ARParam structure will be copied, and the original may be disposed of. |
offset | An integer value which specifies how much the lookup table values will be padded around the original camera parameters size. Normally, the default value AR_PARAM_LT_DEFAULT_OFFSET (defined elsewhere in this header) should be used. However, when using a camera with a large amount of lens distortion, a higher value may be required to cope with the corners or sides of the camera image frame. |
Dispose of a memory allocated to a lookup-table camera parameter.
paramLT_p | Pointer to a pointer to the paramLT structure to be disposed of. On return, the location pointed to will be set to NULL. |
AR_EXTERN int arParamObserv2Ideal | ( | const ARdouble | dist_factor[AR_DIST_FACTOR_NUM_MAX], |
const ARdouble | ox, | ||
const ARdouble | oy, | ||
ARdouble * | ix, | ||
ARdouble * | iy, | ||
const int | dist_function_version | ||
) |
Use lens distortion parameters to convert observed (distorted) window coordinates to idealised (zero-distortion) coordinates.
This function is used by artoolkitX to convert for the the effects of lens distortion in images which have been acquired from lens-based optical systems. All lenses introduce some amount of lens distortion. artoolkitX includes calibration utilities to measure the centre of distortion and the radial distortion factors in the x and y dimensions. This calibration information is saved as part of the camera parameters.
This function is one of a pair of functions which convert between OBSERVED window coordinates (i.e. the location of a known reference point, as measured in the x-y viewing plane of an image containing lens distortion) and IDEALISED coordinates (i.e. the location of the same reference point as measured in an image containing no radial distortion, e.g. an image rendered using OpenGL's viewing model.)
This function is the input function of the pair. It's inputs are distorted coordinates, e.g. taken from an image acquired from a camera The outputs are the location where in an idealised image (e.g. generated with OpenGL) where the same point would lie.
dist_factor | An array of ARdouble values holding the lens distortion parameters. These values are generated as part of the camera calibration process in artoolkitX. The exact number of values from the array used by the function is determined by the distortion function version, but does not exceed AR_DIST_FACTOR_NUM_MAX. |
ix | Input observed normalised window coordinate x axis value. |
iy | Input observed normalised window coordinate y axis value. |
ox | Pointer to ARdouble, which on return will hold the idealised normalised window coordinate x axis value. |
oy | Pointer to ARdouble, which on return will hold the idealised normalised window coordinate y axis value. |
dist_function_version | An integer, in the range [1, AR_DIST_FUNCTION_VERSION_MAX] which determines the algorithm used to interpret the dist_factor values. |
The values correspond to the following algorithms:
version 1: The original ARToolKit lens model, with a single radial distortion factor, plus center of distortion.
version 2: Improved distortion model, introduced in ARToolKit v4.0. This algorithm adds a quadratic term to the radial distortion factor of the version 1 algorithm.
version 3: Improved distortion model with aspect ratio, introduced in ARToolKit v4.0. The addition of an aspect ratio to the version 2 algorithm allows for non-square pixels, as found e.g. in DV image streams.
version 4: OpenCV-based distortion model, introduced in ARToolKit v4.3. This differs from the standard OpenCV model by the addition of a scale factor, so that input values do not exceed the range [-1.0, 1.0] in either forward or inverse conversions.
AR_EXTERN int arParamObserv2IdealLTf | ( | const ARParamLTf * | paramLTf, |
const float | ox, | ||
const float | oy, | ||
float * | ix, | ||
float * | iy | ||
) |
Use a lookup-table camera parameter to convert observed (distorted) window coordinates to idealised (zero-distortion) coordinates.
This function is used by artoolkitX to convert for the the effects of lens distortion in images which have been acquired from lens-based optical systems. All lenses introduce some amount of lens distortion. artoolkitX includes calibration utilities to measure the centre of distortion and the radial distortion factors in the x and y dimensions. This calibration information is saved as part of the camera parameters.
This function is one of a pair of functions which convert between OBSERVED window coordinates (i.e. the location of a known reference point, as measured in the x-y viewing plane of an image containing lens distortion) and IDEALISED coordinates (i.e. the location of the same reference point as measured in an image containing no radial distortion, e.g. an image rendered using OpenGL's viewing model.)
This function is the input function of the pair. It's inputs are distorted coordinates, e.g. taken from an image acquired from a camera The outputs are the location where in an idealised image (e.g. generated with OpenGL) where the same point would lie.
paramLTf | A lookup-table based version of the lens distortion parameters. These values are generated as part of the camera calibration process in artoolkitX, and converted to a lookup table by arParamLTCreate(). |
ix | Input observed normalised window coordinate x axis value. |
iy | Input observed normalised window coordinate y axis value. |
ox | Pointer to ARdouble, which on return will hold the idealised normalised window coordinate x axis value. |
oy | Pointer to ARdouble, which on return will hold the idealised normalised window coordinate y axis value. |
Save lens parameters to a file.
See the discussion under ARParam for more info.
filename | Path to file to which to save the parameters. The file pointed to may later be reloaded with arParamLoad. |
num | Number of ARParams to be saved, normally 1. |
param | Pointer to the ARParam structure to save. |
AR_EXTERN int arParamSaveOptical | ( | const char * | filename, |
const ARdouble | fovy, | ||
const ARdouble | aspect, | ||
const ARdouble | m[16] | ||
) |
|
extern |
Constant array with parameters applicable to each version of the camera parameter distortion function.