~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/file/camera/view_prms.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2   */
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 
 11 extern Bool fclose_2(FILE * stream, const char *pathname);
 12 extern FILE *fopen_2(const char *pathname, const char *mode);
 13 
 14 void    view_params_write_stream(FILE * fp, Camera * caml, Camera * camr)
 15 {
 16     Vec3    lex =
 17     {Vec3_id};
 18     Vec3    ley =
 19     {Vec3_id};
 20     Vec3    lez =
 21     {Vec3_id};
 22     Vec3    lp =
 23     {Vec3_id};
 24     Vec3    rex =
 25     {Vec3_id};
 26     Vec3    rey =
 27     {Vec3_id};
 28     Vec3    rez =
 29     {Vec3_id};
 30     Vec3    rp =
 31     {Vec3_id};
 32 
 33     if (caml == NULL || camr == NULL)
 34         return;
 35 
 36     trans3_get_frame2in1(*(caml->transf), &lp, &lex, &ley, &lez);
 37     vec3_x(lp) *= -1;
 38     vec3_z(lp) *= -1;
 39     vec3_y(lex) *= -1;
 40     vec3_y(ley) *= -1;
 41     vec3_x(lez) *= -1;
 42     vec3_z(lez) *= -1;
 43     trans3_get_frame2in1(*(camr->transf), &rp, &rex, &rey, &rez);
 44     vec3_x(rp) *= -1;
 45     vec3_z(rp) *= -1;
 46     vec3_y(rex) *= -1;
 47     vec3_y(rey) *= -1;
 48     vec3_x(rez) *= -1;
 49     vec3_z(rez) *= -1;
 50 
 51     (void) fprintf(fp, "%d %f ", caml->width, caml->pixel);
 52     (void) fprintf(fp, "%f\n\n", vec3_mod(vec3_diff(lp, rp)));
 53 
 54     (void) fprintf(fp, "%f %f ", 1 / caml->ax, caml->f);
 55     (void) fprintf(fp, "%f %f\n", caml->cx, caml->cy);
 56     (void) fprintf(fp, "%f %f %f\n", vec3_x(lex), vec3_x(ley), vec3_x(lez));
 57     (void) fprintf(fp, "%f %f %f\n", vec3_y(lex), vec3_y(ley), vec3_y(lez));
 58     (void) fprintf(fp, "%f %f %f\n", vec3_z(lex), vec3_z(ley), vec3_z(lez));
 59     vec3_print(fp, lp);
 60     (void) fprintf(fp, "\n\n");
 61 
 62     (void) fprintf(fp, "%f %f ", 1 / camr->ax, camr->f);
 63     (void) fprintf(fp, "%f %f\n", camr->cx, camr->cy);
 64     (void) fprintf(fp, "%f %f %f\n", vec3_x(rex), vec3_x(rey), vec3_x(rez));
 65     (void) fprintf(fp, "%f %f %f\n", vec3_y(rex), vec3_y(rey), vec3_y(rez));
 66     (void) fprintf(fp, "%f %f %f\n", vec3_z(rex), vec3_z(rey), vec3_z(rez));
 67     vec3_print(fp, rp);
 68     (void) fprintf(fp, "\n");
 69 }
 70 
 71 void    view_params_read_stream(FILE * fp, void (*cam1_func) ( /* ??? */ ), void (*cam2_func) ( /* ??? */ ))
 72 {
 73     Transform3 transf =
 74     {Transform3_id};
 75     float   f, pix, ax, ay = (float) 1.0, cx, cy;
 76     Vec3    ex =
 77     {Vec3_id};
 78     Vec3    ey =
 79     {Vec3_id};
 80     Vec3    ez =
 81     {Vec3_id};
 82     Vec3    p =
 83     {Vec3_id};
 84     int     w, h;
 85 
 86     (void) fscanf(fp, "%d %f %*f", &w, &pix);
 87     h = w;
 88     (void) fscanf(fp, "%f %f %f %f", &ax, &f, &cx, &cy);
 89     ax = 1 / ax;
 90     (void) fscanf(fp, "%f %f %f", &vec3_x(ex), &vec3_x(ey), &vec3_x(ez));
 91     (void) fscanf(fp, "%f %f %f", &vec3_y(ex), &vec3_y(ey), &vec3_y(ez));
 92     (void) fscanf(fp, "%f %f %f", &vec3_z(ex), &vec3_z(ey), &vec3_z(ez));
 93     /* correct to new camera definition and coordinate frame */
 94     ex.el[1] *= (float) -1.0;
 95     ey.el[1] *= (float) -1.0;
 96     ez.el[0] *= (float) -1.0;
 97     ez.el[2] *= (float) -1.0;
 98     p = vec3_read(fp);
 99     p.el[0] *= (float) -1.0;
100     p.el[2] *= (float) -1.0;
101 
102     transf = trans3_to_frame(p, ex, ey, ez);
103     cam1_func(cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
104 
105     (void) fscanf(fp, "%f %f %f %f", &ax, &f, &cx, &cy);
106     ax = 1 / ax;
107     (void) fscanf(fp, "%f %f %f", &vec3_x(ex), &vec3_x(ey), &vec3_x(ez));
108     (void) fscanf(fp, "%f %f %f", &vec3_y(ex), &vec3_y(ey), &vec3_y(ez));
109     (void) fscanf(fp, "%f %f %f", &vec3_z(ex), &vec3_z(ey), &vec3_z(ez));
110     /* correct to new camera definition and coordinate frame */
111     ex.el[1] *= (float) -1.0;
112     ey.el[1] *= (float) -1.0;
113     ez.el[0] *= (float) -1.0;
114     ez.el[2] *= (float) -1.0;
115     p = vec3_read(fp);
116     p.el[0] *= (float) -1.0;
117     p.el[2] *= (float) -1.0;
118 
119     transf = trans3_to_frame(p, ex, ey, ez);
120     cam2_func(cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
121 }
122 
123 void    view_params_read(char *pathname, void (*cam1_func) ( /* ??? */ ), void (*cam2_func) ( /* ??? */ ))
124 {
125     FILE   *stream = fopen_2(pathname, "r");
126 
127     if (stream)
128     {
129         view_params_read_stream(stream, cam1_func, cam2_func);
130         (void) fclose_2(stream, pathname);
131     }
132 }
133 
134 void    view_params_write(char *pathname, Camera * cam1, Camera * cam2)
135 {
136     FILE   *stream = fopen_2(pathname, "w");
137 
138     if (stream)
139     {
140         view_params_write_stream(stream, cam1, cam2);
141         (void) fclose_2(stream, pathname);
142     }
143 }
144 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.