00001 /*!@file INVT/ezvision.C simplified version of vision.C 00002 */ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00006 // 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/INVT/ezvision.C $ 00036 // $Id: ezvision.C 10711 2009-02-01 04:45:19Z itti $ 00037 // 00038 00039 #include "Component/JobServerConfigurator.H" 00040 #include "Component/ModelManager.H" 00041 #include "Image/Image.H" 00042 #include "Image/Pixels.H" 00043 #include "Image/Point2D.H" 00044 #include "Media/SimFrameSeries.H" 00045 #include "Neuro/NeuroOpts.H" 00046 #include "Neuro/StdBrain.H" 00047 #include "Raster/Raster.H" 00048 #include "Simulation/SimEventQueueConfigurator.H" 00049 #include "Util/AllocAux.H" 00050 #include "Util/Pause.H" 00051 #include "Util/Types.H" 00052 #include "Util/csignals.H" 00053 #include "Util/log.H" 00054 #include "Util/sformat.H" 00055 #include "rutz/trace.h" 00056 00057 #include <signal.h> 00058 #include <sys/types.h> 00059 00060 int main(const int argc, const char **argv) 00061 { 00062 GVX_TRACE("ezvision-main"); 00063 00064 // 'volatile' because we will modify this from signal handlers 00065 volatile int signum = 0; 00066 00067 // catch signals and redirect them for a clean exit (in particular, 00068 // this gives us a chance to do useful things like flush and close 00069 // output files that would otherwise be left in a bogus state, like 00070 // mpeg output files): 00071 catchsignals(&signum); 00072 00073 MYLOGVERB = LOG_INFO; // suppress debug messages 00074 00075 // Instantiate a ModelManager: 00076 ModelManager manager("Attention Model"); 00077 00078 // Instantiate our various ModelComponents: 00079 nub::ref<JobServerConfigurator> 00080 jsc(new JobServerConfigurator(manager)); 00081 manager.addSubComponent(jsc); 00082 00083 nub::ref<SimEventQueueConfigurator> 00084 seqc(new SimEventQueueConfigurator(manager)); 00085 manager.addSubComponent(seqc); 00086 00087 // NOTE: make sure you register your OutputFrameSeries with the 00088 // manager before you do your InputFrameSeries, to ensure that 00089 // outputs for the current frame get saved before the next input 00090 // frame is loaded. 00091 nub::ref<SimOutputFrameSeries> ofs(new SimOutputFrameSeries(manager)); 00092 manager.addSubComponent(ofs); 00093 00094 nub::ref<SimInputFrameSeries> ifs(new SimInputFrameSeries(manager)); 00095 manager.addSubComponent(ifs); 00096 00097 nub::ref<StdBrain> brain(new StdBrain(manager)); 00098 manager.addSubComponent(brain); 00099 00100 // Request a bunch of option aliases (shortcuts to lists of options): 00101 REQUEST_OPTIONALIAS_NEURO(manager); 00102 00103 // Parse command-line: 00104 if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) 00105 return(1); 00106 00107 nub::ref<SimEventQueue> seq = seqc->getQ(); 00108 00109 // let's get all our ModelComponent instances started: 00110 manager.start(); 00111 00112 // temporary, for debugging... 00113 seq->printCallbacks(); 00114 00115 PauseWaiter p; 00116 int retval = 0; 00117 SimStatus status = SIM_CONTINUE; 00118 00119 // main loop: 00120 while(status == SIM_CONTINUE) 00121 { 00122 // Abort if we received a kill or similar signal: 00123 if (signum != 0) { 00124 LINFO("quitting because %s was caught", signame(signum)); 00125 retval = -1; break; 00126 } 00127 00128 // Are we in pause mode, if so, hold execution: 00129 if (p.checkPause()) continue; 00130 00131 // Evolve for one time step and switch to the next one: 00132 status = seq->evolve(); 00133 } 00134 00135 // print final memory allocation stats 00136 LINFO("Simulation terminated."); 00137 00138 // stop all our ModelComponents 00139 manager.stop(); 00140 00141 // all done! 00142 return retval; 00143 } 00144 00145 // ###################################################################### 00146 /* So things look consistent in everyone's emacs... */ 00147 /* Local Variables: */ 00148 /* indent-tabs-mode: nil */ 00149 /* End: */