contrib/rpl/rgrl/rgrl_initializer_reader.h
Go to the documentation of this file.
00001 #ifndef rgrl_initializer_reader_h_
00002 #define rgrl_initializer_reader_h_
00003 //:
00004 // \file
00005 // \brief Generate initial estimates based on prior transformations in input stream.
00006 // \author Gehua Yang
00007 // \date 16 Feb 2005
00008 
00009 #include <vcl_vector.h>
00010 #include <vcl_iosfwd.h>
00011 
00012 #include <rgrl/rgrl_initializer.h>
00013 #include <rgrl/rgrl_scale_sptr.h>
00014 #include <rgrl/rgrl_mask.h>
00015 #include <rgrl/rgrl_mask_sptr.h>
00016 #include <rgrl/rgrl_transformation_sptr.h>
00017 
00018 //: Generate initial estimates based on a single prior transformation.
00019 class rgrl_initializer_reader
00020   : public rgrl_initializer
00021 {
00022  public:
00023   //: Initialize with a view
00024   rgrl_initializer_reader( vcl_istream& istr,
00025                            rgrl_mask_sptr             const& from_image_roi,
00026                            rgrl_mask_sptr             const& to_image_roi,
00027                            rgrl_scale_sptr            const& prior_scale=0,
00028                            rgrl_estimator_sptr        const& estimator = 0,
00029                            unsigned int                      resolution = 0 );
00030 
00031   //: Add more potential prior transformations
00032   void add_prior_xform( rgrl_transformation_sptr   xform_estimate );
00033 
00034   //: Get next initial estimate when first called, but return false thereafter.
00035   bool next_initial( rgrl_view_sptr           & view,
00036                      rgrl_scale_sptr          & prior_scale );
00037 
00038   //: Set index pointing to vector of initializations to zero.
00039   void reset_xform_index( ) { xform_index_ = 0; }
00040 
00041   //: Set index pointing to the vector of initializations to a given value.
00042   void set_xform_index( unsigned int index ) { xform_index_ = index; }
00043 
00044   //: Return number of initializations
00045   //  -1 stands for unknown
00046   virtual int size() const;
00047 
00048   //: Defines type-related functions
00049   rgrl_type_macro( rgrl_initializer_reader, rgrl_initializer );
00050 
00051  protected:
00052 
00053   struct init_record {
00054     rgrl_view_sptr            view_;
00055     rgrl_scale_sptr           scale_;
00056     rgrl_transformation_sptr  xform_;
00057   };
00058 
00059   //: Initializations read from a stream
00060   vcl_vector< init_record >           init_records_;
00061 
00062   //: Index pointing into initialization in init_records_ vector that will be used
00063   unsigned int xform_index_;
00064 
00065   rgrl_mask_sptr       from_image_roi_;
00066   rgrl_mask_sptr       to_image_roi_;
00067   rgrl_scale_sptr      prior_scale_;
00068   rgrl_estimator_sptr  estimator_;
00069   unsigned int         res_;
00070 };
00071 
00072 #endif