Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

strk_track_display_process.cxx

Go to the documentation of this file.
00001 // This is brl/bseg/strk/strk_track_display_process.cxx
00002 #include "strk_track_display_process.h"
00003 #include <vcl_iostream.h>
00004 #include <vcl_vector.h>
00005 #include <vtol/vtol_topology_object.h>
00006 #include <vtol/vtol_vertex.h>
00007 #include <vtol/vtol_edge.h>
00008 #include <vtol/vtol_vertex_2d.h>
00009 #include <vtol/vtol_face_2d.h>
00010 #include <strk/strk_io.h>
00011 strk_track_display_process::strk_track_display_process()
00012 {
00013   failure_ = false;
00014   first_frame_ = true;
00015 }
00016 
00017 strk_track_display_process::~strk_track_display_process()
00018 {
00019 }
00020 
00021 bool strk_track_display_process::execute()
00022 {
00023   if (failure_)
00024     return false;
00025   if (this->get_N_input_images()!=1)
00026   {
00027     vcl_cout << "In strk_track_display_process::execute() -"
00028              << " not exactly one input image\n";
00029     failure_ = true;
00030     return false;
00031   }
00032   output_topo_objs_.clear();
00033   input_images_.clear();
00034   static int n_faces = 0;
00035   if (first_frame_)
00036   {
00037     first_frame_ = false;
00038     n_faces = tracked_faces_.size();
00039     if (!n_faces)
00040     {
00041       vcl_cout << "In strk_track_display_process::execute() -"
00042                << " no faces found in track file\n";
00043       failure_ = true;
00044     }
00045   }
00046   int frame_index = this->frame_index();
00047   int offset = frame_index-start_frame_;
00048   if (offset<0||offset>=n_faces)
00049     return false;
00050   vtol_face_2d_sptr f = tracked_faces_[offset];
00051   vcl_vector<vtol_edge_sptr> edges;
00052   f->edges(edges);
00053   //cog
00054   vgl_point_2d<double> p = tracked_cogs_[offset];
00055   vtol_topology_object_sptr to = new vtol_vertex_2d(p.x(), p.y());
00056   output_topo_objs_.push_back(to);
00057   //edges
00058   for (vcl_vector<vtol_edge_sptr>::iterator eit = edges.begin();
00059        eit != edges.end(); eit++)
00060   {
00061     to = (*eit)->cast_to_edge();
00062     output_topo_objs_.push_back(to);
00063   }
00064   return true;
00065 }
00066 
00067 bool strk_track_display_process::set_input_file(vcl_string const& file_name)
00068 {
00069   start_frame_ = 0;
00070   track_file_ = file_name;
00071   if (track_file_=="")
00072     return false;
00073   vcl_ifstream str(track_file_.c_str());
00074   if (!str)
00075   {
00076     vcl_cout << "In strk_track_display_process::set_input_file() -"
00077              << " could not open file " << track_file_ << '\n';
00078     return false;
00079   }
00080   unsigned int n_frames = 0;
00081   if(!strk_io::read_track_data(str, start_frame_, n_frames,
00082                            tracked_cogs_, tracked_faces_))
00083     {
00084       str.close();
00085       return false;
00086     }
00087   end_frame_ = start_frame_+n_frames -1;
00088   str.close();
00089   return true;
00090 }

Generated on Thu Jan 10 14:53:19 2008 for contrib/brl/bseg/strk by  doxygen 1.4.4