00001 /*!@file Beobot/BeobotVisualCortex.H Header for navigation class */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // 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: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Beobot/BeobotVisualCortex.H $ 00035 // $Id: BeobotVisualCortex.H 9412 2008-03-10 23:10:15Z farhan $ 00036 // 00037 00038 #ifndef BEOBOTVISUALCORTEX_H_DEFINED 00039 #define BEOBOTVISUALCORTEX_H_DEFINED 00040 00041 #include "Beobot/ImageSpring.H" 00042 #include "Beowulf/Beowulf.H" 00043 #include "Beowulf/TCPmessage.H" 00044 #include "Channels/Jet.H" 00045 #include "Image/ImageSet.H" 00046 #include "Image/PyramidTypes.H" 00047 #include "Image/fancynorm.H" 00048 #include "Util/Assert.H" 00049 #include "Util/Types.H" 00050 #include "rutz/shared_ptr.h" 00051 00052 //! Visual Cortex of a Beobot 00053 /*! this is no longer derived from VisualCortex 00054 it can be used with one CPU or SMP systems */ 00055 class BeobotVisualCortex { 00056 public: 00057 //! constructor 00058 BeobotVisualCortex(); 00059 00060 //! initialization 00061 /*! use beow=NULL for single-CPU processing */ 00062 void init(const int imgw, const int imgh, const int lev_min, 00063 const int lev_max, const int delta_min, const int delta_max, 00064 const int smlev, const int nborient, const MaxNormType normtype, 00065 const int jlev, const int jdepth, const int nbneig, 00066 nub::soft_ref<Beowulf> beow); 00067 00068 //! present a new visual input from an existing image 00069 void newVisualInput(Image< PixRGB<byte> >& scene); 00070 00071 //! get pointer to scene image, so that we can directly grab it 00072 Image< PixRGB<byte> >* getScenePtr(); 00073 00074 //! call this to execute all the low-level processing on current scene 00075 /*! This method will automatically parallelize the processing if 00076 a non-NULL beowulf was passed at initialization. However, it will 00077 call processStart() and processEnd() in sequence, waiting for the 00078 results to be ready before returning. It may be a better idea 00079 to separately call processStart(), do something, then processEnd(). 00080 For single-CPU operation, process() is the only option. */ 00081 void process(const int frame); 00082 00083 //! start parallel processing by sending off current frame 00084 void processStart(const int frame); 00085 00086 //! end parallel process by receiving results 00087 void processEnd(const int frame); 00088 00089 //! not normally used; use process() instead 00090 void singleCPUprocess(const int frame); 00091 00092 //! not normally used; use process() instead 00093 void masterProcess(const int frame); 00094 00095 //! Call this in an infinite loop on slaves to process & return incoming maps 00096 void slaveProcess(); 00097 00098 //! not normally used; use process() instead 00099 void masterCollect(); 00100 00101 //! get most salient location: 00102 void getWinner(Point2D<int>& win) const; 00103 00104 //! initialize clustering with "spring method" 00105 void initSprings( bool initPosMasses ); 00106 00107 //! iterate clustering with "spring method" 00108 void iterateSprings(const float dt); 00109 00110 //! returns the clustered image and the position of the track centroid 00111 void getClusteredImage(Image< PixRGB<byte> > &clusteredImage, 00112 Point2D<int> &supposedTrackCentroid, 00113 const Point2D<int> &previousTrackCentroid); 00114 00115 //! get size of input image 00116 inline void getInputSize(Point2D<int>& size); 00117 00118 //! get mass positions 00119 void getPositions(Image< PixRGB<byte> > &img, const int zoom); 00120 00121 private: 00122 //! compute a feature for incoming image in message 00123 void computeFeature(TCPmessage &rmsg, const PyramidType ptyp, 00124 const float ori, const int maptype); 00125 00126 //! compute a feature for two incoming images in message 00127 void computeFeature2(TCPmessage &rmsg, const PyramidType ptyp, 00128 const float ori, const int maptype); 00129 00130 //! compute feature for given image 00131 void computeFeature(const Image<float>& fima, const PyramidType ptyp, 00132 const float ori, const int id, const int maptype); 00133 00134 //! compute conspicuity map given a pyramid 00135 void computeCmap(const ImageSet<float>& pyr, Image<float>& cmap); 00136 00137 bool initialized; 00138 00139 // the input scene (retinal image): 00140 Image< PixRGB<byte> > scene; 00141 Image<float> prevlum; // luminance of previous scene, for flicker 00142 int currframe; 00143 00144 // the segmented scene: 00145 ImageSpring< Jet<float> > jets; 00146 int nbjmap; 00147 00148 // saliency map input: 00149 Image<float> sminput; 00150 int nbcmap; 00151 Point2D<int> winner; 00152 00153 // for inter-CPU communication: 00154 nub::soft_ref<Beowulf> beo; 00155 00156 // parameters: 00157 int iw, ih, lmin, lmax, dmin, dmax, sml, nori; 00158 MaxNormType nortyp; 00159 int jetlevel, jetdepth; 00160 int nbneigh; 00161 rutz::shared_ptr<JetSpec> jetSpec; 00162 }; 00163 00164 // ###################################################################### 00165 inline void BeobotVisualCortex::getInputSize(Point2D<int>& size) 00166 { 00167 ASSERT(scene.initialized()); 00168 size.i = scene.getWidth(); size.j = scene.getHeight(); 00169 } 00170 00171 #endif 00172 00173 // ###################################################################### 00174 /* So things look consistent in everyone's emacs... */ 00175 /* Local Variables: */ 00176 /* indent-tabs-mode: nil */ 00177 /* End: */