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

Linux Cross Reference
Tina4/src/tools/stereo/ster_file.c

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

  1 #include <stdio.h>
  2 #include <sys/param.h>
  3 #include <string.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 #include <tina/tv.h>
 10 #include <tina/tvfuncs.h>
 11 #include <tina/file.h>
 12 #include <tina/filefuncs.h>
 13 #include <tina/file_gen.h>
 14 #include <tina/toolsfuncs.h>
 15 
 16 #define AIFF_FILE    0
 17 #define ROI_FILE     1
 18 #define EDGE_FILE    2
 19 #define POLY_FILE    3
 20 #define GEOM_LH      4
 21 #define GEOM_RH      5
 22 #define CAMERA       6
 23 
 24 int    stereo_input(char *directory_name, char *base_name, int file_type)
 25 {
 26   Imrect *left_im=NULL;
 27   Imrect *right_im=NULL;
 28   char    pathname[MAXPATHLEN];
 29   char    pathname_ext[MAXPATHLEN];
 30   int     retval = 1;
 31 
 32   (void) strip_spaces(base_name);
 33   (void) strip_spaces(directory_name);
 34   (void) string_append(pathname, directory_name, "/", base_name, NULL);
 35 
 36   switch (file_type)
 37     {
 38     case AIFF_FILE:
 39       /* Left image */
 40       (void) string_append(pathname_ext, pathname, ".l.aiff", NULL);
 41       if ((left_im = (Imrect *) aiff_read_image(pathname_ext)))
 42         left_image_set(left_im);
 43       else
 44         {
 45           retval = 0;
 46           error("stereo_input: null left aiff image", warning);
 47         }
 48 
 49       /* Right image */
 50       (void) string_append(pathname_ext, pathname, ".r.aiff", NULL);
 51       if ((right_im = (Imrect *) aiff_read_image(pathname_ext)))
 52         right_image_set(right_im);
 53       else
 54         {
 55           retval = 0;
 56           error("stereo_input: null right aiff image", warning);
 57         }
 58       break;
 59 
 60     case EDGE_FILE:
 61       {
 62         int     height, width;
 63         Imrect *im;
 64         Imregion *region;
 65 
 66         /* Left image */
 67         if ((im = left_image()))
 68           {
 69             height = im->height;
 70             width = im->width;
 71             region = im->region;
 72           } 
 73         else
 74           {
 75             height = 256;
 76             width = 256;
 77             region = NULL;
 78           }
 79         (void) string_append(pathname_ext, pathname, ".l.edges", NULL);
 80         if ((im = edges_read_file(pathname_ext, height, width, region)))
 81           left_edges_set(im);
 82         else
 83           error("stereo_input: null left edges", warning);
 84         er_find_edge_strings(im);
 85 
 86         /* Right image */
 87         if ((im = right_image()))
 88           {
 89             height = im->height;
 90             width = im->width;
 91             region = im->region;
 92           } 
 93         else
 94           {
 95             height = 256;
 96             width = 256;
 97             region = NULL;
 98           }
 99         (void) string_append(pathname_ext, pathname, ".r.edges", NULL);
100         if ((im = edges_read_file(pathname_ext, height, width, region)))
101           right_edges_set(im);
102         else
103           error("stereo_input: null right edges", warning);
104         er_find_edge_strings(im);
105         break;
106       }
107     case POLY_FILE:
108       (void) string_append(pathname_ext, pathname, ".l.poly", NULL);
109       left_geom_set(geom2_read(pathname_ext));
110       (void) string_append(pathname_ext, pathname, ".r.poly", NULL);
111       right_geom_set(geom2_read(pathname_ext));
112       break;
113     case GEOM_LH:
114       (void) string_append(pathname_ext, pathname, ".poly", NULL);
115       threed_geom_set(geom3_read(pathname_ext, LEFT));
116       break;
117     case GEOM_RH:
118       (void) string_append(pathname_ext, pathname, ".poly", NULL);
119       threed_geom_set(geom3_read(pathname_ext, RIGHT));
120       break;
121     case CAMERA:
122       left_camera_set(input_camera_file(pathname, ".l"));
123       right_camera_set(input_camera_file(pathname, ".r"));
124       if (left_camera!=NULL&&right_camera!=NULL)
125         pcam_update(left_camera(),right_camera());
126       break;
127     case ROI_FILE:
128       read_stereo_roi(pathname);
129       break;
130     default:
131       error("file type not available", non_fatal);
132       return(retval);
133     }
134   
135   /* Input camera files for aiff images */
136   switch (file_type)
137     {
138     case AIFF_FILE:
139       if (left_im)
140         left_camera_set(input_camera_file(pathname, ".l"));
141       if (right_im)
142         right_camera_set(input_camera_file(pathname, ".r"));
143       if (left_camera!=NULL&&right_camera!=NULL)
144         pcam_update(left_camera(),right_camera());
145       break;
146     }
147   return(retval);
148 }
149 
150 void    stereo_output(char *directory_name, char *base_name, int file_type)
151 {
152   char    pathname[MAXPATHLEN];
153   char    pathname_ext[MAXPATHLEN];
154 
155   (void) strip_spaces(base_name);
156   (void) strip_spaces(directory_name);
157   (void) string_append(pathname, directory_name, "/", base_name, NULL);
158 
159   switch (file_type)
160     {
161     case AIFF_FILE:
162       (void) string_append(pathname_ext, pathname, ".l.aiff", NULL);
163       aiff_write_image(left_image(), pathname_ext);
164       (void) string_append(pathname_ext, pathname, ".r.aiff", NULL);
165       aiff_write_image(right_image(), pathname_ext);
166       break;
167     case EDGE_FILE:
168       (void) string_append(pathname_ext, pathname, ".l.edges", NULL);
169       edges_write_file(pathname_ext, left_edges());
170       (void) string_append(pathname_ext, pathname, ".r.edges", NULL);
171       edges_write_file(pathname_ext, right_edges());
172       break;
173     case POLY_FILE:
174       (void) string_append(pathname_ext, pathname, ".l.poly", NULL);
175       geom2_write(pathname_ext, left_geom_get());
176       (void) string_append(pathname_ext, pathname, ".r.poly", NULL);
177       geom2_write(pathname_ext, right_geom_get());
178       break;
179     case GEOM_LH:
180       (void) string_append(pathname_ext, pathname, ".poly", NULL);
181       geom3_write(pathname_ext, threed_geom_get(), LEFT);
182       break;
183     case GEOM_RH:
184       (void) string_append(pathname_ext, pathname, ".poly", NULL);
185       geom3_write(pathname_ext, threed_geom_get(), RIGHT);
186       break;
187     case CAMERA:
188       (void) string_append(pathname_ext, pathname, ".l.cam", NULL);
189       cam_write(pathname_ext, left_camera(), rdist_write_fp);
190       (void) string_append(pathname_ext, pathname, ".r.cam", NULL);
191       cam_write(pathname_ext, right_camera(), rdist_write_fp);
192       break;
193     case ROI_FILE:
194       write_stereo_roi(pathname);
195       break;
196     default:
197       error("file type not available", non_fatal);
198       return;
199     }
200 }
201 

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