ARX  1.0
The next-generation open source augmented reality toolkit.
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
param.h File Reference

artoolkitX functions for handling calibrated camera parameters. More...

#include <ARX/AR/ar.h>
Include dependency graph for param.h:
This graph shows which files directly or indirectly include this file:

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 ARParamLTarParamLTLoad (char *filename, char *ext)
 
AR_EXTERN ARParamLTarParamLTCreate (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...
 

Detailed Description

artoolkitX functions for handling calibrated camera parameters.

Macro Definition Documentation

◆ AR_DIST_FACTOR_NUM_MAX

#define AR_DIST_FACTOR_NUM_MAX   17

Maximum number of values in a distortion factor array.

See function arParamObserv2Ideal() for discussion.

◆ AR_DIST_FUNCTION_VERSION_DEFAULT

#define AR_DIST_FUNCTION_VERSION_DEFAULT   5

Default version for functions accepting a "distortion function version" parameter.

See function arParamObserv2Ideal() for discussion.

◆ AR_DIST_FUNCTION_VERSION_MAX

#define AR_DIST_FUNCTION_VERSION_MAX   5

Maximum version allowable for functions accepting a "distortion function version" parameter.

See function arParamObserv2Ideal() for discussion.

◆ AR_PARAM_LT_DEFAULT_OFFSET

#define AR_PARAM_LT_DEFAULT_OFFSET   15

Default padding added around a lookup-table based camera parameter.

See function arParamLTCreate() for discussion.

Function Documentation

◆ arParamChangeSize()

AR_EXTERN int arParamChangeSize ( ARParam source,
int  xsize,
int  ysize,
ARParam newparam 
)

◆ arParamClear()

AR_EXTERN int arParamClear ( ARParam param,
int  xsize,
int  ysize,
int  dist_function_version 
)

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.

Parameters
paramPointer to an ARParam structure which will be filled out with the resulting camera parameters.
xsizeThe horizontal dimension of the image.
ysizeThe vertical dimension of the image.
dist_function_versionAllows 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.
Returns
0 if the function completed successfully, or -1 in case of error.
Here is the call graph for this function:

◆ arParamClearWithFOVy()

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.

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.

Parameters
paramPointer to an ARParam structure which will be filled out with the resulting camera parameters.
xsizeThe horizontal dimension of the image.
ysizeThe vertical dimension of the image.
FOVyField-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).
Returns
0 if the function completed successfully, or -1 in case of error.

◆ arParamDecomp()

AR_EXTERN int arParamDecomp ( const ARParam source,
ARParam icpara,
ARdouble  trans[3][4] 
)
Here is the call graph for this function:

◆ arParamDecompMat()

AR_EXTERN int arParamDecompMat ( const ARdouble  source[3][4],
ARdouble  cpara[3][4],
ARdouble  trans[3][4] 
)

◆ arParamDecompMatf()

AR_EXTERN int arParamDecompMatf ( const ARdouble  source[3][4],
float  cpara[3][4],
float  trans[3][4] 
)

◆ arParamDisp()

AR_EXTERN int arParamDisp ( const ARParam param)

◆ arParamDispExt()

AR_EXTERN int arParamDispExt ( ARdouble  para[3][4])

◆ arParamDispOptical()

AR_EXTERN int arParamDispOptical ( const ARdouble  fovy,
const ARdouble  aspect,
const ARdouble  m[16] 
)

◆ arParamDistFactorClear()

AR_EXTERN int arParamDistFactorClear ( ARdouble  dist_factor[AR_DIST_FACTOR_NUM_MAX],
int  xsize,
int  ysize,
int  dist_function_version 
)

◆ arParamGetPerspectiveMat()

AR_EXTERN int arParamGetPerspectiveMat ( ARdouble  global[][3],
ARdouble  idealScreen[][2],
int  data_num,
ARdouble  mat[3][4] 
)
Here is the call graph for this function:

◆ arParamIdeal2Observ()

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.

Parameters
dist_factorAn 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.
ixInput idealised normalised window coordinate x axis value.
iyInput idealised normalised window coordinate y axis value.
oxPointer to ARdouble, which on return will hold the observed normalised window coordinate x axis value.
oyPointer to ARdouble, which on return will hold the observed normalised window coordinate y axis value.
dist_function_versionAn 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.

Returns
0 in case of function success, or -1 if an error occured. At present the only error possible is an invalid value of dist_function_version.
See also
arParamObserv2Ideal
arParamObserv2IdealLTf

◆ arParamIdeal2ObservLTf()

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.

Parameters
paramLTfA 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().
ixInput idealised normalised window coordinate x axis value.
iyInput idealised normalised window coordinate y axis value.
oxPointer to ARdouble, which on return will hold the observed normalised window coordinate x axis value.
oyPointer to ARdouble, which on return will hold the observed normalised window coordinate y axis value.
Returns
0 in case of function success, or -1 if an error occured. One possible error condition is the case where the input portion of the pair is outside the range of coordinates covered by the lookup table.
See also
arParamLTCreate
arParamIdeal2Observ
arParamObserv2IdealLTf

◆ arParamLoad()

AR_EXTERN int arParamLoad ( const char *  filename,
int  num,
ARParam param,
  ... 
)

Load lens parameters from a file.

See the discussion under ARParam for more info.

Parameters
filenamePath to file from which to load the parameters. The file pointed to should be a file saved with arParamSave.
numNumber of ARParams to be loaded, normally 1.
paramPointer to the ARParam structure into which the parameters will be read.
Returns
0 if successful, or -1 if an error occured.
See also
ARParam
arParamLoadFromBuffer
arParamSave

◆ arParamLoadExt()

AR_EXTERN int arParamLoadExt ( const char *  filename,
ARdouble  para[3][4] 
)

◆ arParamLoadExtFromBuffer()

AR_EXTERN int arParamLoadExtFromBuffer ( const void *  buffer,
size_t  bufsize,
ARdouble  para[3][4] 
)

◆ arParamLoadFromBuffer()

AR_EXTERN int arParamLoadFromBuffer ( const void *  buffer,
size_t  bufsize,
ARParam param 
)

Load lens parameters from a buffer.

See the discussion under ARParam for more info.

Parameters
bufferBuffer from which the parameter(s) will be loaded. The buffer could be (for example) the contents of a parameter file read with fread().
bufsizeSize of the contents of buffer.
paramPointer to the ARParam structure into which the parameters will be read.
Returns
0 if successful, or -1 if an error occured.
See also
ARParam
arParamLoad
arParamSave

◆ arParamLoadOptical()

AR_EXTERN int arParamLoadOptical ( const char *  filename,
ARdouble fovy_p,
ARdouble aspect_p,
ARdouble  m[16] 
)

◆ arParamLoadOpticalFromBuffer()

AR_EXTERN int arParamLoadOpticalFromBuffer ( const void *  buffer,
size_t  bufsize,
ARdouble fovy_p,
ARdouble aspect_p,
ARdouble  m[16] 
)

◆ arParamLTCreate()

AR_EXTERN ARParamLT * arParamLTCreate ( ARParam param,
int  offset 
)

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.

Parameters
paramA 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.
offsetAn 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.
Returns
A pointer to a newly-allocated ARParamLT structure, or NULL if an error occurred. Once the ARParamLT is no longer needed, it should be disposed of by calling arParamLTFree() on it.
See also
arParamLTFree
Here is the call graph for this function:

◆ arParamLTFree()

AR_EXTERN int arParamLTFree ( ARParamLT **  paramLT_p)

Dispose of a memory allocated to a lookup-table camera parameter.

Parameters
paramLT_pPointer to a pointer to the paramLT structure to be disposed of. On return, the location pointed to will be set to NULL.
Returns
-1 if an error occurred, or 0 in the case of no error.
See also
arParamLTCreate

◆ arParamLTLoad()

AR_EXTERN ARParamLT * arParamLTLoad ( char *  filename,
char *  ext 
)

◆ arParamLTSave()

AR_EXTERN int arParamLTSave ( char *  filename,
char *  ext,
ARParamLT paramLT 
)

◆ arParamObserv2Ideal()

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.

Parameters
dist_factorAn 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.
ixInput observed normalised window coordinate x axis value.
iyInput observed normalised window coordinate y axis value.
oxPointer to ARdouble, which on return will hold the idealised normalised window coordinate x axis value.
oyPointer to ARdouble, which on return will hold the idealised normalised window coordinate y axis value.
dist_function_versionAn 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.

Returns
0 in case of function success, or -1 if an error occured. At present the only error possible is an invalid value of dist_function_version.
See also
arParamIdeal2Observ
arParamIdeal2ObservLTf

◆ arParamObserv2IdealLTf()

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.

Parameters
paramLTfA 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().
ixInput observed normalised window coordinate x axis value.
iyInput observed normalised window coordinate y axis value.
oxPointer to ARdouble, which on return will hold the idealised normalised window coordinate x axis value.
oyPointer to ARdouble, which on return will hold the idealised normalised window coordinate y axis value.
Returns
0 in case of function success, or -1 if an error occured. One possible error condition is the case where the input portion of the pair is outside the range of coordinates covered by the lookup table.
See also
arParamObserv2Ideal
arParamIdeal2ObservLTf

◆ arParamSave()

AR_EXTERN int arParamSave ( const char *  filename,
const int  num,
const ARParam param,
  ... 
)

Save lens parameters to a file.

See the discussion under ARParam for more info.

Parameters
filenamePath to file to which to save the parameters. The file pointed to may later be reloaded with arParamLoad.
numNumber of ARParams to be saved, normally 1.
paramPointer to the ARParam structure to save.
Returns
0 if successful, or -1 if an error occured.
See also
ARParam
arParamLoad
arParamLoadFromBuffer

◆ arParamSaveExt()

AR_EXTERN int arParamSaveExt ( const char *  filename,
ARdouble  para[3][4] 
)

◆ arParamSaveOptical()

AR_EXTERN int arParamSaveOptical ( const char *  filename,
const ARdouble  fovy,
const ARdouble  aspect,
const ARdouble  m[16] 
)

Variable Documentation

◆ arParamVersionInfo

const arParamVersionInfo_t arParamVersionInfo[AR_DIST_FUNCTION_VERSION_MAX]
extern

Constant array with parameters applicable to each version of the camera parameter distortion function.