IntegerMotionChannel.C

Go to the documentation of this file.
00001 /*!@file Channels/IntegerMotionChannel.C */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
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: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Channels/IntegerMotionChannel.C $
00035 // $Id: IntegerMotionChannel.C 8160 2007-03-21 21:34:16Z rjpeters $
00036 //
00037 
00038 #ifndef CHANNELS_INTEGERMOTIONCHANNEL_C_DEFINED
00039 #define CHANNELS_INTEGERMOTIONCHANNEL_C_DEFINED
00040 
00041 #include "Channels/IntegerMotionChannel.H"
00042 
00043 #include "Channels/ChannelOpts.H"
00044 #include "Channels/IntegerDirectionChannel.H"
00045 #include "Component/OptionManager.H"
00046 #include "Image/IntegerMathOps.H"
00047 #include "rutz/trace.h"
00048 
00049 namespace
00050 {
00051   IntgTrigTable<256, 8> trig;
00052 }
00053 
00054 // ######################################################################
00055 // IntegerMotionChannel member definitions:
00056 // ######################################################################
00057 
00058 // ######################################################################
00059 IntegerMotionChannel::
00060 IntegerMotionChannel(OptionManager& mgr,
00061                      nub::ref<IntegerMathEngine> eng) :
00062   IntegerComplexChannel(mgr, "Integer Motion", "int-motion", MOTION, eng),
00063   itsNumDirs(&OPT_NumDirections, this) // see Channels/ChannelOpts.{H,C}
00064 {
00065 GVX_TRACE(__PRETTY_FUNCTION__);
00066   // let's create our subchannels (may be reconfigured later if our
00067   // number of directions changes):
00068   buildSubChans();
00069 }
00070 
00071 // ######################################################################
00072 IntegerMotionChannel::~IntegerMotionChannel()
00073 {
00074 GVX_TRACE(__PRETTY_FUNCTION__);
00075 }
00076 
00077 // ######################################################################
00078 IntegerDirectionChannel& IntegerMotionChannel::dirChan(const uint idx) const
00079 {
00080 GVX_TRACE(__PRETTY_FUNCTION__);
00081   return *(dynCast<IntegerDirectionChannel>(subChan(idx)));
00082 }
00083 
00084 // ######################################################################
00085 void IntegerMotionChannel::buildSubChans()
00086 {
00087 GVX_TRACE(__PRETTY_FUNCTION__);
00088   // kill any subchans we may have had...
00089   this->removeAllSubChans();
00090 
00091   // let's instantiate our subchannels now that we know how many we
00092   // want. They will inherit the current values (typically
00093   // post-command-line parsing) of all their options as they are
00094   // constructed:
00095   LINFO("Using %d directions spanning [0..360]deg", itsNumDirs.getVal());
00096   for (uint i = 0; i < itsNumDirs.getVal(); ++i)
00097     {
00098       const double dir =
00099         360.0 * double(i) / double(itsNumDirs.getVal());
00100 
00101       nub::ref<IntegerDirectionChannel> chan =
00102         makeSharedComp
00103         (new IntegerDirectionChannel(getManager(), i, dir,
00104                                      trig.costab[trig.indexDegrees(dir)],
00105                                      -trig.sintab[trig.indexDegrees(dir)],
00106                                      trig.nbits,
00107                                      this->getMathEngine()));
00108       this->addSubChan(chan);
00109 
00110       chan->exportOptions(MC_RECURSE);
00111     }
00112 }
00113 
00114 // ######################################################################
00115 void IntegerMotionChannel::paramChanged(ModelParamBase* const param,
00116                                         const bool valueChanged,
00117                                         ParamClient::ChangeStatus* status)
00118 {
00119 GVX_TRACE(__PRETTY_FUNCTION__);
00120   IntegerComplexChannel::paramChanged(param, valueChanged, status);
00121 
00122   // if the param is our number of orientations and it has become
00123   // different from our number of channels, let's reconfigure:
00124   if (param == &itsNumDirs &&
00125       numChans() != itsNumDirs.getVal())
00126     buildSubChans();
00127 }
00128 
00129 // ######################################################################
00130 void IntegerMotionChannel::doInputInt(const IntegerInput& inp,
00131                                       const SimTime& t,
00132                                       PyramidCache<int>* cache,
00133                                       const Image<byte>& clipMask)
00134 {
00135 GVX_TRACE(__PRETTY_FUNCTION__);
00136 
00137   // compute Reichardt motion detection into several directions
00138   for (uint dir = 0; dir < numChans(); ++dir)
00139     {
00140       dirChan(dir).inputInt(inp, t, cache, clipMask);
00141       LINFO("Integer Motion pyramid (%d/%d) ok.", dir+1, numChans());
00142     }
00143 }
00144 
00145 // ######################################################################
00146 /* So things look consistent in everyone's emacs... */
00147 /* Local Variables: */
00148 /* mode: c++ */
00149 /* indent-tabs-mode: nil */
00150 /* End: */
00151 
00152 #endif // CHANNELS_INTEGERMOTIONCHANNEL_C_DEFINED
Generated on Sun May 8 08:40:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3