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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlbase/tlbaseSter_file.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-tools/tinatool/tlbase/tlbaseSter_file.c,v $
 37  * Date    :  $Date: 2005/02/07 23:29:19 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: tlbaseSter_file.c,v 1.3 2005/02/07 23:29:19 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #if HAVE_CONFIG_H
 49 #include <config.h>
 50 #endif
 51 
 52 
 53 #include <stdio.h>
 54 #include <sys/param.h>
 55 #include <string.h>
 56 
 57 #include <tina/sys/sysDef.h>
 58 #include <tina/sys/sysPro.h>
 59 #include <tina/image/imgDef.h>
 60 #include <tina/image/imgPro.h>
 61 #include <tina/file/fileDef.h>
 62 #include <tina/file/filePro.h>
 63 #include <tina/geometry/geomDef.h>
 64 #include <tina/geometry/geomPro.h>
 65 
 66 #include <tinatool/tlbase/tlbase_InfrPro.h>
 67 #include <tinatool/tlbase/tlbaseSter_left.h>
 68 #include <tinatool/tlbase/tlbaseSter_right.h>
 69 #include <tinatool/tlbase/tlbaseSter_roi.h>
 70 #include <tinatool/tlbase/tlbase_SterDef.h>
 71 
 72 
 73 #define AIFF_FILE    0
 74 #define ROI_FILE     1
 75 #define EDGE_FILE    2
 76 #define POLY_FILE    3
 77 #define GEOM_LH      4
 78 #define GEOM_RH      5
 79 #define CAMERA       6
 80 
 81 
 82 int    stereo_input(char *directory_name, char *base_name, int file_type)
 83 {
 84   Imrect *left_im=NULL;
 85   Imrect *right_im=NULL;
 86   char    pathname[MAXPATHLEN];
 87   char    pathname_ext[MAXPATHLEN];
 88   int     retval = 1;
 89 
 90   (void) strip_spaces(base_name);
 91   (void) strip_spaces(directory_name);
 92   (void) string_append(pathname, directory_name, "/", base_name, NULL);
 93 
 94   switch (file_type)
 95     {
 96     case AIFF_FILE:
 97       /* Left image */
 98       (void) string_append(pathname_ext, pathname, ".l.aiff", NULL);
 99       if ((left_im = (Imrect *) aiff_read_image(pathname_ext)))
100         left_image_set(left_im);
101       else
102         {
103           retval = 0;
104           error("stereo_input: null left aiff image", warning);
105         }
106 
107       /* Right image */
108       (void) string_append(pathname_ext, pathname, ".r.aiff", NULL);
109       if ((right_im = (Imrect *) aiff_read_image(pathname_ext)))
110         right_image_set(right_im);
111       else
112         {
113           retval = 0;
114           error("stereo_input: null right aiff image", warning);
115         }
116       break;
117 
118     case EDGE_FILE:
119       {
120         int     height, width;
121         Imrect *im;
122         Imregion *region;
123 
124         /* Left image */
125         if ((im = left_image()))
126           {
127             height = im->height;
128             width = im->width;
129             region = im->region;
130           } 
131         else
132           {
133             height = 256;
134             width = 256;
135             region = NULL;
136           }
137         (void) string_append(pathname_ext, pathname, ".l.edges", NULL);
138         if ((im = edges_read_file(pathname_ext, height, width, region)))
139           left_edges_set(im);
140         else
141           error("stereo_input: null left edges", warning);
142         er_find_edge_strings(im);
143 
144         /* Right image */
145         if ((im = right_image()))
146           {
147             height = im->height;
148             width = im->width;
149             region = im->region;
150           } 
151         else
152           {
153             height = 256;
154             width = 256;
155             region = NULL;
156           }
157         (void) string_append(pathname_ext, pathname, ".r.edges", NULL);
158         if ((im = edges_read_file(pathname_ext, height, width, region)))
159           right_edges_set(im);
160         else
161           error("stereo_input: null right edges", warning);
162         er_find_edge_strings(im);
163         break;
164       }
165     case POLY_FILE:
166       (void) string_append(pathname_ext, pathname, ".l.poly", NULL);
167       left_geom_set(geom2_read(pathname_ext));
168       (void) string_append(pathname_ext, pathname, ".r.poly", NULL);
169       right_geom_set(geom2_read(pathname_ext));
170       break;
171     case GEOM_LH:
172       (void) string_append(pathname_ext, pathname, ".poly", NULL);
173       threed_geom_set(geom3_read(pathname_ext, LEFT));
174       break;
175     case GEOM_RH:
176       (void) string_append(pathname_ext, pathname, ".poly", NULL);
177       threed_geom_set(geom3_read(pathname_ext, RIGHT));
178       break;
179     case CAMERA:
180       left_camera_set(input_camera_file(pathname, ".l"));
181       right_camera_set(input_camera_file(pathname, ".r"));
182       if (left_camera!=NULL&&right_camera!=NULL)
183         pcam_update(left_camera(),right_camera());
184       break;
185     case ROI_FILE:
186       read_stereo_roi(pathname);
187       break;
188     default:
189       error("file type not available", non_fatal);
190       return(retval);
191     }
192   
193   /* Input camera files for aiff images */
194   switch (file_type)
195     {
196     case AIFF_FILE:
197       if (left_im)
198         left_camera_set(input_camera_file(pathname, ".l"));
199       if (right_im)
200         right_camera_set(input_camera_file(pathname, ".r"));
201       if (left_camera!=NULL&&right_camera!=NULL)
202         pcam_update(left_camera(),right_camera());
203       break;
204     }
205   return(retval);
206 }
207 
208 void    stereo_output(char *directory_name, char *base_name, int file_type)
209 {
210   char    pathname[MAXPATHLEN];
211   char    pathname_ext[MAXPATHLEN];
212 
213   (void) strip_spaces(base_name);
214   (void) strip_spaces(directory_name);
215   (void) string_append(pathname, directory_name, "/", base_name, NULL);
216 
217   switch (file_type)
218     {
219     case AIFF_FILE:
220       (void) string_append(pathname_ext, pathname, ".l.aiff", NULL);
221       aiff_write_image(left_image(), pathname_ext);
222       (void) string_append(pathname_ext, pathname, ".r.aiff", NULL);
223       aiff_write_image(right_image(), pathname_ext);
224       break;
225     case EDGE_FILE:
226       (void) string_append(pathname_ext, pathname, ".l.edges", NULL);
227       edges_write_file(pathname_ext, left_edges());
228       (void) string_append(pathname_ext, pathname, ".r.edges", NULL);
229       edges_write_file(pathname_ext, right_edges());
230       break;
231     case POLY_FILE:
232       (void) string_append(pathname_ext, pathname, ".l.poly", NULL);
233       geom2_write(pathname_ext, left_geom_get());
234       (void) string_append(pathname_ext, pathname, ".r.poly", NULL);
235       geom2_write(pathname_ext, right_geom_get());
236       break;
237     case GEOM_LH:
238       (void) string_append(pathname_ext, pathname, ".poly", NULL);
239       geom3_write(pathname_ext, threed_geom_get(), LEFT);
240       break;
241     case GEOM_RH:
242       (void) string_append(pathname_ext, pathname, ".poly", NULL);
243       geom3_write(pathname_ext, threed_geom_get(), RIGHT);
244       break;
245     case CAMERA:
246       (void) string_append(pathname_ext, pathname, ".l.cam", NULL);
247       cam_write(pathname_ext, left_camera(), rdist_write_fp);
248       (void) string_append(pathname_ext, pathname, ".r.cam", NULL);
249       cam_write(pathname_ext, right_camera(), rdist_write_fp);
250       break;
251     case ROI_FILE:
252       write_stereo_roi(pathname);
253       break;
254     default:
255       error("file type not available", non_fatal);
256       return;
257     }
258 }
259 

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