SingleChannelBeo.H

Go to the documentation of this file.
00001 /*!@file Neuro/SingleChannelBeo.H wrapper class to run a SingleChannel on a
00002   distant CPU */
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/SingleChannelBeo.H $
00036 // $Id: SingleChannelBeo.H 8195 2007-03-30 04:34:07Z rjpeters $
00037 //
00038 
00039 #ifndef SINGLECHANNELBEO_H_DEFINED
00040 #define SINGLECHANNELBEO_H_DEFINED
00041 
00042 #include "Channels/InputHandler.H"
00043 #include "Channels/SingleChannel.H"
00044 #include "Util/Types.H"
00045 class Beowulf;
00046 
00047 // Beowulf message IDs for our messages:
00048 #define BEO_SCHANCONF   1000
00049 #define BEO_SCHANINPUT  1001
00050 #define BEO_SCHANOUTPUT 1002
00051 #define BEO_SCHANALLOUT 1003
00052 
00053 /// Wrapper to run a SingleChannel on a distant CPU
00054 /** This class is an InputHandler derivative, to be used as an add-on
00055     to SingleChannel or subclasses, by installing an object of this
00056     class with SingleChannel::setInputHandler(). It uses a Beowulf to
00057     delegate the actual feature map computations to a distant CPU. The
00058     distant CPU should run a SingleChannelBeoServer, like in the the
00059     beochannel-server program; see SingleChannelBeoServer.H and
00060     beochannel-server.C for details. When we get an input image, we
00061     will send it off to the processing node specified at construction
00062     (and possibly modified later using standard ModelParam access
00063     functions), using the Beowulf object given at construction. Before
00064     sending off our first input, we will contact our processing node
00065     and send it all of our associated SingleChannel's ModelParam
00066     values in a configuration message; this will allow it to build the
00067     actual SingleChannel which we are associated with.
00068 
00069     The system can work in two modes: in full emulation mode, the
00070     output map, channel pyramid, submaps and clip pyramid are all
00071     returned by the processor node. This requires a lot of network
00072     bandwidth but should ensure results that are exactly identical to
00073     when using the normal channels. In quick mode, only the output
00074     submap is returned. This will work with standard processing that
00075     only deals with the output, but things like saving the submaps or
00076     biasing the visual cortex will break; so use the fast mode at your
00077     own risk ;-) Selection of which mode is used is made by the
00078     SingleChannelBeoServer; here we just store whatever the server
00079     sends us, be it full or partial results.
00080 
00081     PROGRAMMER NOTE: See the examples in ChannelsBeo.{H,C} for how to
00082     use SingleChannelBeo. */
00083 class SingleChannelBeo : public InputHandler
00084 {
00085 public:
00086   //! Constructor
00087   /*! @param beow the Beowulf to use for data transfers */
00088   SingleChannelBeo(const nub::ref<Beowulf>& beow);
00089 
00090   //! Virtual destructor ensures proper destruction of derived classes.
00091   virtual ~SingleChannelBeo();
00092 
00093   //! Send the input image off to the processing node
00094   /*! You should call this from inside your overload of
00095       SingleChannel::doInput() */
00096   virtual void handleInput(SingleChannel& chan,
00097                            const Image<float>& bwimg,
00098                            const SimTime& t,
00099                            const Image<byte>& clipMask,
00100                            const rutz::shared_ptr<PyramidCache<float> >& cache);
00101 
00102   //! Have we received the results from our processing node yet?
00103   /*! This call will block until the results are received back from
00104     the processing node. You should call this from within your
00105     overload of SingleChannel::outputAvailable().  This is how we
00106     implement the remote processing with minimum differences between
00107     SingleChannel and objects that inherit from both SingleChannel and
00108     SingleChannelBeo; indeed, each time is result is requested from
00109     SingleChannel, it will (and should in future methods!) check first
00110     that some output is available. So, by intercepting this check we
00111     can wait until the results have been received from the processing
00112     node. */
00113   virtual void waitForOutput(SingleChannel& chan);
00114 
00115 private:
00116   virtual rutz::shared_ptr<InputHandler> makeClone() const;
00117 
00118   SingleChannelBeo(const SingleChannelBeo&); // not implemented
00119   SingleChannelBeo& operator=(const SingleChannelBeo&); // not implemented
00120 
00121   nub::ref<Beowulf> itsBeo;   // our Beowulf for communications
00122   int itsNode;                // Beowulf node that will process our data
00123   int32 itsFrame;             // unofficial frame number, starts at zero
00124 };
00125 
00126 #endif
00127 
00128 // ######################################################################
00129 /* So things look consistent in everyone's emacs... */
00130 /* Local Variables: */
00131 /* indent-tabs-mode: nil */
00132 /* End: */
Generated on Sun May 8 08:41:04 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3