SaliencyMT.H

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