00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _GAN_CAMERAF_H
00030 #define _GAN_CAMERAF_H
00031
00032 #include <stdio.h>
00033 #include <gandalf/common/misc_defs.h>
00034 #include <gandalf/vision/camera_defs.h>
00035 #include <gandalf/linalg/3x3matrixf.h>
00036 #include <gandalf/linalg/3vectorf.h>
00037
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00055 typedef struct Gan_RadialBasisFunction_f
00056 {
00058 float x, y;
00059
00061 float dist2_thres;
00062
00064 float weight;
00065
00067 float normaliser;
00068
00070 float dx, dy;
00071
00072 } Gan_RadialBasisFunction_f;
00073
00077 typedef struct Gan_Camera_f
00078 {
00080 Gan_CameraType type;
00081
00083
00085 float fx, fy, fy_over_fx;
00086
00088 float x0, y0;
00089
00091 float zh;
00092
00103 union
00104 {
00105 struct
00106 {
00108 float K1;
00109
00111 float thres_R2, thres_dR;
00112
00114 float outer_a, outer_b;
00115 } radial1;
00116
00117 struct
00118 {
00120 float K1, K2;
00121
00123 float thres_R2, thres_dR;
00124
00126 float outer_a, outer_b;
00127 } radial2;
00128
00129 struct
00130 {
00132 float K1, K2, K3;
00133
00135 float thres_R2, thres_dR;
00136
00138 float outer_a, outer_b;
00139 } radial3;
00140
00141 struct { float cxx, cxy, cyx, cyy; } xydist4;
00142
00143 struct
00144 {
00145 float xla, xlp, xha, xhp;
00146 float yla, ylp, yha, yhp;
00147 } fcwarp;
00148
00149 struct
00150 {
00152 float skew, kyx, kzx, kzy;
00153
00155 Gan_Matrix33_f K, Kinv;
00156
00158 Gan_Vector2_f weight[1 + (1 << 4)][1 + (1 << 4)];
00159 } cbspline;
00160 } nonlinear;
00161
00163 struct
00164 {
00166 Gan_Bool (*project) ( const struct Gan_Camera_f *camera,
00167 Gan_Vector3_f *X, Gan_Vector3_f *p,
00168 Gan_Matrix22_f *HX, struct Gan_Camera_f *HC,
00169 int *error_code );
00170
00172 Gan_Bool (*backproject) ( const struct Gan_Camera_f *camera,
00173 Gan_Vector3_f *p, Gan_Vector3_f *X,
00174 int *error_code );
00175
00177 Gan_Bool (*add_distortion) ( const struct Gan_Camera_f *camera,
00178 Gan_Vector3_f *pu, Gan_Vector3_f *p,
00179 int *error_code );
00180
00182 Gan_Bool (*remove_distortion) ( const struct Gan_Camera_f *camera,
00183 Gan_Vector3_f *p, Gan_Vector3_f *pu,
00184 int *error_code);
00185 } pointf;
00186
00188 struct
00189 {
00191 Gan_Bool (*project) ( const struct Gan_Camera_f *camera,
00192 Gan_Vector3_f *L, Gan_Vector3_f *l );
00193
00195 Gan_Bool (*backproject) ( const struct Gan_Camera_f *camera,
00196 Gan_Vector3_f *l, Gan_Vector3_f *L );
00197 } linef;
00198 } Gan_Camera_f;
00199
00200 Gan_Bool gan_cameraf_build_va ( Gan_Camera_f *camera, Gan_CameraType type,
00201 float zh,
00202 float fx, float fy, float x0, float y0,
00203 ... );
00204 Gan_Bool gan_cameraf_internalize ( Gan_Camera_f *camera );
00205 Gan_Bool gan_cameraf_identical ( Gan_Camera_f *camera1, Gan_Camera_f *pcamera2 );
00206 Gan_SquMatrix33_f gan_cameraf_fill_matrix_s ( const Gan_Camera_f *camera );
00207 Gan_Matrix33_f gan_cameraf_fill_fullmatrix_s ( const Gan_Camera_f *camera );
00208
00209 Gan_Bool gan_cameraf_set_common_fields ( Gan_Camera_f *camera,
00210 Gan_CameraType type,
00211 float zh, float fx, float fy,
00212 float x0, float y0 );
00213
00237 Gan_Bool
00238 gan_cameraf_project_point_gen ( const Gan_Camera_f *camera,
00239 Gan_Vector3_f *X, Gan_Vector3_f *p,
00240 Gan_Matrix22_f *HX, Gan_Camera_f HC[2],
00241 int *error_code );
00242
00259 Gan_Bool
00260 gan_cameraf_project_point ( const Gan_Camera_f *camera,
00261 Gan_Vector3_f *X, Gan_Vector3_f *p,
00262 int *error_code );
00263
00282 Gan_Bool
00283 gan_cameraf_project_point_q ( const Gan_Camera_f *camera,
00284 Gan_Vector3_f *X, Gan_Vector3_f *p );
00285
00303 Gan_Bool
00304 gan_cameraf_project_point_i ( const Gan_Camera_f *camera, Gan_Vector3_f *X );
00305
00325 Gan_Bool
00326 gan_cameraf_backproject_point ( const Gan_Camera_f *camera,
00327 Gan_Vector3_f *p, Gan_Vector3_f *X,
00328 int *error_code );
00329
00350 Gan_Bool
00351 gan_cameraf_backproject_point_q ( const Gan_Camera_f *camera,
00352 Gan_Vector3_f *p, Gan_Vector3_f *X );
00353
00373 Gan_Bool
00374 gan_cameraf_backproject_point_i ( const Gan_Camera_f *camera,
00375 Gan_Vector3_f *p );
00376
00393 Gan_Bool
00394 gan_cameraf_add_distortion ( const Gan_Camera_f *camera,
00395 Gan_Vector3_f *pu, Gan_Vector3_f *p,
00396 int *error_code );
00397
00415 Gan_Bool
00416 gan_cameraf_add_distortion_q ( const Gan_Camera_f *camera,
00417 Gan_Vector3_f *pu, Gan_Vector3_f *p );
00418
00434 Gan_Bool
00435 gan_cameraf_add_distortion_i ( const Gan_Camera_f *camera, Gan_Vector3_f *p );
00436
00451 Gan_Bool
00452 gan_cameraf_remove_distortion ( const Gan_Camera_f *camera,
00453 Gan_Vector3_f *p, Gan_Vector3_f *pu,
00454 int *error_code );
00455
00472 Gan_Bool
00473 gan_cameraf_remove_distortion_q ( const Gan_Camera_f *camera,
00474 Gan_Vector3_f *p, Gan_Vector3_f *pu );
00475
00491 Gan_Bool
00492 gan_cameraf_remove_distortion_i ( const Gan_Camera_f *camera, Gan_Vector3_f *p );
00493
00510 Gan_Bool
00511 gan_cameraf_project_line_q ( const Gan_Camera_f *camera,
00512 Gan_Vector3_f *L, Gan_Vector3_f *l );
00513
00530 Gan_Bool
00531 gan_cameraf_project_line_i ( const Gan_Camera_f *camera, Gan_Vector3_f *L );
00532
00552 Gan_Bool
00553 gan_cameraf_backproject_line_q ( const Gan_Camera_f *camera,
00554 Gan_Vector3_f *l, Gan_Vector3_f *L );
00555
00577 Gan_Bool
00578 gan_cameraf_backproject_line_i ( const Gan_Camera_f *camera, Gan_Vector3_f *l );
00579
00588 #ifdef __cplusplus
00589 }
00590 #endif
00591
00592 #endif