SimulationViewer.H

Go to the documentation of this file.
00001 /*!@file Neuro/SimulationViewer.H visualize various model simulations */
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: Laurent Itti <itti@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/SimulationViewer.H $
00035 // $Id: SimulationViewer.H 14518 2011-02-17 00:48:30Z dberg $
00036 //
00037 
00038 #ifndef SIMULATIONVIEWER_H_DEFINED
00039 #define SIMULATIONVIEWER_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Image/Image.H"
00044 #include "Media/MediaSimEvents.H"
00045 #include "Simulation/SimModule.H"
00046 #include "SpaceVariant/SpaceVariantModule.H"//module for space var
00047 #include "Neuro/WTAwinner.H"//for WTAwinner
00048 #include "Neuro/NeuroSimEvents.H"
00049 
00050 template <class T> class Image;
00051 
00052 //! This class provides an abstract interface for a simulation viewer
00053 /*! Its typical usage is with a model that generates shifts of
00054   attention, eye and head movements. Derivatives from this class will
00055   handle visualizing those events. See SimulationViewerStd.H for an
00056   example of such derivative. The base class described here just
00057   specifies the interface. */
00058 class SimulationViewer : public SimModule {
00059 public:
00060   // ######################################################################
00061   /*! @name Constructors and destructors */
00062   //@{
00063 
00064   //! Constructor. See ModelComponent.H.
00065     /*! @param mgr our ModelManager (see ModelManager.H)
00066       @param descrName descriptive name for human usage
00067       @param tagName name for ParamMap usage */
00068   SimulationViewer(OptionManager& mgr,
00069                    const std::string& descrName = "Simulation Viewer",
00070                    const std::string& tagName = "SimulationViewer");
00071 
00072   //! Destructor
00073   virtual ~SimulationViewer();
00074 
00075   //@}
00076 
00077 protected:
00078   //! Callback for when a new scene description is available
00079   SIMCALLBACK_DECLARE(SimulationViewer, SimEventSceneDescription);
00080 
00081   //! Callback for when a new object description is available
00082   SIMCALLBACK_DECLARE(SimulationViewer, SimEventObjectDescription);
00083 
00084   OModelParam<bool> itsDisplayInterp;  //!< use interpolation to display maps?
00085   OModelParam<float> itsMapFactor;     //!< factor to use to display maps
00086   OModelParam<std::string> itsMapType; //!< type of map to use for displays
00087 
00088   //! Helper function to get the latest ''saliency map''
00089   /*! What is returned here could be SM, AGM, TRM, VCO, etc in
00090     normalized or un-normalized form, depending upon the values of
00091     itsMapFactor and itsMapType. If warn is true an error will be
00092     displayed if no suitable map is found in the event queue */
00093   Image<float> getMap(SimEventQueue& q, const bool warn = true) const;
00094 
00095   //! the map may be in non-cartesian coords, and an inverse may need to be applied
00096   virtual Image<float> inverseMap(const Image<float>& map_image) const
00097   {return map_image; };
00098 };
00099 
00100 // ######################################################################
00101 /*! Its simulation viewer that implements some basic catching of
00102   events and inverse transforms non-cartesian retinal images for
00103   display if necessary */
00104 // ######################################################################
00105 class SimulationViewerAdapter : public SimulationViewer {
00106 public:
00107   // ######################################################################
00108   /*! @name Constructors and destructors */
00109   //@{
00110 
00111   //! Constructor. See ModelComponent.H.
00112     /*! @param mgr our ModelManager (see ModelManager.H)
00113       @param descrName descriptive name for human usage
00114       @param tagName name for ParamMap usage */
00115   SimulationViewerAdapter(OptionManager& mgr,
00116                           const std::string& descrName = "Simulation Viewer",
00117                           const std::string& tagName = "SimulationViewerAdapter");
00118 
00119   //! Destructor
00120   virtual ~SimulationViewerAdapter() { };
00121   
00122   //@}
00123   
00124 protected:
00125   //! Callback for when a new retina image is available
00126   SIMCALLBACK_DECLARE(SimulationViewerAdapter, SimEventRetinaImage);
00127   
00128   //! Callback for when a new attention shift occurs
00129   SIMCALLBACK_DECLARE(SimulationViewerAdapter, SimEventWTAwinner);
00130   
00131   OModelParam<bool> itsInverseRetinal; //!< should we inverse our transforms for display
00132   
00133   Image< PixRGB<byte> > itsInput; // clean input image 
00134   WTAwinner itsCurrFOA;           // current attention position
00135   WTAwinner itsPrevFOA;           // previous attention position
00136 
00137   //! Reset SimulationViewerStd
00138   /*! See the base function in ModelComponent.H for info. */
00139   virtual void reset1();
00140   
00141   //! so derived classes can process retinal images
00142   virtual void doEventRetinaImage(SimEventQueue& q, rutz::shared_ptr<SimEventRetinaImage>& e) { };
00143 
00144   // so derived classes can process wta winners
00145   virtual void doEventWTAwinner(SimEventQueue& q, rutz::shared_ptr<SimEventWTAwinner>& e) { };
00146 
00147   //!inverse a space variant transformed retinal image
00148   Image<float> inverseRetinal(const Image<float>& ret_image) const;
00149   
00150   //!inverse a space variant transformed map
00151   virtual Image<float> inverseMap(const Image<float>& map_image) const;
00152 
00153   //!put a point in retinal coords
00154   void toRetinal(Point2D<int>& point) const;
00155 
00156   //!get a point from retinal coords
00157   void fromRetinal(Point2D<int>& point) const;
00158 
00159   //!get a point from retinal coords at the map level
00160   void fromRetinalMap(Point2D<int>& point) const;
00161 
00162   //! hold potential transforms
00163   nub::ref<SpaceVariantModule> itsTransform;
00164 };
00165 #endif
00166 
00167 // ######################################################################
00168 /* So things look consistent in everyone's emacs... */
00169 /* Local Variables: */
00170 /* indent-tabs-mode: nil */
00171 /* End: */
Generated on Sun May 8 08:41:04 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3