test-vision.C

Go to the documentation of this file.
00001 /*! @file SceneUnderstanding/test-vision.C Test the various vision comp
00002  * with simple stimulus*/
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
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: Lior Elazary <elazary@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/plugins/SceneUnderstanding/test-vision.C $
00036 // $Id: test-vision.C 13765 2010-08-06 18:56:17Z lior $
00037 //
00038 
00039 //#include "Image/OpenCVUtil.H"  // must be first to avoid conflicting defs of int64, uint64
00040 
00041 #include "Component/JobServerConfigurator.H"
00042 #include "Component/ModelManager.H"
00043 #include "Image/Image.H"
00044 #include "Image/Pixels.H"
00045 #include "Image/Point2D.H"
00046 #include "Media/SimFrameSeries.H"
00047 #include "Neuro/NeuroOpts.H"
00048 #include "Raster/Raster.H"
00049 #include "Simulation/SimEventQueueConfigurator.H"
00050 #include "Simulation/SimEventQueue.H"
00051 #include "plugins/SceneUnderstanding/VisualCortex.H"
00052 #include "Util/AllocAux.H"
00053 #include "Util/Pause.H"
00054 #include "Util/Types.H"
00055 #include "Util/csignals.H"
00056 #include "Util/log.H"
00057 #include "Util/sformat.H"
00058 #include "rutz/trace.h"
00059 
00060 #include <signal.h>
00061 #include <sys/types.h>
00062 
00063 
00064 int main(const int argc, const char **argv)
00065 {
00066 
00067   // 'volatile' because we will modify this from signal handlers
00068   volatile int signum = 0;
00069 
00070   // catch signals and redirect them for a clean exit (in particular,
00071   // this gives us a chance to do useful things like flush and close
00072   // output files that would otherwise be left in a bogus state, like
00073   // mpeg output files):
00074   catchsignals(&signum);
00075 
00076   MYLOGVERB = LOG_INFO;
00077   ModelManager manager("Test Vision");
00078 
00079   nub::ref<SimEventQueueConfigurator>
00080     seqc(new SimEventQueueConfigurator(manager));
00081   manager.addSubComponent(seqc);
00082 
00083   nub::ref<SimOutputFrameSeries> ofs(new SimOutputFrameSeries(manager));
00084   manager.addSubComponent(ofs);
00085 
00086   nub::ref<SimInputFrameSeries> ifs(new SimInputFrameSeries(manager));
00087   manager.addSubComponent(ifs);
00088 
00089   nub::ref<VisualCortex> vc(new VisualCortex(manager));
00090   manager.addSubComponent(vc);
00091 
00092 
00093    // Request a bunch of option aliases (shortcuts to lists of options):
00094   REQUEST_OPTIONALIAS_NEURO(manager);
00095 
00096   if (manager.parseCommandLine(
00097         (const int)argc, (const char**)argv, "", 0, 0) == false)
00098     return 1;
00099 
00100   nub::ref<SimEventQueue> seq = seqc->getQ();
00101 
00102 
00103   manager.start();
00104 
00105   // temporary, for debugging...
00106   seq->printCallbacks();
00107 
00108   PauseWaiter p;
00109   int retval = 0;
00110   SimStatus status = SIM_CONTINUE;
00111 
00112   // main loop:
00113   while(status == SIM_CONTINUE)
00114   {
00115     // Abort if we received a kill or similar signal:
00116     if (signum != 0) {
00117       LINFO("quitting because %s was caught", signame(signum));
00118       retval = -1; break;
00119     }
00120 
00121     // Are we in pause mode, if so, hold execution:
00122     if (p.checkPause()) continue;
00123 
00124     // Evolve for one time step and switch to the next one:
00125     status = seq->evolve();
00126   }
00127 
00128   // print final memory allocation stats
00129   LINFO("Simulation terminated.");
00130 
00131   // stop all our ModelComponents
00132   manager.stop();
00133 
00134   return 0;
00135 }
00136 
Generated on Sun May 8 08:41:09 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3