InferoTemporalSIFT.H

00001 /*!@file Neuro/InferoTemporalHmax.H Object recognition module */
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:Sophie Marat
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/InferoTemporalSIFT.H $
00035 // $Id: InferoTemporalHmax.H 14244 2010-11-17 02:56:14Z sophie $
00036 //
00037 
00038 #ifndef INFEROTEMPORALSIFT_H_DEFINED
00039 #define INFEROTEMPORALSIFT_H_DEFINED
00040 
00041 
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Neuro/InferoTemporal.H"
00045 #include "SIFT/Keypoint.H"
00046 #include "SIFT/VisualObject.H"
00047 #include "SIFT/VisualObjectDB.H"
00048 #include "Channels/InputFrame.H"
00049 #include "Image/Pixels.H"
00050 #include "Image/Image.H"
00051 #include "Media/TestImages.H"
00052 
00053 #include "Channels/RawVisualCortex.H"
00054 #include"Component/RawGistEstimatorStd.H"
00055 
00056 #include "Neuro/SVMClassifierModule.H"
00057 
00058 class Brain;
00059 
00060 namespace nub { template <class T> class ref; }
00061 
00062 
00063 // ######################################################################
00064 //! Inferotemporal interface using SIFT with feature learning
00065 /*! Model of the Inferior Temporal Cortex utilizing SIFT object recognition */
00066 class InferoTemporalSIFT : public InferoTemporal
00067 {
00068 
00069 public:
00070   //! Constructor
00071   InferoTemporalSIFT(OptionManager& mgr,
00072                      const std::string& descrName = "Infero Temporal SIFT",
00073                      const std:: string& tagName = "InferoTemporalSIFT");
00074 
00075 
00076 
00077   //! Destructor
00078   virtual ~InferoTemporalSIFT();
00079 
00080   std::string getObjNameAtLoc(const std::vector<TestImages::ObjData> &objects, const Point2D<int>& loc);
00081   
00082 
00083  
00084 protected:
00085   //! Object recognition
00086   virtual void attentionShift(SimEventQueue& q, const Point2D<int>& location);
00087 
00088 protected:
00089   OModelParam<std::string> itsSIFTStoredDatabase; //!< dir of stored SIFT Database
00090   OModelParam<std::string> itsITCMode; //!< option for training or testing mode
00091   OModelParam<std::string> itsPathMatch; //!< Path of the objects to consider for matching
00092   OModelParam<bool> itsCoarseReco; //!< Use the gist to do a coares pre-recognition
00093 
00094   OModelParam<std::string> itsTrainSVM; //!< file where the training exemple for the SVM will be saved 
00095   OModelParam<std::string> itsSVMId; //!< The Id of the object to train the SVM
00096   OModelParam<std::string> itsSVMClass; //!< The Class of the object to train the SVM - Used for completing the ID:Class table
00097   OModelParam<std::string> itsSVMModel; //!< file where the training exemple for the SVM will be saved The SVM model to use
00098   OModelParam<std::string> itsSVMRange; //!< file where the training exemple for the SVM will be saved The range to rescale data before SVM
00099   OModelParam<std::string> itsNameObj; //!< Name on the object that is processed to train SVM ///
00100   OModelParam<std::string> itsRecoSave; //!< file where the result of the recognition will be saved
00101   OModelParam<std::string> itsTable; //!< file where the table of the class and their Id is saved
00102 
00103 
00104   rutz::shared_ptr<VisualObjectDB> itsObjectDB; //!< our object database
00105   rutz::shared_ptr<VisualObjectDB> itsnewObjectDB; //!< to adapt the database to select only object to match within the given path
00106   rutz::shared_ptr<std::map<double,int> > itsPDFGist; //!< proba density of the recognition using gist
00107 
00108   //GIST//
00109   nub::ref<RawVisualCortex> itsVisualCortex;
00110   //rutz::shared_ptr<RawVisualCortex> itsVisualCortex;  // raw visual cortex use to compute coarse recognition with gist
00111   nub::ref<RawGistEstimatorStd> itsGistEstim;
00112 
00113 
00114   //nub::ref<SVMClassifierModule> itsClassifier;
00115 
00116   //! (re-)initialization - load object database
00117   virtual void start1();
00118 
00119   //! destruction - save object database
00120   virtual void stop1();
00121 
00122   void getObjDBToMatch(const char *dir);
00123 
00124   void computeGist(Image<PixRGB<byte> >);
00125   //Image<float> computeGist(Image<PixRGB<byte> >);
00126   
00127   void gistSelect(std::map<double, int>::reverse_iterator iteratorPDFGist);
00128 
00129 };
00130 
00131 #endif
00132 
00133 
00134 // ######################################################################
00135 /* So things look consistent in everyone's emacs... */
00136 /* Local Variables: */
00137 /* indent-tabs-mode: nil */
00138 /* End: */
00139 
Generated on Sun May 8 08:05:24 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3