pgh_scene.h

Go to the documentation of this file.
00001 //
00002 // scene image stuff. need a separate class to collate all the
00003 // comparison results etc. 
00004 // 
00005 // stuart meikle 
00006 // Thu May 11 13:05:23 2000
00007 //
00008 
00009 // scene objects are also pgh_2dobject objects as there are a flat series of lines
00010 // which are converted into pghs.
00011 
00012 // bpa - Tue Apr 17 13:49:36 BST 2001
00013 // Added new addModel function
00014 //  addModel("pgm_filename","model_name")
00015 // NOT WORKING PROPERLY! DO NOT USE
00016 
00017 #ifndef PGH_SCENE_H
00018 #define PGH_SCENE_H
00019 
00020 #include <boost/shared_array.hpp>
00021 #include <string>
00022 #include <list>
00023 #include <sys/time.h>
00024 #include "mimasconfig.h"
00025 #include "object.h"
00026 #include "pgh_2dobject.h"
00027 #include "object_instance_list.h"
00028 #include "image.h"
00029 
00030 //think through the algo a bit:-
00031 //(1) register all the objects we're interested in finding.
00032 //    create histograms for them all and all that
00033 //(2) compare each scene line to each of the lines of each of the objects
00034 //    we need to store the response of each SCENE line to each line in each object
00035 //    (not the response of each object line to each scene line)
00036 
00037 //for each scene line
00038 //
00039 
00040 //
00041 // NOTE TO DEVELOPERS: the scene class (this one) will take control of all
00042 // pointed to data structures passed in. ie if you pass a pointer to an object
00043 // into addModel then that structure will be deleted when this class is destroyed.
00044 //
00045 namespace mimas {
00109 class pgh_scene : public pgh_2dobject
00110 {
00111     //NOTE: the input camera scene is a 2d pgh object in its own right.
00112 
00113 
00117     class scene_match_score
00118     {
00119         public:
00120         double  best_match;
00121         pgh_ptr object_pgh;
00122         line_ptr object_line;
00123     };
00124  
00125     typedef boost::shared_array< scene_match_score > scene_match_score_array;
00126     typedef std::list< scene_match_score_array > scene_match_score_array_list;
00127     typedef pgh_2dobject_ptr_list::iterator     obj_it;
00128     typedef scene_match_score_array_list::iterator    sms_it;
00129     typedef enum { long_lines, short_lines, points }  pgh_loc_type;
00130 
00131 
00132     private:
00133   pgh_2dobject_ptr_list objects_of_interest;
00134 
00135         //this is essentially like Class definitions
00136         //  object_instance_list  instances;
00137         //for each of the objects_of_interest
00138         //we have a list of all of the found instances
00139         //(if they have been searched for)
00140 
00141      // std::list<bool>   we_created_obj;///<store bool for each of objects of interest which says if this class created it
00142         //not all of the object line data will be created by this
00143         //class -> we shouldn't delete external data!
00144 
00145    scene_match_score_array_list match_score_list;
00146         //each element is scene_match_score[ num_scene_lines ]
00147         //one entry per object here.
00148 
00149 #ifdef HAVE_GETTIMEOFDAY
00150   struct timeval    timestamp;
00151 #endif
00152   pgh_loc_type    location_hough_type;
00153 
00154         //info regarding how this set of scene lines relates to the
00155         //underlying image. non-ideal!
00156 
00157   double      centroid_posn_x;
00158   double      centroid_posn_y;
00159         //the co-ordinates of the set of scene lines centroid on
00160         //the original image. a bit weird...
00161 
00162   int     image_height, image_width;
00163         //size of the attached camera image
00164 
00165 
00166   //funcs:
00167   object_instance_list_ptr locateObject( scene_match_score_array match_array, pgh_2dobject_ptr ob );
00168   object_instance_list_ptr locateObject_longLines( scene_match_score_array match_array , pgh_2dobject_ptr ob );
00169   object_instance_list_ptr locateObject_points( scene_match_score_array match_array , pgh_2dobject_ptr ob );
00170   angle orientObject( scene_match_score_array match_array , pgh_2dobject &ob, const Vector &loc );
00171 
00172 
00173     public:
00174   pgh_scene(void);
00175   ~pgh_scene(void);
00176 
00177   // added by fbc, 15.11.01
00178   void      clear(void);
00179 
00180 
00181   void      addModel( const line_ptr_list &geom,
00182                          const std::string &name );
00183   void      addModel( pgh_2dobject_ptr ob );
00184   // void     addModel( pgh_2dobject *ob, bool wco );
00185 
00186   // following was added by bpa
00187   // NOT WORKING PROPERLY! DO NOT USE
00188   void      addModel(char *pgmfilename , const char *modelname );
00189 
00190 
00191   object_instance_list_ptr findModel( pgh_2dobject_ptr ob );
00192   void      updateSceneLines( const line_ptr_list &newscene, int w, int h );
00193 
00194   // added by bpa
00195   void      updateSceneLines(char *newscenePGM, int w, int h );
00196   void      updateSceneLines( image<int> &imagein);
00197 
00198   // modified by fbc, 17.12.01
00199   void      updateSceneLines( image<int> &imagein, char *polyfilename);
00200 
00201 
00202   int     getNumScenePGHs(void);
00203   pgh_ptr_list *getScenePghList(void);
00204   // shifted here so that user can change value
00205   bool      prefiltering;
00206   double      pgh_match_thresh;    //(becoming a bit of a mess i think! -stu)
00207   double      hough_peak_thresh;
00208 #ifdef HAVE_XALAN
00209   // added by Jan Wedekind
00210   // save parameters to xml-file. Returns true on success.
00211   void saveSceneParameters( const char *fileName );
00212   // load parameters from xml-file. Returns true on success.
00213   void loadSceneParameters( const char *fileName );
00214 #endif
00215 };
00216 
00217 }
00218 
00219 #endif

[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:17 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...