contrib/gel/gmvl/gmvl_helpers.cxx
Go to the documentation of this file.
00001 // This is gel/gmvl/gmvl_helpers.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author crossge@crd.ge.com
00008 
00009 #include "gmvl_helpers.h"
00010 
00011 #include <vcl_iostream.h>
00012 #include <vcl_fstream.h>
00013 #include <vil1/vil1_image.h>
00014 #include <vil1/vil1_load.h>
00015 #include <gmvl/gmvl_corner_node.h>
00016 #include <gmvl/gmvl_image_node.h>
00017 
00018 
00019 // input output
00020 vcl_ostream &operator<<( vcl_ostream &os, const vcl_vector<gmvl_node_sptr> &r)
00021 {
00022   for (unsigned int i=0; i< r.size(); ++i) os << *r[i];
00023   return os;
00024 }
00025 
00026 
00027 // loaders and savers
00028 
00029 vcl_vector<gmvl_node_sptr> gmvl_load_raw_corners( const vcl_string filename)
00030 {
00031   vcl_vector<gmvl_node_sptr> corners;
00032 
00033   vcl_ifstream fin( filename.c_str());
00034 
00035   while (fin.good() && !fin.eof())
00036     {
00037       double x,y;
00038 
00039       fin >> x >> y;
00040 
00041       if (fin.good()) corners.push_back( new gmvl_corner_node( x, y));
00042     }
00043 
00044   vcl_cerr << "gmvl_load_raw_corners: loaded " << corners.size() << " corners from " << filename << vcl_endl;
00045 
00046   return corners;
00047 }
00048 
00049 gmvl_node_sptr gmvl_load_image( const vcl_string filename)
00050 {
00051   vil1_image image= vil1_load( filename.c_str());
00052   gmvl_image_node *node= new gmvl_image_node( image);
00053 
00054   if (image)
00055     vcl_cerr << "gmvl_load_image: load image from " << filename << vcl_endl;
00056   else
00057     vcl_cerr << "gmvl_load_image: failed to load image from " << filename << vcl_endl;
00058 
00059   return gmvl_node_sptr( node);
00060 }