ObjRecSPM.H

Go to the documentation of this file.
00001 /*!@file ObjRec/ObjRecSPM.H Obj Reconition using spatial pyramid matching
00002  algorithem from Lzebnik, Schmid and Ponce
00003  */
00004 
00005 // //////////////////////////////////////////////////////////////////// //
00006 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00007 // University of Southern California (USC) and the iLab at USC.         //
00008 // See http://iLab.usc.edu for information about this project.          //
00009 // //////////////////////////////////////////////////////////////////// //
00010 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00011 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00012 // in Visual Environments, and Applications'' by Christof Koch and      //
00013 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00014 // pending; application number 09/912,225 filed July 23, 2001; see      //
00015 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00016 // //////////////////////////////////////////////////////////////////// //
00017 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00018 //                                                                      //
00019 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00020 // redistribute it and/or modify it under the terms of the GNU General  //
00021 // Public License as published by the Free Software Foundation; either  //
00022 // version 2 of the License, or (at your option) any later version.     //
00023 //                                                                      //
00024 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00025 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00026 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00027 // PURPOSE.  See the GNU General Public License for more details.       //
00028 //                                                                      //
00029 // You should have received a copy of the GNU General Public License    //
00030 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00031 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00032 // Boston, MA 02111-1307 USA.                                           //
00033 // //////////////////////////////////////////////////////////////////// //
00034 //
00035 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu>
00036 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/ObjRec/ObjRecSPM.H $
00037 // $Id: ObjRecSPM.H 9108 2007-12-30 06:14:30Z rjpeters $
00038 //
00039 
00040 #ifndef ObjRecSPM_H_DEFINED
00041 #define ObjRecSPM_H_DEFINED
00042 
00043 #include "Component/ModelComponent.H"
00044 #include "Component/ModelParam.H"
00045 #include "Image/Image.H"
00046 #include "Image/ImageSet.H"
00047 #include "Image/Pixels.H"
00048 #include "SIFT/Histogram.H"
00049 #include "Neuro/getSaliency.H"
00050 
00051 #include <vector>
00052 #include <limits>
00053 
00054 class ObjRecSPM : public ModelComponent
00055 {
00056 public:
00057 
00058   struct SiftKeypoint {
00059     int x;
00060     int y;
00061     std::vector<std::vector<byte> > fv;
00062   };
00063 
00064   struct Descriptor {
00065     std::vector<std::vector<Histogram> > featureLevelHist;
00066     std::vector<SiftKeypoint> siftDescriptors;
00067   };
00068 
00069   struct Object
00070   {
00071     int id;
00072     std::string name;
00073     std::vector<Descriptor> model;
00074   };
00075 
00076   //Constructor
00077   ObjRecSPM(OptionManager& mgr,
00078           const std::string& descrName = "ObjRecSPM",
00079           const std::string& tagName = "ObjRecSPM");
00080   ~ObjRecSPM();
00081 
00082   //###########################################################
00083 
00084   void start2();
00085 
00086   void train(const Image<PixRGB<byte> > &img, const std::string label);
00087   void finalizeTraining();
00088   std::string predict(const Image<PixRGB<byte> > &img);
00089 
00090   Descriptor extractFeatures(const Image<float> &input);
00091   Descriptor extractSiftFeatures(const Image<float> &input);
00092 
00093   uint getObject(const std::string name);
00094 
00095   //Find the object given the features
00096   int findObject(const Descriptor &desc);
00097 
00098   double matchKernel(const std::vector<Histogram>& A, const std::vector<Histogram>& B);
00099 
00100   double matchDescriptor(const Descriptor& descA, const Descriptor& descB);
00101 
00102   //For SIft descriptor
00103   std::vector<std::vector<byte> > getSiftDescriptor(const Image<float> &lum,
00104       const float x, const float y, const float s);
00105   void calculateOrientationVector(const float x, const float y, const float s,
00106       const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00107   std::vector<std::vector<byte> > createVectorsAndKeypoints(const float x, const float y, const float s,
00108       const Image<float>& gradmag, const Image<float>& gradorie, Histogram& OV);
00109 
00110 
00111 
00112 
00113 
00114 private:
00115 
00116   int itsNumOri;
00117   int itsNumScales;
00118   int itsNumOriArray;
00119   std::vector<Object> itsObjects;
00120 
00121   ImageSet<float> itsFilters;
00122 
00123   nub::soft_ref<GetSaliency> itsGetSaliency;
00124   bool itsUseSaliency;
00125 };
00126 
00127 #endif
00128 
00129 // ######################################################################
00130 /* So things look consistent in everyone's emacs... */
00131 /* Local Variables: */
00132 /* indent-tabs-mode: nil */
00133 /* End: */
Generated on Sun May 8 08:41:08 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3