00001 /*!@file Neuro/SimulationViewerEyeMvt.H comparison between saliency and 00002 human eye movements */ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 00006 // by the University of Southern California (USC) and the iLab at USC. // 00007 // See http://iLab.usc.edu for information about this project. // 00008 // //////////////////////////////////////////////////////////////////// // 00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00011 // in Visual Environments, and Applications'' by Christof Koch and // 00012 // Laurent Itti, California Institute of Technology, 2001 (patent // 00013 // pending; application number 09/912,225 filed July 23, 2001; see // 00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00015 // //////////////////////////////////////////////////////////////////// // 00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00017 // // 00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00019 // redistribute it and/or modify it under the terms of the GNU General // 00020 // Public License as published by the Free Software Foundation; either // 00021 // version 2 of the License, or (at your option) any later version. // 00022 // // 00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00026 // PURPOSE. See the GNU General Public License for more details. // 00027 // // 00028 // You should have received a copy of the GNU General Public License // 00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00031 // Boston, MA 02111-1307 USA. // 00032 // //////////////////////////////////////////////////////////////////// // 00033 // 00034 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/SimulationViewerEyeMvt.H $ 00036 // $Id: SimulationViewerEyeMvt.H 13871 2010-09-01 22:16:25Z jshen $ 00037 // 00038 00039 #ifndef SIMULATIONVIEWEREYEMVT_H_DEFINED 00040 #define SIMULATIONVIEWEREYEMVT_H_DEFINED 00041 00042 #include "Component/ModelParam.H" 00043 #include "Image/ImageCache.H" 00044 #include "Image/ImageSet.H" 00045 #include "Image/LevelSpec.H" 00046 #include "Neuro/SimulationViewer.H" 00047 #include "Simulation/SimEvents.H" 00048 00049 #include <map> 00050 #include<vector> 00051 00052 class EyeData; 00053 class SpatialMetrics; 00054 class ofstream; 00055 class SimTime; 00056 00057 typedef Point2D<int> (*Point2DTransform)(Point2D<int> P); 00058 00059 //! Measure salience at human eye positions 00060 class SimulationViewerEyeMvt : public SimulationViewer { 00061 public: 00062 // ###################################################################### 00063 /*! @name Constructors and destructors */ 00064 //@{ 00065 00066 //! Constructor. See ModelComponent.H. 00067 SimulationViewerEyeMvt(OptionManager& mgr, 00068 const std::string& descrName = 00069 "EyeMvt Simulation Viewer", 00070 const std::string& tagName = 00071 "SimulationViewerEyeMvt"); 00072 00073 //! Destructor 00074 virtual ~SimulationViewerEyeMvt(); 00075 00076 //@} 00077 00078 protected: 00079 //! Callback for every clock tick 00080 SIMCALLBACK_DECLARE(SimulationViewerEyeMvt, SimEventClockTick); 00081 00082 //! Callback for every time we should save our outputs 00083 SIMCALLBACK_DECLARE(SimulationViewerEyeMvt, SimEventSaveOutput); 00084 00085 //! Save our various results 00086 void save1(const ModelComponentSaveInfo& sinfo); 00087 00088 //! Get the attention/eye/head trajectory image 00089 virtual Image< PixRGB<byte> > getTraj(SimEventQueue& q); 00090 00091 nub::ref<SpatialMetrics> itsMetrics;//!< metrics that depend on input size 00092 00093 OModelParam<bool> itsSaveTraj; //!< save trajectory? 00094 OModelParam<bool> itsSaveMegaCombo; //!< save mega combo? 00095 OModelParam<int> itsDelayCacheSize; //!< size of our delay cache 00096 OModelParam<int> itsMaxCacheSize; //!< size of our max cache 00097 OModelParam<bool> itsSampleAtStart; //!< take samples at start or end of sac 00098 OModelParam<bool> itsDisplaySacNum; //!< display saccade number? 00099 OModelParam<bool> itsDisplayPatch; //!< display eye position 00100 OModelParam<int> itsPatchSize; //!< size of marker at eye position 00101 OModelParam<bool> itsEraseMarker; //!< erase marker at each frame 00102 OModelParam<bool> itsDisplayFOA; //!< display saccade targets? 00103 OModelParam<LevelSpec> itsLevelSpec; //!< our levelspec 00104 OModelParam<std::string> itsOutFname; //!< Our results file 00105 OModelParam<std::string> itsPriorRandomDistro; //!< Uniform or from File 00106 OModelParam<bool> itsUseSaccadeInBlink;//!< use saccade during blink? 00107 OModelParam<bool> itsUseDiagColor;//!< use saccade during blink? 00108 OModelParam<bool> itsLabelEyePatch; //!< label eyetraces on video 00109 OModelParam<bool> itsWriteFrameNum; //!< write framenumber 00110 OModelParam<int> itsNumRandomSamples; //!< number of random samples 00111 OModelParam<int> itsMaxComboWidth; //!< max width of getTraj() 00112 OModelParam<uint> itsSMhistoryQlen; //!< queue len for Sm history 00113 00114 virtual void start1(); //!< get started 00115 virtual void stop1(); //!< get stopped 00116 00117 virtual void drawEye(const rutz::shared_ptr<EyeData> data, const uint trackerNum); // overloaded by EyeRegion 00118 virtual void drawFOA(const Point2D<int> target, const uint trackerNum); // overloaded by EyeRegion 00119 00120 // where the SVEM output is all put together 00121 virtual std::string craftSVEMOutput(const std::string TrackerNum, 00122 const rutz::shared_ptr<EyeData> data); 00123 00124 // overloaded by EyeRegion to do its output 00125 virtual void extraSampleProcessing(const rutz::shared_ptr<EyeData>); 00126 00127 // auxiliaries for file I/O 00128 std::string craftModelFreeOutput(const rutz::shared_ptr<EyeData> data); 00129 std::string craftSMSamples(const rutz::shared_ptr<EyeData> data, Image<float> smap); 00130 std::string craftSMHistory(const rutz::shared_ptr<EyeData> data, Image<float> smap); 00131 void writeHeader(); 00132 00133 // use a sliding image cache for salience computations: 00134 ImageCacheMinMax<float> itsDelayCache; 00135 ImageCacheMinMax<float> itsMaxCache; 00136 00137 // the saliency map at the head of the delay cache; 00138 Image<float> itsHeadSM; 00139 00140 Image< PixRGB<byte> > itsDrawings; // our drawings - black is transparent! 00141 // these drawings include, from SVEyeMvt: the eyetrace 00142 // from SVEyeRegion: the names and borders of regions 00143 00144 SimTime itsCurrTime; 00145 uint itsFrameNumber; // this can now be outputted to eyesal file 00146 00147 bool itsHeaderCrafted; 00148 std::vector<std::string> itsOutFields; 00149 00150 // based on SimEventRetinaImage::rawToRetinal() 00151 // wraps the rawToRetinal transform for inherited functions to use 00152 Point2D<int> rawToRet(Point2D<int> P) const {return P+itsRawToRetOffset;} 00153 00154 struct GEyeFormat { 00155 PixRGB<byte> col; 00156 std::string label; // depends on OModelParam 00157 int pSize; // patch size 00158 // shape? other aspects? 00159 }; 00160 00161 std::vector<GEyeFormat> itsEyeStyles; 00162 private: 00163 std::map<int, rutz::shared_ptr<EyeData> > itsTargets; 00164 std::vector<Point2D<int> > randPoints; 00165 ImageCache<float> itsSMhistory; 00166 00167 std::ofstream *itsOutFile; 00168 std::ifstream *itsRandFile; 00169 Point2D<int> itsRawToRetOffset; 00170 }; 00171 00172 #endif 00173 00174 // ###################################################################### 00175 /* So things look consistent in everyone's emacs... */ 00176 /* Local Variables: */ 00177 /* indent-tabs-mode: nil */ 00178 /* End: */