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

Linux Cross Reference
Tina5/tina-libs/tina/file/fileCam_io.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/file/fileCam_io.c,v $
 37  * Date    :  $Date: 2009/03/19 18:36:26 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: fileCam_io.c,v 1.4 2009/03/19 18:36:26 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes   :
 44  *
 45  *  Functions to read/write CAMERA files
 46  *
 47  *********
 48 */
 49 
 50 #include "fileCam_io.h"
 51 
 52 #if HAVE_CONFIG_H
 53   #include <config.h>
 54 #endif
 55 
 56 #include <stdio.h>
 57 #include <tina/sys/sysPro.h>
 58 #include <tina/sys/sysDef.h>
 59 #include <tina/math/mathDef.h>
 60 #include <tina/math/mathPro.h>
 61 #include <tina/geometry/geomDef.h>
 62 #include <tina/geometry/geomPro.h>
 63 #include <tina/vision/visDef.h>
 64 #include <tina/vision/visPro.h>
 65 #include <tina/file/fileUtil_io.h>
 66 
 67 Camera *cam_read_stream(FILE * stream, const char *pathname)
 68 {
 69     float   f, pix, ax, ay, cx, cy;
 70     int     w, h;
 71     Transform3 transf =
 72     {Transform3_id};
 73     Vec3    ex =
 74     {Vec3_id};
 75     Vec3    ey =
 76     {Vec3_id};
 77     Vec3    ez =
 78     {Vec3_id};
 79     Vec3    p =
 80     {Vec3_id};
 81 
 82     (void) fscanf(stream, "%d %d", &w, &h);
 83     (void) fscanf(stream, "%f %f", &pix, &f);
 84     (void) fscanf(stream, "%f %f", &ax, &ay);
 85     (void) fscanf(stream, "%f %f", &cx, &cy);
 86     ex = vec3_read(stream);
 87     ey = vec3_read(stream);
 88     ez = vec3_read(stream);
 89     p = vec3_read(stream);
 90 
 91     transf = trans3_to_frame(p, ex, ey, ez);
 92     return (cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
 93 }
 94 
 95 Camera *cam_read(char *pathname, void (*extra_read_func) ( /* ??? */ ))
 96 {
 97     Camera *cam = NULL;
 98     FILE   *stream = fopen_2(pathname, "r");
 99 
100     if (stream)
101     {
102         cam = cam_read_stream(stream, pathname);
103         if (extra_read_func)
104         {
105             extra_read_func(cam, stream);
106         }
107         (void) fclose_2(stream, pathname);
108     }
109     return (cam);
110 }
111 
112 void    cam_write_stream(const Camera * cam, FILE * stream, const char *pathname)
113 {
114     Vec3    ex =
115     {Vec3_id};
116     Vec3    ey =
117     {Vec3_id};
118     Vec3    ez =
119     {Vec3_id};
120     Vec3    p =
121     {Vec3_id};
122 
123     if (cam)
124     {
125         (void) fprintf(stream, "%d %d\n\n", cam->width, cam->height);
126         (void) fprintf(stream, "%f %f\n\n", cam->pixel, cam->f);
127         (void) fprintf(stream, "%f %f\n\n", cam->ax, cam->ay);
128         (void) fprintf(stream, "%f %f\n\n", cam->cx, cam->cy);
129         trans3_get_frame2in1(*(cam->transf), &p, &ex, &ey, &ez);
130         vec3_print(stream, ex);
131         (void) fprintf(stream, "\n");
132         vec3_print(stream, ey);
133         (void) fprintf(stream, "\n");
134         vec3_print(stream, ez);
135         (void) fprintf(stream, "\n\n");
136         vec3_print(stream, p);
137         (void) fprintf(stream, "\n");
138     }
139 }
140 
141 void    cam_write(char *pathname, Camera * cam, void (*extra_write_func) ( /* ??? */ ))
142 {
143     if (cam)
144     {
145         FILE   *stream = fopen_2(pathname, "w");
146 
147         if (stream)
148         {
149             cam_write_stream(cam, stream, pathname);
150             if (extra_write_func)
151             {
152                 extra_write_func(cam, stream);
153             }
154             (void) fclose_2(stream, pathname);
155         }
156     }
157 }
158 

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