SaliencyMT.H

00001 /*!@file /Robots/Beobot2/LaneFollowing/RG_Lane/SaliencyMT.H 
00002  * A class for quick-and-dirty saliency mapping */
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: Zack Gossman <gossman@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/Beobot2/LaneFollowing/RG_Lane/SaliencyMT.H $
00036 // $Id: SaliencyMT.H 7229 2006-10-01 14:40:23Z kai $
00037 //
00038 
00039 #ifndef BEOSALIENCYMT_H_DEFINED
00040 #define BEOSALIENCYMT_H_DEFINED
00041 
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Image/ColorOps.H"
00045 #include "Image/Image.H"
00046 #include "Image/ImageSet.H"
00047 #include "Image/MathOps.H"
00048 #include "Image/DrawOps.H"
00049 #include "Image/FilterOps.H"
00050 #include "Image/Pixels.H"
00051 #include "Image/PyramidOps.H"
00052 #include "Image/ShapeOps.H"
00053 #include "Image/Transforms.H"
00054 #include "Image/fancynorm.H"
00055 #include "Util/Types.H"
00056 #include "Image/colorDefs.H"
00057 
00058 #include <pthread.h>
00059 #include <cstdlib>
00060 #include <unistd.h>
00061 #include <list>
00062 
00063 // ######################################################################
00064 struct jobData
00065 {
00066   jobData() { };
00067 
00068   jobData(const int jt, const PyramidType pt, const float w,
00069           const float ori = 0.0F) :
00070     jobType(jt), ptyp(pt), weight(w), orientation(ori) { }
00071 
00072   int jobType;
00073   PyramidType ptyp;
00074   float weight;
00075   float orientation;
00076 };
00077 
00078 
00079 // ######################################################################
00080 class SaliencyMT : public ModelComponent
00081 {
00082 public:
00083 
00084   // ######################################################################
00085   /*! @name Constructors and Destructors */
00086   //@{
00087 
00088   //! Constructor
00089   SaliencyMT(OptionManager& mgr,
00090              const std::string& descrName = "SaliencyMT",
00091              const std::string& tagName = "SaliencyMT");
00092 
00093   //! Destructor
00094   ~SaliencyMT();
00095 
00096   //@}
00097 
00098   // ######################################################################
00099   /*! @name member functions */
00100   //@{
00101 
00102   //! Setup up with image to be processed and build the job queue
00103   void newInput(const Image< PixRGB<byte> > img, bool procFlicker=true);
00104 
00105   //! Is the last given input done processing?
00106   bool outputReady();
00107 
00108   //! Get last computed output
00109   Image<float> getOutput();
00110   Image<float> getRGOutput();
00111   Image<float> getBYOutput();
00112   Image<float> getIntensityOutput();
00113 
00114 
00115   //! For internal thread use: Compute a conspicuity map from an image
00116   void computeCMAP();
00117   //@}
00118 
00119 protected:
00120   OModelParam<uint> itsNumThreads; //!< Number of worker threads to use
00121 
00122   void start1(); //!< get started
00123   void stop2();  //!< get stopped
00124 
00125 private:
00126   Image< PixRGB<byte> > colima;     // current color image
00127   Image<float> lum;        //curent luminance image
00128   Image<byte> r, g, b, y;  //curent RGBY images
00129   Image<float> prev;       // previous float image
00130   Image<float> outmap;     // output saliency map
00131   Image<float> skinima;    //skin hue map
00132   Image<float> cmap_rg;    //current Red-Green Map
00133   Image<float> cmap_by;    //current Blue-Yellow Map
00134   Image<float> cmap_intensity;    //current Blue-Yellow Map
00135   bool gotLum, gotRGBY, gotSkin;
00136 
00137   std::list<jobData> jobQueue;
00138   uint jobsTodo;
00139 
00140   //thread stuff
00141   pthread_t *worker;
00142   pthread_mutex_t jobLock, mapLock;
00143   pthread_cond_t jobCond;
00144   uint numWorkers;
00145 };
00146 
00147 #endif
00148 
00149 // ######################################################################
00150 /* So things look consistent in everyone's emacs... */
00151 /* Local Variables: */
00152 /* indent-tabs-mode: nil */
00153 /* End: */
Generated on Sun May 8 08:40:11 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3