Beobot2_GistSalLocalizerWorker.H

Go to the documentation of this file.
00001 /*!@file                                                                */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Christian Siagian <siagian@usc.edu>
00033 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/Beobot2/Localization/Beobot2_GistSalLocalizerWorker.H $
00034 // $Id: Beobot2_GistSalLocalizerWorker.H 12962 2010-03-06 02:13:53Z irock $
00035 //
00036 
00037 #include "Component/ModelComponent.H"
00038 #include "Component/ModelParam.H"
00039 
00040 #include "GUI/XWinManaged.H"
00041 
00042 #include "Beobot/GSlocalizer.H"
00043 #include "Beobot/Landmark.H"
00044 #include "SIFT/Histogram.H"
00045 #include "Beobot/GSparticle.H"
00046 #include "Beobot/Environment.H"
00047 #include "Util/Timer.H"
00048 
00049 
00050 
00051 #include "Robots/RobotBrain/RobotBrainComponent.H"
00052 #include "Ice/RobotBrainObjects.ice.H"
00053 #include "Ice/BeobotEvents.ice.H"
00054 #include "Ice/IceImageUtils.H"
00055 #include <IceUtil/Thread.h>
00056 
00057 #ifndef BEOBOT2_GISTSALLOCALIZERWORKERI_H
00058 #define BEOBOT2_GISTSALLOCALIZERWORKERI_H
00059 
00060 class Beobot2_GistSalLocalizerWorkerI : public RobotBrainComponent
00061 {
00062 public:
00063 
00064   Beobot2_GistSalLocalizerWorkerI(OptionManager& mgr,
00065       const std::string& descrName = "Beobot2_GistSalLocalizerWorker",
00066       const std::string& tagName = "Beobot2_GistSalLocalizerWorker");
00067 
00068   ~Beobot2_GistSalLocalizerWorkerI();
00069 
00070   //! Get started. See ModelComponent.
00071   virtual void start1();
00072 
00073   virtual void evolve();
00074 
00075   //!Get a message
00076   virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00077       const Ice::Current&);
00078 
00079   virtual void registerTopics();
00080 
00081 //   //! set the prefix of file to save data  - has to be done
00082 //   void setSavePrefix(std::string prefix);
00083 
00084   //! set the environment - has to be done
00085   void setEnvironment(rutz::shared_ptr<Environment> env);
00086 
00087   //! set worker index and total number of workers
00088   void setWorkerInformation(uint index, uint totalNumWorkers);
00089 
00090   //@}
00091 
00092 private:
00093 
00094 //   // ######################################################################
00095 //   /*! @name private functions */
00096 //   //@{
00097 
00098   //! compute match
00099   void compute(GSlocJobData cjob);
00100 
00101   //! get the match image
00102   Image<PixRGB<byte> > getMatchImage(uint index, Dims d);
00103 
00104 //   //! get the match
00105 //   GSlocJobData getMatch(uint index);
00106 
00107 //   //@}
00108 
00109 //   //!  file prefix to save data
00110 //   std::string itsSavePrefix;
00111 
00112   //! all the environment information
00113   rutz::shared_ptr<Environment> itsEnvironment;
00114 
00115   //! from its environment: topological map
00116   rutz::shared_ptr<TopologicalMap> itsTopologicalMap;
00117 
00118   //! from its environment: visual landmark database
00119   rutz::shared_ptr<LandmarkDB> itsLandmarkDB;
00120 
00121   //! the input image, visual objects, and gist
00122   Image<PixRGB<byte> > itsInputImage;
00123   std::vector<rutz::shared_ptr<VisualObject> > itsInputVO;
00124   std::vector<bool> itsVOKeypointsComputed;
00125   std::vector<Point2D<int> > itsInputObjOffset;
00126   //  Image<double> itsInputGist;
00127 
00128 
00129 //   int itsInputFnum;
00130 //   int itsSearchInputFnum;
00131 
00132 //   //! ground truth information - default to (0,0.0)
00133 //   uint  itsSnumGT;
00134 //   float itsLtravGT;
00135 
00136 //   //! the current robot movement
00137 //   float itsRobotDx;
00138 //   float itsRobotDy;
00139 
00140 //   //! segment histogram from the classifier
00141 //   rutz::shared_ptr<Histogram> itsSegmentHistogram;
00142 
00143   //! result of search
00144   //std::vector<Image<PixRGB<byte> > > itsVOmatchImage;
00145   std::vector<rutz::shared_ptr<VisualObjectMatch> > itsVOmatch;
00146   std::vector<GSlocJobData> itsLmkMatch;
00147   std::vector<uint> itsSegNumMatch;
00148   std::vector<float> itsLenTravMatch;
00149   std::vector<bool> itsMatchFound;
00150   std::vector<uint> itsNumObjectSearch;
00151 
00152 //   //! resulting geographic location
00153 //   uint itsSegmentLocation;
00154 //   float itsSegmentLengthTraveled;
00155 //   Point2D<int> itsLocation;
00156 
00157 //   //! job queue and number of jobs to do
00158 //   //! Note: they are on jobLock
00159   std::list<GSlocJobData> itsJobQueue;
00160 //   bool itsIsQueueSorted;         //!< note if the queue is sorted
00161   uint itsNumJobsProcessed;      //!< number of jobs that has been processed
00162 //   uint itsLastSuccessfulJob;     //!< job index last found
00163 //   uint itsNumObjectFound;        //!< number of objects found
00164 //   uint itsNumJobs;               //!< original number of jobs
00165    bool itsEmptyQueue;            //!< stop search request
00166 
00167 //   //! segment histogram from the belief particles
00168 //   rutz::shared_ptr<Histogram> itsSegmentBeliefHistogram;
00169 
00170 //   //! especially for input
00171 //   bool itsOutputReady2;
00172 
00173   //! locks
00174   IceUtil::Mutex its_job_queue_mutex;  //!< locking jobQueue
00175 //   pthread_mutex_t fnumLock;      //!< locking frame number
00176 //   pthread_mutex_t or2Lock;       //!< locking itsOutputReady2
00177 //   pthread_mutex_t stopSearchLock;//!< locking stop search
00178   IceUtil::Mutex its_results_mutex;  //!< locking results
00179   IceUtil::Mutex its_input_info_mutex;  //!< locking the input information
00180 //   pthread_mutex_t particleLock;  //!< locking belief particles
00181 
00182   rutz::shared_ptr<XWinManaged> itsInputWin;
00183 
00184 //   rutz::shared_ptr<Timer> itsTimer;
00185 
00186   int itsInputFnum;
00187   int itsLastSearchDone;
00188 
00189   uint itsWorkerIndex;
00190   uint itsNumWorkers;
00191 };
00192 
00193 // ######################################################################
00194 // Implementation for Beobot2_GisSalLocalizerWorker inline functions
00195 // ######################################################################
00196 
00197 
00198 #endif
00199 
00200 // ######################################################################
00201 /* So things look consistent in everyone's emacs... */
00202 /* Local Variables: */
00203 /* indent-tabs-mode: nil */
00204 /* End: */
Generated on Sun May 8 08:05:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3