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/2x3matrixf.h>
00037 #include <gandalf/linalg/3vectorf.h>
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00056 typedef struct Gan_PositionState_f
00057 {
00058 Gan_Bool initialised;
00059 Gan_Vector3_f pin, pout;
00060 } Gan_PositionState_f;
00061
00065 typedef struct Gan_CubicBSplineSupportF
00066 {
00067 Gan_Vector2_f warped_pos[1 + (1 << 4)][1 + (1 << 4)];
00068 Gan_Matrix22_f warped_deriv[1 + (1 << 4)][1 + (1 << 4)];
00069 } Gan_CubicBSplineSupportF;
00070
00071 typedef Gan_Vector2_f Gan_CubicBSplineWeightBlockF[1 + (1<<4)];
00072
00076 typedef struct Gan_CubicBSplineWeightsF
00077 {
00078 Gan_Vector2_f weight[1 + (1 << 4)][1 + (1 << 4)];
00079 } Gan_CubicBSplineWeightsF;
00080
00084 typedef struct Gan_Camera_f
00085 {
00087 Gan_CameraType type;
00088
00090
00092 float fx, fy, fy_over_fx;
00093
00095 float x0, y0;
00096
00098 float zh;
00099
00110 union
00111 {
00112 struct
00113 {
00115 float skew, kyx;
00116
00118 Gan_Matrix23_f Kinv;
00119 } affine;
00120
00121 struct
00122 {
00124 float K1;
00125
00127 float thres_R2, thres_dR;
00128
00130 float outer_a, outer_b;
00131 } radial1;
00132
00133 struct
00134 {
00136 float K1, K2;
00137
00139 float thres_R2, thres_dR;
00140
00142 float outer_a, outer_b;
00143 } radial2;
00144
00145 struct
00146 {
00148 float K1, K2, K3;
00149
00151 float thres_R2, thres_dR;
00152
00154 float outer_a, outer_b;
00155 } radial3;
00156
00157 struct { float cxx, cxy, cyx, cyy; } xydist4;
00158
00159 struct
00160 {
00161 float xla, xlp, xha, xhp;
00162 float yla, ylp, yha, yhp;
00163 float axx, axy, ayx, ayy;
00164 } fcwarp;
00165
00166 struct
00167 {
00169 float skew, kyx, kzx, kzy;
00170
00172 Gan_Matrix33_f K, Kinv;
00173
00175 Gan_CubicBSplineWeightBlockF *weight;
00176
00178 Gan_CubicBSplineSupportF* support;
00179 } cbspline;
00180 } nonlinear;
00181
00183 struct
00184 {
00186 Gan_Bool (*project) ( const struct Gan_Camera_f *camera,
00187 Gan_Vector3_f *X, Gan_Vector3_f *p, Gan_PositionState_f *Xpprev,
00188 Gan_Matrix22_f *HX, struct Gan_Camera_f *HC,
00189 int *error_code );
00190
00192 Gan_Bool (*backproject) ( const struct Gan_Camera_f *camera,
00193 Gan_Vector3_f *p, Gan_Vector3_f *X, Gan_PositionState_f *pXprev,
00194 int *error_code );
00195
00197 Gan_Bool (*add_distortion) ( const struct Gan_Camera_f *camera,
00198 Gan_Vector3_f *pu, Gan_Vector3_f *p, Gan_PositionState_f *pupprev,
00199 int *error_code );
00200
00202 Gan_Bool (*remove_distortion) ( const struct Gan_Camera_f *camera,
00203 Gan_Vector3_f *p, Gan_Vector3_f *pu, Gan_PositionState_f *ppuprev,
00204 int *error_code);
00205 } pointf;
00206
00208 struct
00209 {
00211 Gan_Bool (*project) ( const struct Gan_Camera_f *camera,
00212 Gan_Vector3_f *L, Gan_Vector3_f *l );
00213
00215 Gan_Bool (*backproject) ( const struct Gan_Camera_f *camera,
00216 Gan_Vector3_f *l, Gan_Vector3_f *L );
00217 } linef;
00218 } Gan_Camera_f;
00219
00220 Gan_Bool gan_cameraf_build_va ( Gan_Camera_f *camera, Gan_CameraType type,
00221 float zh,
00222 float fx, float fy, float x0, float y0,
00223 ... );
00224 Gan_Bool gan_cameraf_internalize ( Gan_Camera_f *camera );
00225 Gan_Bool gan_cameraf_identical ( const Gan_Camera_f *camera1, const Gan_Camera_f *pcamera2 );
00226 Gan_SquMatrix33_f gan_cameraf_fill_matrix_s ( const Gan_Camera_f *camera );
00227 Gan_Matrix33_f gan_cameraf_fill_fullmatrix_s ( const Gan_Camera_f *camera );
00228
00229 Gan_Bool gan_cameraf_set_common_fields ( Gan_Camera_f *camera,
00230 Gan_CameraType type,
00231 float zh, float fx, float fy,
00232 float x0, float y0 );
00233
00258 Gan_Bool
00259 gan_cameraf_project_point_gen ( const Gan_Camera_f *camera,
00260 Gan_Vector3_f *X, Gan_Vector3_f *p, Gan_PositionState_f *Xpprev,
00261 Gan_Matrix22_f *HX, Gan_Camera_f HC[2],
00262 int *error_code );
00263
00280 Gan_Bool
00281 gan_cameraf_project_point ( const Gan_Camera_f *camera,
00282 Gan_Vector3_f *X, Gan_Vector3_f *p,
00283 int *error_code );
00284
00303 Gan_Bool
00304 gan_cameraf_project_point_q ( const Gan_Camera_f *camera,
00305 Gan_Vector3_f *X, Gan_Vector3_f *p );
00306
00324 Gan_Bool
00325 gan_cameraf_project_point_i ( const Gan_Camera_f *camera, Gan_Vector3_f *X );
00326
00347 Gan_Bool
00348 gan_cameraf_backproject_point_gen ( const Gan_Camera_f *camera,
00349 Gan_Vector3_f *p, Gan_Vector3_f *X, Gan_PositionState_f *pXprev,
00350 int *error_code );
00351
00371 Gan_Bool
00372 gan_cameraf_backproject_point ( const Gan_Camera_f *camera,
00373 Gan_Vector3_f *p, Gan_Vector3_f *X,
00374 int *error_code );
00375
00396 Gan_Bool
00397 gan_cameraf_backproject_point_q ( const Gan_Camera_f *camera,
00398 Gan_Vector3_f *p, Gan_Vector3_f *X );
00399
00419 Gan_Bool
00420 gan_cameraf_backproject_point_i ( const Gan_Camera_f *camera,
00421 Gan_Vector3_f *p );
00422
00440 Gan_Bool
00441 gan_cameraf_add_distortion_gen ( const Gan_Camera_f *camera,
00442 Gan_Vector3_f *pu, Gan_Vector3_f *p, Gan_PositionState_f *pupprev,
00443 int *error_code );
00444
00461 Gan_Bool
00462 gan_cameraf_add_distortion ( const Gan_Camera_f *camera,
00463 Gan_Vector3_f *pu, Gan_Vector3_f *p,
00464 int *error_code );
00465
00483 Gan_Bool
00484 gan_cameraf_add_distortion_q ( const Gan_Camera_f *camera,
00485 Gan_Vector3_f *pu, Gan_Vector3_f *p );
00486
00502 Gan_Bool
00503 gan_cameraf_add_distortion_i ( const Gan_Camera_f *camera, Gan_Vector3_f *p );
00504
00520 Gan_Bool
00521 gan_cameraf_remove_distortion_gen ( const Gan_Camera_f *camera,
00522 Gan_Vector3_f *p, Gan_Vector3_f *pu, Gan_PositionState_f *ppuprev,
00523 int *error_code );
00524
00539 Gan_Bool
00540 gan_cameraf_remove_distortion ( const Gan_Camera_f *camera,
00541 Gan_Vector3_f *p, Gan_Vector3_f *pu,
00542 int *error_code );
00543
00560 Gan_Bool
00561 gan_cameraf_remove_distortion_q ( const Gan_Camera_f *camera,
00562 Gan_Vector3_f *p, Gan_Vector3_f *pu );
00563
00579 Gan_Bool
00580 gan_cameraf_remove_distortion_i ( const Gan_Camera_f *camera, Gan_Vector3_f *p );
00581
00598 Gan_Bool
00599 gan_cameraf_project_line_q ( const Gan_Camera_f *camera,
00600 Gan_Vector3_f *L, Gan_Vector3_f *l );
00601
00618 Gan_Bool
00619 gan_cameraf_project_line_i ( const Gan_Camera_f *camera, Gan_Vector3_f *L );
00620
00640 Gan_Bool
00641 gan_cameraf_backproject_line_q ( const Gan_Camera_f *camera,
00642 Gan_Vector3_f *l, Gan_Vector3_f *L );
00643
00665 Gan_Bool
00666 gan_cameraf_backproject_line_i ( const Gan_Camera_f *camera, Gan_Vector3_f *l );
00667
00676 #ifdef __cplusplus
00677 }
00678 #endif
00679
00680 #endif