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

Linux Cross Reference
Tina6/tina-libs/tina/file/fileCam_view_prms.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_view_prms.c,v $
 37  * Date    :  $Date: 2005/01/23 19:10:21 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: fileCam_view_prms.c,v 1.4 2005/01/23 19:10:21 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes   :
 44  * 
 45  *
 46  *********
 47 */
 48 
 49 #include "fileCam_view_prms.h"
 50 
 51 #if HAVE_CONFIG_H
 52   #include <config.h>
 53 #endif
 54 
 55 #include <stdio.h>
 56 #include <tina/sys/sysPro.h>
 57 #include <tina/sys/sysDef.h>
 58 #include <tina/math/mathDef.h>
 59 #include <tina/math/mathPro.h>
 60 #include <tina/vision/visDef.h>
 61 #include <tina/vision/visPro.h>
 62 #include <tina/geometry/geomPro.h>
 63 #include <tina/file/fileUtil_io.h>
 64 
 65 void    view_params_write_stream(FILE * fp, Camera * caml, Camera * camr)
 66 {
 67     Vec3    lex =
 68     {Vec3_id};
 69     Vec3    ley =
 70     {Vec3_id};
 71     Vec3    lez =
 72     {Vec3_id};
 73     Vec3    lp =
 74     {Vec3_id};
 75     Vec3    rex =
 76     {Vec3_id};
 77     Vec3    rey =
 78     {Vec3_id};
 79     Vec3    rez =
 80     {Vec3_id};
 81     Vec3    rp =
 82     {Vec3_id};
 83 
 84     if (caml == NULL || camr == NULL)
 85         return;
 86 
 87     trans3_get_frame2in1(*(caml->transf), &lp, &lex, &ley, &lez);
 88     vec3_x(lp) *= -1;
 89     vec3_z(lp) *= -1;
 90     vec3_y(lex) *= -1;
 91     vec3_y(ley) *= -1;
 92     vec3_x(lez) *= -1;
 93     vec3_z(lez) *= -1;
 94     trans3_get_frame2in1(*(camr->transf), &rp, &rex, &rey, &rez);
 95     vec3_x(rp) *= -1;
 96     vec3_z(rp) *= -1;
 97     vec3_y(rex) *= -1;
 98     vec3_y(rey) *= -1;
 99     vec3_x(rez) *= -1;
100     vec3_z(rez) *= -1;
101 
102     (void) fprintf(fp, "%d %f ", caml->width, caml->pixel);
103     (void) fprintf(fp, "%f\n\n", vec3_mod(vec3_diff(lp, rp)));
104 
105     (void) fprintf(fp, "%f %f ", 1 / caml->ax, caml->f);
106     (void) fprintf(fp, "%f %f\n", caml->cx, caml->cy);
107     (void) fprintf(fp, "%f %f %f\n", vec3_x(lex), vec3_x(ley), vec3_x(lez));
108     (void) fprintf(fp, "%f %f %f\n", vec3_y(lex), vec3_y(ley), vec3_y(lez));
109     (void) fprintf(fp, "%f %f %f\n", vec3_z(lex), vec3_z(ley), vec3_z(lez));
110     vec3_print(fp, lp);
111     (void) fprintf(fp, "\n\n");
112 
113     (void) fprintf(fp, "%f %f ", 1 / camr->ax, camr->f);
114     (void) fprintf(fp, "%f %f\n", camr->cx, camr->cy);
115     (void) fprintf(fp, "%f %f %f\n", vec3_x(rex), vec3_x(rey), vec3_x(rez));
116     (void) fprintf(fp, "%f %f %f\n", vec3_y(rex), vec3_y(rey), vec3_y(rez));
117     (void) fprintf(fp, "%f %f %f\n", vec3_z(rex), vec3_z(rey), vec3_z(rez));
118     vec3_print(fp, rp);
119     (void) fprintf(fp, "\n");
120 }
121 
122 void    view_params_read_stream(FILE * fp, void (*cam1_func) ( /* ??? */ ), void (*cam2_func) ( /* ??? */ ))
123 {
124     Transform3 transf =
125     {Transform3_id};
126     float   f, pix, ax, ay = (float) 1.0, cx, cy;
127     Vec3    ex =
128     {Vec3_id};
129     Vec3    ey =
130     {Vec3_id};
131     Vec3    ez =
132     {Vec3_id};
133     Vec3    p =
134     {Vec3_id};
135     int     w, h;
136 
137     (void) fscanf(fp, "%d %f %*f", &w, &pix);
138     h = w;
139     (void) fscanf(fp, "%f %f %f %f", &ax, &f, &cx, &cy);
140     ax = 1 / ax;
141     (void) fscanf(fp, "%f %f %f", &vec3_x(ex), &vec3_x(ey), &vec3_x(ez));
142     (void) fscanf(fp, "%f %f %f", &vec3_y(ex), &vec3_y(ey), &vec3_y(ez));
143     (void) fscanf(fp, "%f %f %f", &vec3_z(ex), &vec3_z(ey), &vec3_z(ez));
144     /* correct to new camera definition and coordinate frame */
145     ex.el[1] *= (float) -1.0;
146     ey.el[1] *= (float) -1.0;
147     ez.el[0] *= (float) -1.0;
148     ez.el[2] *= (float) -1.0;
149     p = vec3_read(fp);
150     p.el[0] *= (float) -1.0;
151     p.el[2] *= (float) -1.0;
152 
153     transf = trans3_to_frame(p, ex, ey, ez);
154     cam1_func(cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
155 
156     (void) fscanf(fp, "%f %f %f %f", &ax, &f, &cx, &cy);
157     ax = 1 / ax;
158     (void) fscanf(fp, "%f %f %f", &vec3_x(ex), &vec3_x(ey), &vec3_x(ez));
159     (void) fscanf(fp, "%f %f %f", &vec3_y(ex), &vec3_y(ey), &vec3_y(ez));
160     (void) fscanf(fp, "%f %f %f", &vec3_z(ex), &vec3_z(ey), &vec3_z(ez));
161     /* correct to new camera definition and coordinate frame */
162     ex.el[1] *= (float) -1.0;
163     ey.el[1] *= (float) -1.0;
164     ez.el[0] *= (float) -1.0;
165     ez.el[2] *= (float) -1.0;
166     p = vec3_read(fp);
167     p.el[0] *= (float) -1.0;
168     p.el[2] *= (float) -1.0;
169 
170     transf = trans3_to_frame(p, ex, ey, ez);
171     cam2_func(cam_make(CAMERA_PHYSICAL, &transf, f, pix, ax, ay, cx, cy, w, h));
172 }
173 
174 void    view_params_read(char *pathname, void (*cam1_func) ( /* ??? */ ), void (*cam2_func) ( /* ??? */ ))
175 {
176     FILE   *stream = fopen_2(pathname, "r");
177 
178     if (stream)
179     {
180         view_params_read_stream(stream, cam1_func, cam2_func);
181         (void) fclose_2(stream, pathname);
182     }
183 }
184 
185 void    view_params_write(char *pathname, Camera * cam1, Camera * cam2)
186 {
187     FILE   *stream = fopen_2(pathname, "w");
188 
189     if (stream)
190     {
191         view_params_write_stream(stream, cam1, cam2);
192         (void) fclose_2(stream, pathname);
193     }
194 }
195 

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