00001 /*!@file Media/SimFrameSeries.H a series of frames as SimModule */ 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@pollux.usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Media/SimFrameSeries.H $ 00035 // $Id: SimFrameSeries.H 13373 2010-05-09 04:28:40Z lior $ 00036 // 00037 00038 #ifndef SIMFRAMESERIES_H_DEFINED 00039 #define SIMFRAMESERIES_H_DEFINED 00040 00041 #include "Component/ModelParam.H" 00042 #include "Media/MediaSimEvents.H" 00043 #include "Raster/GenericFrame.H" 00044 #include "Simulation/SimModule.H" 00045 #include "Simulation/SimEvents.H" 00046 #include "Util/SimTime.H" 00047 class InputFrameSeries; 00048 class OutputFrameSeries; 00049 00050 // ###################################################################### 00051 //! An InputFrameSeries encapsulated into a SimModule 00052 /*! SimInputFrameSeries encapsulates the functionality of 00053 InputFrameSeries for use by SimModule objects. The interface is a 00054 simplified version of that of InputFrameSeries, since now most of 00055 the I/O is handled through the SimEventQueue blackboard rather than 00056 through explicit function calls and return values. Rather than 00057 deriving from InputFrameSeries, we hold an InputFrameSeries as a 00058 data member. This is because much of the InputFrameSeries interface 00059 is not used here because it is replaced by posting messages to the 00060 SimEventQueue. */ 00061 class SimInputFrameSeries : public SimModule 00062 { 00063 public: 00064 //! Constructor 00065 SimInputFrameSeries(OptionManager& mgr, 00066 const std::string& descrName = "Sim Input Frame Series", 00067 const std::string& tagName = "SimInputFrameSeries"); 00068 00069 //! Destructor 00070 virtual ~SimInputFrameSeries(); 00071 00072 //! Get specifications of the image frames 00073 /*! It is okay to call this before the model is started(). If input 00074 resizing is being done, the returned dimensions will be the 00075 resized dims. All in all, this will return the size of whatever 00076 you will get when calling readFrame(), readRGB(), etc. */ 00077 virtual GenericFrameSpec peekFrameSpec(); 00078 00079 //! Optional call to efficiently prepare for frame streaming 00080 virtual void startStream(); 00081 00082 //! Set the frame source; same as doing --in=source on the command line 00083 void setFrameSource(const std::string& source); 00084 00085 //! Get the current frame number 00086 int frame() const; 00087 00088 protected: 00089 //! Callback function triggered at each clock tick 00090 SIMCALLBACK_DECLARE(SimInputFrameSeries, SimEventClockTick); 00091 00092 private: 00093 nub::ref<InputFrameSeries> itsIFS; 00094 }; 00095 00096 00097 00098 // ###################################################################### 00099 //! An OutputFrameSeries encapsulated into a SimModule 00100 /*! SimOutputFrameSeries encapsulates the functionality of 00101 OutputFrameSeries for use by SimModule objects. The interface is a 00102 simplified version of that of OutputFrameSeries, since now most of 00103 the I/O is handled through the SimEventQueue blackboard rather than 00104 through explicit function calls and return values. Rather than 00105 deriving from OutputFrameSeries, we hold an OutputFrameSeries as a 00106 data member. This is because much of the OutputFrameSeries interface 00107 is not used here because it is replaced by posting messages to the 00108 SimEventQueue. */ 00109 class SimOutputFrameSeries : public SimModule 00110 { 00111 public: 00112 //! Constructor 00113 SimOutputFrameSeries(OptionManager& mgr, 00114 const std::string& descrName="Sim Output Frame Series", 00115 const std::string& tagName = "SimOutputFrameSeries"); 00116 00117 //! Destructor 00118 virtual ~SimOutputFrameSeries(); 00119 00120 //! Check if we have no output destinations (e.g., user gave --out=none) 00121 /*! Clients can test isVoid() before they generate potentially 00122 expensive output images. This is just a performance optimization 00123 -- even if isVoid() is true, it's still safe to call writeRGB(), 00124 writeGray(), etc., but those calls will do nothing, and so any 00125 time spent computing the image will have been wasted. */ 00126 virtual bool isVoid() const; 00127 00128 //! Add a frame destination; same as doing --out=source on the command line 00129 void addFrameDest(const std::string& dest); 00130 00131 //! Get the current frame number 00132 int frame() const; 00133 00134 protected: 00135 //! Callback function at triggered at each clock tick 00136 SIMCALLBACK_DECLARE(SimOutputFrameSeries, SimEventClockTick); 00137 00138 //! Callback function to check for requests to save outputs 00139 SIMCALLBACK_DECLARE(SimOutputFrameSeries, SimEventRequestSaveOutput); 00140 00141 //! update 00142 void update(SimEventQueue& q, const bool saveRequested); 00143 00144 //! Simulation time step 00145 OModelParam<SimTime> itsTimeStep; 00146 00147 private: 00148 nub::ref<OutputFrameSeries> itsOFS; 00149 bool itsSaveRequested; 00150 }; 00151 00152 00153 #endif 00154 00155 // ###################################################################### 00156 /* So things look consistent in everyone's emacs... */ 00157 /* Local Variables: */ 00158 /* indent-tabs-mode: nil */ 00159 /* End: */