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

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

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

  1 /*
  2         roi_file.c
  3 
  4         reading and writing of stereo ROI files
  5 */
  6 
  7 #include <stdio.h>
  8 #include <sys/param.h>
  9 #include <string.h>
 10 #include <tina/sys.h>
 11 #include <tina/sysfuncs.h>
 12 #include <tina/math.h>
 13 #include <tina/vision.h>
 14 #include <tina/visionfuncs.h>
 15 #include <tina/tv.h>
 16 #include <tina/tvfuncs.h>
 17 #include <tina/file.h>
 18 #include <tina/filefuncs.h>
 19 #include <tina/file_gen.h>
 20 #include <tina/toolsfuncs.h>
 21  
 22 void read_stereo_roi(char *fname)
 23 {
 24   FILE *fp = NULL;
 25   int lxl, lxr, uxl, uxr, lyl, lyr, uyl, uyr;
 26 
 27   if (fname == NULL)
 28     {
 29       error("read_stereo_roi : invalid filename", warning);
 30       return;
 31     }
 32 
 33   if ((fp = fopen(fname, "r")) == NULL)
 34     {
 35       error("read_stereo_roi : cannot open file", warning);
 36       return;
 37     }
 38 
 39   fscanf(fp, "%d %d %d %d ", &lxl, &lyl, &uxl, &uyl);
 40   fscanf(fp, "%d %d %d %d ", &lxr, &lyr, &uxr, &uyr);
 41   fclose(fp);
 42 
 43   tv_set_roi(left_tv_get(), roi_alloc(lxl, lyl, uxl, uyl));
 44   tv_set_roi(right_tv_get(), roi_alloc(lxr, lyr, uxr, uyr));
 45 }
 46 
 47 void write_stereo_roi(char *fname)
 48 {
 49   FILE *fp = NULL;
 50   Imregion *roil = NULL, *roir = NULL;
 51   
 52   if (fname == NULL)
 53     {
 54       error("write_stereo_roi : invalid filename", warning);
 55       return;
 56     }
 57 
 58   if ((fp = fopen(fname, "w")) == NULL)
 59     {
 60       error("write_stereo_roi : cannot open file", warning);
 61       return;
 62     }
 63 
 64   roil = tv_get_im_roi(left_tv_get());
 65   roir = tv_get_im_roi(right_tv_get());
 66 
 67   if ((roil == NULL) || (roir == NULL))
 68     {
 69       error("write_stereo_roi : no left or right roi data", warning);
 70       fclose(fp);
 71       return;
 72     }
 73 
 74   fprintf(fp, "%d %d %d %d ", roil->lx, roil->ly, roil->ux, roil->uy);
 75   fprintf(fp, "%d %d %d %d ", roir->lx, roir->ly, roir->ux, roir->uy);
 76   fclose(fp);
 77 
 78   rfree(roil);
 79   rfree(roir);
 80 }
 81 
 82 
 83 

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