21 #ifndef PROJECTION_MATRIX_H
22 #define PROJECTION_MATRIX_H
45 void print(FILE * file,
char * calibration_filename);
48 bool load_tdir(
const char * tdir_filename);
49 bool load_tdir(
const char * tdir_filename,
int w,
int h);
53 static FILE * open_matchmover_output(
char * filename);
54 static void close_matchmover_output(FILE * f);
55 bool read_from_matchmover_output(FILE * f);
58 void set_3x4_matrix(
double P[3][4],
int width,
int height);
59 void get_3x4_matrix(
double P[3][4]);
62 void set_original_internal_parameters(
int image_width,
int image_height,
63 double fx,
double fy,
double cx,
double cy);
65 void set_original_internal_parameters(
double fx,
double fy,
double cx,
double cy);
67 void change_image_size(
int new_width,
int new_height);
69 bool read_internal_parameters_from_tdir_file(
const char * tdir_filename);
77 void set_camera_centre_and_lookat_point(
double Cx,
double Cy,
double Cz,
78 double Lx,
double Ly,
double Lz,
79 double angle_vertical);
81 void set_external_parameters(
double omega,
double phi,
double kappa,
double Tx,
double Ty,
double Tz);
82 void set_angles(
double omega,
double phi,
double kappa);
83 void set_external_parameters(
double rot[3][3],
double transl[3]);
84 void set_external_parameters(
double wc2vc[3][4]);
85 void set_external_parameters(
double ** wc2vc);
86 void set_external_parameters(
double * state);
87 void set_external_parameters_exp_map(
double * state, CvMat * JR = 0);
88 void set_external_parameters(CvMat * H);
89 void set_rotation_to_Id(
void);
90 void set_translation_to_0(
void);
92 void get_external_parameters(
double * omega,
double * phi,
double * kappa,
93 double * Tx,
double * Ty,
double * Tz);
94 void get_external_parameters(
double * state);
95 void get_external_parameters_exp_map(
double * state);
97 void get_angles(
double * omega,
double * phi,
double * kappa);
99 void translate_x(
double delta);
100 void translate_y(
double delta);
101 void translate_z(
double delta);
102 void rotate_x(
double delta);
103 void rotate_y(
double delta);
104 void rotate_z(
double delta);
106 void world_to_cam(
double * M,
double * Mc);
109 void get_optical_centre(
double * Cx,
double * Cy,
double * Cz);
111 double * get_optical_centre(
void);
115 double * get_V(
double u,
double v);
116 void get_V(
double u,
double v,
double * V);
117 void get_V(
double u,
double v,
double * Vx,
double * Vy,
double * Vz);
120 void set_GL_zmin_zmax(
double zmin,
double zmax);
122 void set_GL_PROJECTION(
int xdim,
int ydim,
float * gl_vector);
123 void set_GL_MODELVIEW(
double * gl_matrix);
125 bool visible_triangle(
double X1,
double Y1,
double Z1,
126 double X2,
double Y2,
double Z2,
127 double X3,
double Y3,
double Z3);
130 void project(
const double X,
const double Y,
const double Z,
double * u,
double * v);
131 void project(
const double X,
const double Y,
const double Z,
float * u,
float * v);
135 static void read_one_line(FILE * f,
char * line);
136 void getAAt(
const double P[3][4],
double AAt[3][3]);
139 double original_fx, original_fy, original_cx, original_cy;
140 double fx, fy, cx, cy;
142 int original_image_width, original_image_height;
143 int image_width, image_height;
145 double R[3][3], T[3];
147 double optical_centre[3];
150 void compute_optical_centre(
void);
151 void compute_invAR(
void);
152 void compute_P(
void);
154 bool have_to_recompute_optical_centre;
155 bool have_to_recompute_invAR;
156 bool have_to_recompute_P;
165 if (have_to_recompute_P)
169 M[0] = X; M[1] = Y; M[2] = Z; M[3] = 1.;
172 double inv_PM3 = 1 / PM[2];
173 *u = inv_PM3 * PM[0];
174 *v = inv_PM3 * PM[1];
179 if (have_to_recompute_P)
183 M[0] = X; M[1] = Y; M[2] = Z; M[3] = 1.;
186 double inv_PM3 = 1 / PM[2];
187 *u = float(inv_PM3 * PM[0]);
188 *v = float(inv_PM3 * PM[1]);
192 #endif // PROJECTION_MATRIX_H