beobot-slave.C

Go to the documentation of this file.
00001 /*!@file Beobot/beobot-slave.C A parallel vision slave to use with
00002  beobot-master.  See the beobotgo script in bin/ for how to launch the
00003  slaves, and see beobot-master.C for the master program.
00004 */
00005 // //////////////////////////////////////////////////////////////////// //
00006 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00007 // University of Southern California (USC) and the iLab at USC.         //
00008 // See http://iLab.usc.edu for information about this project.          //
00009 // //////////////////////////////////////////////////////////////////// //
00010 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00011 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00012 // in Visual Environments, and Applications'' by Christof Koch and      //
00013 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00014 // pending; application number 09/912,225 filed July 23, 2001; see      //
00015 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00016 // //////////////////////////////////////////////////////////////////// //
00017 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00018 //                                                                      //
00019 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00020 // redistribute it and/or modify it under the terms of the GNU General  //
00021 // Public License as published by the Free Software Foundation; either  //
00022 // version 2 of the License, or (at your option) any later version.     //
00023 //                                                                      //
00024 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00025 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00026 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00027 // PURPOSE.  See the GNU General Public License for more details.       //
00028 //                                                                      //
00029 // You should have received a copy of the GNU General Public License    //
00030 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00031 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00032 // Boston, MA 02111-1307 USA.                                           //
00033 // //////////////////////////////////////////////////////////////////// //
00034 //
00035 // Primary maintainer for this file: Laurent Itti <itti@usc.edu>
00036 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Beobot/beobot-slave.C $
00037 // $Id: beobot-slave.C 6793 2006-06-29 20:03:25Z rjpeters $
00038 //
00039 
00040 #include "Beobot/BeobotVisualCortex.H"
00041 #include "Beobot/beobot-defs.H"
00042 #include "Beowulf/Beowulf.H"
00043 #include "Component/ModelManager.H"
00044 #include "Image/Image.H"
00045 #include "Image/ImageSet.H"
00046 #include "Image/Pixels.H"
00047 #include "Image/fancynorm.H"
00048 #include "Util/Types.H"
00049 
00050 #include <cstdlib>
00051 #include <iostream>
00052 #include <netdb.h>
00053 #include <signal.h>
00054 #include <time.h>
00055 #include <unistd.h>
00056 
00057 
00058 #define IMGWIDTH 160
00059 #define IMGHEIGHT 120
00060 
00061 static bool goforever = true;  //!< Will turn false on interrupt signal
00062 
00063 //! Signal handler (e.g., for control-C)
00064 void terminate(int s)
00065 {
00066   std::cerr<<"*** INTERRUPT ***"<<std::endl;
00067   goforever = false;
00068 }
00069 
00070 // ######################################################################
00071 int main(const int argc, const char **argv)
00072 {
00073   MYLOGVERB = LOG_INFO;
00074 
00075   // instantiate a model manager:
00076   ModelManager manager("Parallel Vision TCP Version 2 - Slave");
00077 
00078   // Instantiate our various ModelComponents:
00079   nub::soft_ref<Beowulf>
00080     beo(new Beowulf(manager, "Beowulf Slave", "BeowulfSlave", false));
00081   manager.addSubComponent(beo);
00082 
00083   // Parse command-line:
00084   if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return(1);
00085 
00086   // setup signal handling:
00087   signal(SIGHUP, terminate); signal(SIGINT, terminate);
00088   signal(SIGQUIT, terminate); signal(SIGTERM, terminate);
00089   initRandomNumbers();
00090 
00091   // init visual cortex:
00092   BeobotVisualCortex vcx;
00093   vcx.init(IMGWIDTH, IMGHEIGHT, LEVEL_MIN, LEVEL_MAX,
00094            DELTA_MIN, DELTA_MAX, SMLEVEL, NBORIENTS, VCXNORM_MAXNORM,
00095            JETLEVEL, JETDEPTH, NBNEIGH, beo);
00096 
00097   // let's get all our ModelComponent instances started:
00098   manager.start();
00099 
00100   // wait for data and process it:
00101   while(goforever)
00102     vcx.slaveProcess(); // receive images, process them, and send them back
00103 
00104   // we got broken:
00105   manager.stop();
00106   return 0;
00107 }
00108 
00109 // ######################################################################
00110 /* So things look consistent in everyone's emacs... */
00111 /* Local Variables: */
00112 /* indent-tabs-mode: nil */
00113 /* End: */
Generated on Sun May 8 08:04:26 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3