PrefrontalCortex.H

Go to the documentation of this file.
00001 /*!@file Neuro/PrefrontalCortex.H simulation of a human PrefrontalCortex */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Lior Elazary
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/PrefrontalCortex.H $
00035 // $Id: PrefrontalCortex.H 11086 2009-04-03 03:35:14Z lior $
00036 //
00037 
00038 
00039 #ifndef PrefrontalCortex_H_DEFINED
00040 #define PrefrontalCortex_H_DEFINED
00041 
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Component/ParamMap.H"
00045 #include "Media/MediaSimEvents.H"
00046 #include "Neuro/NeuroSimEvents.H"
00047 #include "Simulation/SimModule.H"
00048 
00049 class ModelManager;
00050 class Bayes;
00051 class BayesianBiaser;
00052 
00053 // ######################################################################
00054 //! The PrefrontalCortex base class
00055 /*! The PrefrontalCortex is the entry point to the Brain and VisualCortex,
00056   for now it is only used to load the task-relevant data for biasing. */
00057 class PrefrontalCortex : public SimModule
00058 {
00059 public:
00060   //! Constructor
00061   /*! See ModelComponent.H for details */
00062   PrefrontalCortex(OptionManager& mgr,
00063                    const std::string& descrName = "PrefrontalCortex",
00064                    const std::string& tagName = "PrefrontalCortex");
00065 
00066   //! Destructor
00067   virtual ~PrefrontalCortex();
00068 };
00069 
00070 
00071 // ######################################################################
00072 //! PrefrontalCortex configurator
00073 // ######################################################################
00074 /*! This will export the --PrefrontalCortex-type=XX command-line
00075   option and will instantiate a PrefrontalCortex of the desired type
00076   as the option gets assigned a value. As this happens, new options
00077   may become available in the command-line. To see them, use --help
00078   AFTER you have chosen the type to use. The current PrefrontalCortex
00079   may be retrieved using getPFC(). */
00080 class PrefrontalCortexConfigurator : public ModelComponent
00081 {
00082 public:
00083   //! Constructor
00084   PrefrontalCortexConfigurator(OptionManager& mgr,
00085                      const std::string& descrName =
00086                                "PrefrontalCortex Configurator",
00087                      const std::string& tagName =
00088                                "PrefrontalCortexConfigurator");
00089 
00090   //! destructor
00091   virtual ~PrefrontalCortexConfigurator();
00092 
00093   //! Get the chosen PrefrontalCortex
00094   /*! You should call this during start() of the ModelComponent that
00095       needs the PrefrontalCortex. This is guaranteed to be a non-null object
00096       (though it may be "stub" type, e.g. PrefrontalCortexStub). */
00097   nub::ref<PrefrontalCortex> getPFC() const;
00098 
00099 protected:
00100   OModelParam<std::string> itsType; //!< type of PrefrontalCortex
00101 
00102   //! Intercept people changing our ModelParam
00103   /*! See ModelComponent.H; as parsing the command-line or reading a
00104     config file sets our name, we'll also here instantiate a
00105     PrefrontalCortex of the proper type (and export its options) */
00106   virtual void paramChanged(ModelParamBase* const param,
00107                             const bool valueChanged,
00108                             ParamClient::ChangeStatus* status);
00109 
00110 private:
00111   nub::ref<PrefrontalCortex> itsPFC; // the PrefrontalCortex
00112 };
00113 
00114 // ######################################################################
00115 //! "Stub" PrefrontalCortex implementation
00116 // ######################################################################
00117 /*! Does nothing but copy its input to its output. */
00118 class PrefrontalCortexStub : public PrefrontalCortex
00119 {
00120 public:
00121   //! Constructor
00122   PrefrontalCortexStub(OptionManager& mgr,
00123              const std::string& descrName = "PrefrontalCortexStub",
00124              const std::string& tagName = "PrefrontalCortexStub");
00125 
00126   //! Destructor
00127   virtual ~PrefrontalCortexStub();
00128 };
00129 
00130 // ######################################################################
00131 //! OptimalGains PrefrontalCortex implementation
00132 // ######################################################################
00133 /*! This PFC computes the salience of targets and distractors and
00134   saves that info to a text file. Those text files can later be
00135   combined and used to compute optimal gains, per Navalpakkam & Itti,
00136   IEEE CVPR, 2006. The resulting optimal gains can finally be used to
00137   bias saliency computations, using a PrefrontalCortexGS. */
00138 class PrefrontalCortexOG : public PrefrontalCortex
00139 {
00140 public:
00141   //! Constructor
00142   /*! See ModelComponent.H for details */
00143   PrefrontalCortexOG(OptionManager& mgr,
00144                      const std::string& descrName = "PrefrontalCortexOG",
00145                      const std::string& tagName = "PrefrontalCortexOG");
00146 
00147   //! Destructor
00148   virtual ~PrefrontalCortexOG();
00149 
00150 protected:
00151   //! Callback for when a new input frame is available
00152   SIMCALLBACK_DECLARE(PrefrontalCortexOG, SimEventInputFrame);
00153 
00154   //! Callback for when a new vcx output is ready
00155   SIMCALLBACK_DECLARE(PrefrontalCortexOG, SimEventVisualCortexOutput);
00156 
00157   OModelParam<std::string> itsFilename; //!< file to save sT and sD values
00158   OModelParam<std::string> itsTargetMaskObjName; //!< target mask obj name
00159   OModelParam<std::string> itsDistractorMaskObjName; //!< distractor mask obj name
00160   OModelParam<bool> itsDoMax;
00161   Image<byte> itsTargetMask, itsDistractorMask;
00162 };
00163 
00164 // ######################################################################
00165 //! GuidedSearch PrefrontalCortex implementation
00166 // ######################################################################
00167 /*! This PFC loads up a set of gains and applies them to the submaps
00168   and channels, thereby implementing Jeremy Wolfe's Guided Search
00169   (Wolfe, 1994). */
00170 class PrefrontalCortexGS : public PrefrontalCortex
00171 {
00172 public:
00173   //! Constructor
00174   /*! See ModelComponent.H for details */
00175   PrefrontalCortexGS(OptionManager& mgr,
00176                      const std::string& descrName = "PrefrontalCortexGS",
00177                      const std::string& tagName = "PrefrontalCortexGS");
00178 
00179   //! Destructor
00180   virtual ~PrefrontalCortexGS();
00181 
00182 protected:
00183   //! Callback for when a new input frame is available
00184   SIMCALLBACK_DECLARE(PrefrontalCortexGS, SimEventInputFrame);
00185 
00186   OModelParam<std::string> itsFilename; //!< file to save sT and sD values
00187 };
00188 
00189 // ######################################################################
00190 //! SalBayes PrefrontalCortex implementation
00191 // ######################################################################
00192 class PrefrontalCortexSB : public PrefrontalCortex
00193 {
00194 public:
00195   //! Constructor
00196   /*! See ModelComponent.H for details */
00197   PrefrontalCortexSB(OptionManager& mgr,
00198                            const std::string& descrName =
00199                            "PrefrontalCortexSB",
00200                            const std::string& tagName =
00201                            "PrefrontalCortexSB");
00202 
00203   //! Destructor
00204   virtual ~PrefrontalCortexSB();
00205 
00206 protected:
00207   //! Callback for when a new input frame is available
00208   SIMCALLBACK_DECLARE(PrefrontalCortexSB, SimEventInputFrame);
00209 
00210   OModelParam<std::string> itsBayesNetFilename; //!< The object database
00211   OModelParam<int> itsObjToBias; //!< the object to bias for from the database
00212 
00213   //! get started
00214   virtual void start1();
00215 
00216 private:
00217   rutz::shared_ptr<Bayes> itsBayesNet;
00218 };
00219 
00220 
00221 #endif
00222 
00223 // ######################################################################
00224 /* So things look consistent in everyone's emacs... */
00225 /* Local Variables: */
00226 /* indent-tabs-mode: nil */
00227 /* End: */
Generated on Sun May 8 08:41:03 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3