contrib/brl/bseg/vpro/vpro_video_process.h
Go to the documentation of this file.
00001 
00002 // This is brl/bseg/vpro/vpro_video_process.h
00003 #ifndef vpro_video_process_h_
00004 #define vpro_video_process_h_
00005 //--------------------------------------------------------------------------------
00006 //:
00007 // \file
00008 // \brief live vpro_video_process
00009 //
00010 //  A generic video processor that is called from the live_video_manager
00011 //  to carry out algorithms on the live video frames.
00012 // \author
00013 //   J.L. Mundy
00014 // \date
00015 //   October 9, 2002    Initial version.
00016 //
00017 // \verbatim
00018 //  Modifications
00019 //   10-sep-2004 Peter Vanroose Added copy ctor with explicit vbl_ref_count init
00020 // \endverbatim
00021 //--------------------------------------------------------------------------------
00022 #include <vcl_vector.h>
00023 #include <vil1/vil1_image.h>
00024 #include <vbl/vbl_ref_count.h>
00025 #include <vsol/vsol_spatial_object_2d.h>
00026 #include <vtol/vtol_topology_object.h>
00027 
00028 class vpro_video_process : public vbl_ref_count
00029 {
00030  public:
00031   enum process_data_type {NOTYPE=0, IMAGE, SPATIAL_OBJECT, TOPOLOGY, IMAGE_SPATIAL_OBJECT};
00032 
00033   vpro_video_process();
00034   vpro_video_process(vpro_video_process const& p)
00035     : vbl_ref_count(),
00036       frame_index_(p.frame_index_), n_frames_(p.n_frames_),
00037       input_images_(p.input_images_),
00038       input_spat_objs_(p.input_spat_objs_),
00039       input_topo_objs_(p.input_topo_objs_),
00040       output_image_(p.output_image_),
00041       output_topo_objs_(p.output_topo_objs_),
00042       output_spat_objs_(p.output_spat_objs_) {}
00043   virtual ~vpro_video_process() {}
00044   void clear_input();
00045   void clear_output();
00046 
00047 
00048   void set_n_frames(int n_frames) { n_frames_ = n_frames; }
00049   void set_frame_index(int index) { frame_index_= index; }
00050 
00051   void add_input_image(vil1_image const& im) { input_images_.push_back(im); }
00052 
00053   void add_input_spatial_object(vsol_spatial_object_2d_sptr const& so);
00054 
00055   void add_input_spatial_objects(vcl_vector<vsol_spatial_object_2d_sptr> const& spat_objs);
00056 
00057   void add_input_topology_object(vtol_topology_object_sptr const& to);
00058 
00059   void add_input_topology(vcl_vector<vtol_topology_object_sptr> const& topo_objs);
00060 
00061   int n_frames() const { return n_frames_; }
00062   int frame_index() const { return frame_index_; }
00063   int get_N_input_images() const { return input_images_.size(); }
00064   vil1_image get_input_image(unsigned int i);
00065   vil1_image get_output_image() { return output_image_; }
00066 
00067   int get_N_input_spat_objs() const { return input_spat_objs_.size(); }
00068   vcl_vector<vsol_spatial_object_2d_sptr> const& get_input_spatial_objects()
00069   { return input_spat_objs_; }
00070 
00071   int get_N_input_topo_objs() const { return input_topo_objs_.size(); }
00072   vcl_vector<vtol_topology_object_sptr> const& get_input_topology()
00073   { return input_topo_objs_; }
00074 
00075 
00076   //:output handling may depend on the specific process
00077   virtual vcl_vector<vsol_spatial_object_2d_sptr> const& get_output_spatial_objects()
00078   { return output_spat_objs_; }
00079 
00080   virtual vcl_vector<vtol_topology_object_sptr> const & get_output_topology()
00081   { return output_topo_objs_; }
00082 
00083   //graph output for data display
00084   void set_graph_flag(){graph_flag_ = true;}
00085   void clear_graph_flag(){graph_flag_ = false;}
00086   bool graph_flag() const {return graph_flag_;}
00087   void  set_graph(vcl_vector<float> const& graph){graph_=graph;}
00088   vcl_vector<float> graph() const {return graph_;}
00089   //start and end of processed sequence
00090   unsigned int start_frame() const {return start_frame_;}
00091   unsigned int end_frame() const {return end_frame_;}
00092 
00093   virtual process_data_type get_input_type() const { return NOTYPE; }
00094   virtual process_data_type get_output_type() const { return NOTYPE; }
00095   virtual bool execute()=0;
00096   virtual bool finish()=0;
00097  protected:
00098   //members
00099   int frame_index_;
00100   int n_frames_;
00101   unsigned int start_frame_;//start of the processed sequence
00102   unsigned int end_frame_;  //end of the processed sequence
00103   vcl_vector<vil1_image> input_images_;
00104   vcl_vector<vsol_spatial_object_2d_sptr> input_spat_objs_;
00105   vcl_vector<vtol_topology_object_sptr> input_topo_objs_;
00106   vil1_image output_image_;
00107   vcl_vector<vtol_topology_object_sptr> output_topo_objs_;
00108   vcl_vector<vsol_spatial_object_2d_sptr> output_spat_objs_;
00109   bool graph_flag_;
00110   vcl_vector<float> graph_;//for histograms and other plots
00111 };
00112 
00113 #endif // vpro_video_process_h_