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

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

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

  1 /**@(#)Functions to read/write CAMERA files
  2 */
  3 
  4 #include <stdio.h>
  5 #include <tina/file.h>
  6 #include <tina/sys.h>
  7 #include <tina/sysfuncs.h>
  8 #include <tina/math.h>
  9 #include <tina/mathfuncs.h>
 10 #include <tina/vision.h>
 11 
 12 extern Bool fclose_2(FILE * stream, const char *pathname);
 13 extern FILE *fopen_2(const char *pathname, const char *mode);
 14 
 15 Camera *cam_read_stream(FILE * stream, const char *pathname)
 16 {
 17     Camera *cam_make();
 18     float   f, pix, ax, ay, cx, cy;
 19     int     w, h;
 20     Transform3 transf =
 21     {Transform3_id};
 22     Vec3    ex =
 23     {Vec3_id};
 24     Vec3    ey =
 25     {Vec3_id};
 26     Vec3    ez =
 27     {Vec3_id};
 28     Vec3    p =
 29     {Vec3_id};
 30 
 31     (void) fscanf(stream, "%d %d", &w, &h);
 32     (void) fscanf(stream, "%f %f", &pix, &f);
 33     (void) fscanf(stream, "%f %f", &ax, &ay);
 34     (void) fscanf(stream, "%f %f", &cx, &cy);
 35     ex = vec3_read(stream);
 36     ey = vec3_read(stream);
 37     ez = vec3_read(stream);
 38     p = vec3_read(stream);
 39 
 40     transf = trans3_to_frame(p, ex, ey, ez);
 41     return (cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
 42 }
 43 
 44 Camera *cam_read(char *pathname, void (*extra_read_func) ( /* ??? */ ))
 45 {
 46     Camera *cam = NULL;
 47     FILE   *stream = fopen_2(pathname, "r");
 48 
 49     if (stream)
 50     {
 51         cam = cam_read_stream(stream, pathname);
 52         if (extra_read_func)
 53         {
 54             extra_read_func(cam, stream);
 55         }
 56         (void) fclose_2(stream, pathname);
 57     }
 58     return (cam);
 59 }
 60 
 61 void    cam_write_stream(const Camera * cam, FILE * stream, const char *pathname)
 62 {
 63     Vec3    ex =
 64     {Vec3_id};
 65     Vec3    ey =
 66     {Vec3_id};
 67     Vec3    ez =
 68     {Vec3_id};
 69     Vec3    p =
 70     {Vec3_id};
 71 
 72     if (cam)
 73     {
 74         (void) fprintf(stream, "%d %d\n\n", cam->width, cam->height);
 75         (void) fprintf(stream, "%f %f\n\n", cam->pixel, cam->f);
 76         (void) fprintf(stream, "%f %f\n\n", cam->ax, cam->ay);
 77         (void) fprintf(stream, "%f %f\n\n", cam->cx, cam->cy);
 78         trans3_get_frame2in1(*(cam->transf), &p, &ex, &ey, &ez);
 79         vec3_print(stream, ex);
 80         (void) fprintf(stream, "\n");
 81         vec3_print(stream, ey);
 82         (void) fprintf(stream, "\n");
 83         vec3_print(stream, ez);
 84         (void) fprintf(stream, "\n\n");
 85         vec3_print(stream, p);
 86         (void) fprintf(stream, "\n");
 87     }
 88 }
 89 
 90 void    cam_write(char *pathname, Camera * cam, void (*extra_write_func) ( /* ??? */ ))
 91 {
 92     if (cam)
 93     {
 94         FILE   *stream = fopen_2(pathname, "w");
 95 
 96         if (stream)
 97         {
 98             cam_write_stream(cam, stream, pathname);
 99             if (extra_write_func)
100             {
101                 extra_write_func(cam, stream);
102             }
103             (void) fclose_2(stream, pathname);
104         }
105     }
106 }
107 

~ [ 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.