| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
param.h
Go to the documentation of this file.
1/*
2 * param.h
3 * artoolkitX
4 *
5 * This file is part of artoolkitX.
6 *
7 * artoolkitX is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * artoolkitX is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with artoolkitX. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * As a special exception, the copyright holders of this library give you
21 * permission to link this library with independent modules to produce an
22 * executable, regardless of the license terms of these independent modules, and to
23 * copy and distribute the resulting executable under terms of your choice,
24 * provided that you also meet, for each linked independent module, the terms and
25 * conditions of the license of that module. An independent module is a module
26 * which is neither derived from nor based on this library. If you modify this
27 * library, you may extend this exception to your version of the library, but you
28 * are not obligated to do so. If you do not wish to do so, delete this exception
29 * statement from your version.
30 *
31 * Copyright 2018 Realmax, Inc.
32 * Copyright 2015 Daqri, LLC.
33 * Copyright 2003-2015 ARToolworks, Inc.
34 *
35 * Author(s): Takeshi Mita, Shinsaku Hiura, Hirokazu Kato, Philip Lamb
36 *
37 */
38/*******************************************************
39 *
40 * Author: Takeshi Mita, Shinsaku Hiura, Hirokazu Kato
41 *
42 * tmita@inolab.sys.es.osaka-u.ac.jp
43 * shinsaku@sys.es.osaka-u.ac.jp
44 * kato@sys.im.hiroshima-cu.ac.jp
45 *
46 * Revision: 5.0
47 * Date: 03/08/13
48 *
49 *******************************************************/
50
51#ifndef AR_PARAM_H
52#define AR_PARAM_H
53
54#include <ARX/AR/ar.h>
55
56#ifdef __cplusplus
57 extern "C" {
58#endif
59
69#define AR_DIST_FUNCTION_VERSION_DEFAULT 5
74#define AR_DIST_FUNCTION_VERSION_MAX 5
79#define AR_DIST_FACTOR_NUM_MAX 17
84#define AR_PARAM_LT_DEFAULT_OFFSET 15
85
99 typedef struct {
100 int xsize;
101 int ysize;
102 ARdouble mat[3][4];
103 ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX];
104 int dist_function_version;
105} ARParam;
106
107 typedef struct {
108 int dist_factor_num;
109 int ARParam_size;
110} arParamVersionInfo_t;
114 extern const arParamVersionInfo_t arParamVersionInfo[AR_DIST_FUNCTION_VERSION_MAX];
115
120 typedef struct {
121 float *i2o;
122 float *o2i;
123 int xsize;
124 int ysize;
125 int xOff;
126 int yOff;
127} ARParamLTf;
128
129//typedef struct {
130// short *i2o;
131// short *o2i;
132// int xsize;
133// int ysize;
134// int xOff;
135// int yOff;
136//} ARParamLTi;
137
151 typedef struct {
152 ARParam param;
153 ARParamLTf paramLTf;
154 //ARParamLTi paramLTi;
155} ARParamLT;
156
157 AR_EXTERN int arParamDisp( const ARParam *param );
158
175 AR_EXTERN int arParamClear( ARParam *param, int xsize, int ysize, int dist_function_version );
176
177 AR_EXTERN int arParamDistFactorClear( ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], int xsize, int ysize, int dist_function_version );
178
194 AR_EXTERN int arParamClearWithFOVy(ARParam *param, int xsize, int ysize, ARdouble FOVy);
195
196 AR_EXTERN int arParamChangeSizeWithZoom(ARParam *source, int xsize, int ysize, ARdouble x_zoom, ARdouble y_zoom, ARParam *newparam);
197
212 AR_EXTERN int arParamChangeSize( ARParam *source, int xsize, int ysize, ARParam *newparam );
213
214 AR_EXTERN int arParamDecomp( const ARParam *source, ARParam *icpara, ARdouble trans[3][4] );
215
216 AR_EXTERN int arParamDecompMat( const ARdouble source[3][4], ARdouble cpara[3][4], ARdouble trans[3][4] );
217
218#ifdef ARDOUBLE_IS_FLOAT
219#define arParamDecompMatf arParamDecompMat
220#else
221 AR_EXTERN int arParamDecompMatf( const ARdouble source[3][4], float cpara[3][4], float trans[3][4] );
222#endif
223
250 AR_EXTERN int arParamIdeal2Observ( const ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], const ARdouble ix, const ARdouble iy,
251 ARdouble *ox, ARdouble *oy, const int dist_function_version );
252
299 AR_EXTERN int arParamObserv2Ideal( const ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], const ARdouble ox, const ARdouble oy,
300 ARdouble *ix, ARdouble *iy, const int dist_function_version );
314 AR_EXTERN int arParamSave( const char *filename, const int num, const ARParam *param, ...);
315
329 AR_EXTERN int arParamLoad( const char *filename, int num, ARParam *param, ...);
330
344 AR_EXTERN int arParamLoadFromBuffer( const void *buffer, size_t bufsize, ARParam *param);
345
346 AR_EXTERN int arParamGetPerspectiveMat( ARdouble global[][3], ARdouble idealScreen[][2], int data_num, ARdouble mat[3][4] );
347
361 AR_EXTERN int arParamSaveExt( const char *filename, ARdouble para[3][4] );
362
376 AR_EXTERN int arParamLoadExt( const char *filename, ARdouble para[3][4] );
377
393 AR_EXTERN int arParamLoadExtFromBuffer(const void *buffer, size_t bufsize, ARdouble para[3][4] );
394
402 AR_EXTERN int arParamDispExt( ARdouble para[3][4]);
403
404 AR_EXTERN int arParamSaveOptical(const char *filename, const ARdouble fovy, const ARdouble aspect, const ARdouble m[16]);
405 AR_EXTERN int arParamLoadOptical(const char *filename, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16]);
406 AR_EXTERN int arParamLoadOpticalFromBuffer(const void *buffer, size_t bufsize, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16]);
407 AR_EXTERN int arParamDispOptical(const ARdouble fovy, const ARdouble aspect, const ARdouble m[16]);
408
409 AR_EXTERN int arParamLTSave( char *filename, char *ext, ARParamLT *paramLT );
410 AR_EXTERN ARParamLT *arParamLTLoad( char *filename, char *ext );
411
432 AR_EXTERN ARParamLT *arParamLTCreate( ARParam *param, int offset );
433
441 AR_EXTERN int arParamLTFree( ARParamLT **paramLT_p );
442
466 AR_EXTERN int arParamIdeal2ObservLTf( const ARParamLTf *paramLTf, const float ix, const float iy, float *ox, float *oy);
467
468
505 AR_EXTERN int arParamObserv2IdealLTf( const ARParamLTf *paramLTf, const float ox, const float oy, float *ix, float *iy);
506
507//int arParamIdeal2ObservLTi( const ARParamLTi *paramLTi, const int ix, const int iy, int *ox, int *oy);
508
509//int arParamObserv2IdealLTi( const ARParamLTi *paramLTi, const int ox, const int oy, int *ix, int *iy);
510
511#ifdef __cplusplus
512}
513#endif
514#endif
ar.h
artoolkitX core routines.
ARdouble
double ARdouble
Definition: ar.h:99
AR_EXTERN
#define AR_EXTERN
Definition: ar.h:131
AR_DIST_FACTOR_NUM_MAX
#define AR_DIST_FACTOR_NUM_MAX
Maximum number of values in a distortion factor array.
Definition: param.h:79
arParamLTSave
AR_EXTERN int arParamLTSave(char *filename, char *ext, ARParamLT *paramLT)
Definition: paramLT.c:46
arParamLoadOptical
AR_EXTERN int arParamLoadOptical(const char *filename, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16])
Definition: paramFile.c:595
arParamLoadExtFromBuffer
AR_EXTERN int arParamLoadExtFromBuffer(const void *buffer, size_t bufsize, ARdouble para[3][4])
Load camera extrinsic parameters into a matrix from a binary buffer.
Definition: paramFile.c:510
arParamVersionInfo
const arParamVersionInfo_t arParamVersionInfo[AR_DIST_FUNCTION_VERSION_MAX]
Constant array with parameters applicable to each version of the camera parameter distortion function...
Definition: paramFile.c:64
arParamDecompMat
AR_EXTERN int arParamDecompMat(const ARdouble source[3][4], ARdouble cpara[3][4], ARdouble trans[3][4])
Definition: paramDecomp.c:77
arParamDecomp
AR_EXTERN int arParamDecomp(const ARParam *source, ARParam *icpara, ARdouble trans[3][4])
Definition: paramDecomp.c:64
arParamDispOptical
AR_EXTERN int arParamDispOptical(const ARdouble fovy, const ARdouble aspect, const ARdouble m[16])
Definition: paramDisp.c:111
arParamDisp
AR_EXTERN int arParamDisp(const ARParam *param)
Definition: paramDisp.c:56
arParamGetPerspectiveMat
AR_EXTERN int arParamGetPerspectiveMat(ARdouble global[][3], ARdouble idealScreen[][2], int data_num, ARdouble mat[3][4])
Definition: paramGetPerspective.c:60
AR_DIST_FUNCTION_VERSION_MAX
#define AR_DIST_FUNCTION_VERSION_MAX
Maximum version allowable for functions accepting a "distortion function version" parameter.
Definition: param.h:74
arParamDispExt
AR_EXTERN int arParamDispExt(ARdouble para[3][4])
Print camera extrinsic matrix to stdout.
Definition: paramDisp.c:97
arParamLoadOpticalFromBuffer
AR_EXTERN int arParamLoadOpticalFromBuffer(const void *buffer, size_t bufsize, ARdouble *fovy_p, ARdouble *aspect_p, ARdouble m[16])
Definition: paramFile.c:650
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 (...
Definition: paramLT.c:286
arParamSaveOptical
AR_EXTERN int arParamSaveOptical(const char *filename, const ARdouble fovy, const ARdouble aspect, const ARdouble m[16])
Definition: paramFile.c:540
arParamChangeSize
AR_EXTERN int arParamChangeSize(ARParam *source, int xsize, int ysize, ARParam *newparam)
Adjust the size of a camera parameter's viewing plane, e.g. to match a renderer frustum size.
Definition: paramChangeSize.c:55
arParamLTCreate
AR_EXTERN ARParamLT * arParamLTCreate(ARParam *param, int offset)
Allocate and calculate a lookup-table camera parameter from a standard camera parameter.
Definition: paramLT.c:169
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 ...
Definition: paramDistortion.c:259
arParamLoad
AR_EXTERN int arParamLoad(const char *filename, int num, ARParam *param,...)
Load camera intrinsics (pinhole lens model and distortion parameters) from a file.
Definition: paramFile.c:263
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-...
Definition: paramDistortion.c:62
arParamSave
AR_EXTERN int arParamSave(const char *filename, const int num, const ARParam *param,...)
Save camera intrinsics (pinhole lens model and distortion parameters) to a file.
Definition: paramFile.c:197
arParamChangeSizeWithZoom
AR_EXTERN int arParamChangeSizeWithZoom(ARParam *source, int xsize, int ysize, ARdouble x_zoom, ARdouble y_zoom, ARParam *newparam)
Definition: paramChangeSize.c:60
arParamLoadExt
AR_EXTERN int arParamLoadExt(const char *filename, ARdouble para[3][4])
Load camera extrinsic parameters into a matrix from a binary file.
Definition: paramFile.c:464
arParamSaveExt
AR_EXTERN int arParamSaveExt(const char *filename, ARdouble para[3][4])
Save camera extrinsic parameters from a matrix to a binary file.
Definition: paramFile.c:417
arParamLoadFromBuffer
AR_EXTERN int arParamLoadFromBuffer(const void *buffer, size_t bufsize, ARParam *param)
Load camera intrinsics (pinhole lens model and distortion parameters) from a buffer.
Definition: paramFile.c:370
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 obse...
Definition: paramLT.c:252
arParamClear
AR_EXTERN int arParamClear(ARParam *param, int xsize, int ysize, int dist_function_version)
Create a camera parameter structure representing an idealised lens.
Definition: paramClear.c:53
arParamLTLoad
AR_EXTERN ARParamLT * arParamLTLoad(char *filename, char *ext)
Definition: paramLT.c:92
arParamLTFree
AR_EXTERN int arParamLTFree(ARParamLT **paramLT_p)
Dispose of a memory allocated to a lookup-table camera parameter.
Definition: paramLT.c:221
arParamDistFactorClear
AR_EXTERN int arParamDistFactorClear(ARdouble dist_factor[AR_DIST_FACTOR_NUM_MAX], int xsize, int ysize, int dist_function_version)
Definition: paramClear.c:77
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.
Definition: paramClear.c:137
arParamDecompMatf
AR_EXTERN int arParamDecompMatf(const ARdouble source[3][4], float cpara[3][4], float trans[3][4])
Definition: paramDecomp.c:145
ARParam
Structure holding camera parameters, including image size, projection matrix and lens distortion para...
Definition: param.h:99
ARParam::ysize
int ysize
The height in pixels of images returned by arVideoGetImage() for the camera.
Definition: param.h:101
ARParam::dist_function_version
int dist_function_version
See function arParamObserv2Ideal() for discussion. Must be last field in structure (as will not be wr...
Definition: param.h:104
ARParam::xsize
int xsize
The width in pixels of images returned by arVideoGetImage() for the camera.
Definition: param.h:100
ARParamLT
Structure holding camera parameters, in lookup table form.
Definition: param.h:151
ARParamLT::param
ARParam param
A copy of original ARParam from which the lookup table was calculated.
Definition: param.h:152
ARParamLT::paramLTf
ARParamLTf paramLTf
The lookup table.
Definition: param.h:153
ARParamLTf
Structure holding camera parameters, in lookup table form; floating point version.
Definition: param.h:120
ARParamLTf::xsize
int xsize
The number of pixels in the array's x dimension, including the offset areas on the left and right sid...
Definition: param.h:123
ARParamLTf::i2o
float * i2o
Ideal-to-observed; for the location in the array corresponding to the idealised location,...
Definition: param.h:121
ARParamLTf::ysize
int ysize
The number of pixels in the array's x dimension, including the offset areas on the top and bottom....
Definition: param.h:124
ARParamLTf::yOff
int yOff
The number of pixels from the top edge of the array to row zero of the input.
Definition: param.h:126
ARParamLTf::o2i
float * o2i
Observed-to-ideal; for the location in the array corresponding to the observed location,...
Definition: param.h:122
ARParamLTf::xOff
int xOff
The number of pixels from the left edge of the array to column zero of the input.
Definition: param.h:125
arParamVersionInfo_t
Definition: param.h:107
arParamVersionInfo_t::dist_factor_num
int dist_factor_num
Definition: param.h:108
arParamVersionInfo_t::ARParam_size
int ARParam_size
Definition: param.h:109