/* * The view position (vp) and view direction (vd) are clear. Vup has to * be flipped. Intrinsic parameters are defined by the size of the image * itself. That is, as exposed by 'Realistic Ray Tracing, 2nd Ed.', two * opposite corners of the rectangle. The center of projection and the * filed of view is given or deduced from the size (and position) and * this rectangle. */ #include #include #include #include "cal_main.h" int main(int argc, char **argv) { FILE *fp; double vp_x, vp_y, vp_z; double vd_x, vd_y, vd_z; double vu_x, vu_y, vu_z; double w, h, fov_x, fov_y; double fx, fy; int width, height; if(argc != 4) { fprintf(stderr, "Usage %s tsai_file width height.\n", argv[0]); return 1; } if((fp=fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Can't open %s\n", argv[1]); return 1; } width = atoi(argv[2]); height = atoi(argv[3]); load_cp_cc_data(fp, &cp, &cc); print_cp_cc_data(stderr, &cp, &cc); // -R'*t, not -R*t // or: camera_coord_to_world_coord(0,0,0,&vp_x,&vp_y,&vp_z); vp_x = -(cc.r1 * cc.Tx + cc.r4 * cc.Ty + cc.r7 * cc.Tz); vp_y = -(cc.r2 * cc.Tx + cc.r5 * cc.Ty + cc.r8 * cc.Tz); vp_z = -(cc.r3 * cc.Tx + cc.r6 * cc.Ty + cc.r9 * cc.Tz); /* * Vup has to be flipped. This is Radiance specific. The construction * of the view frame is left-handed. Only after Radiance flips row * number to 'real' y value, does the frame become right-handed */ vu_x = - cc.r4; vu_y = - cc.r5; vu_z = - cc.r6; vd_x = cc.r7; vd_y = cc.r8; vd_z = cc.r9; /* * w and h are the size of the sensor, which is mapped exactly * to the image region used by the ray tracer */ w = cp.dpx * width; h = cp.dpy * height; /* * fov is just another way to specify the size of the image region * it has nothing to do with shift/lift. * Note the fov of x direction is larger */ fov_x = 2*atan(w/(2.*(cc.f*cp.sx))); fov_y = 2*atan(h/(2.*cc.f)); printf("rpict -vp %g %g %g ", vp_x, vp_y, vp_z); printf("-vd %g %g %g ", vd_x, vd_y, vd_z); printf("-vu %g %g %g ", vu_x, vu_y, vu_z); printf("-vh %g ", fov_x*180./M_PI); printf("-vv %g ", fov_y*180./M_PI); /* * the signs of vl and vs are set by trial-and-error */ printf("-vl %g ", (cp.Cy/height-0.5)); printf("-vs %g\n", -(cp.Cx/width-0.5)); fprintf(stderr,"-x %d -y %d -pa 0\n", width, height); }