SceneRec.H

Go to the documentation of this file.
00001 /*!@file RCBot/SceneRec.H  Recognize scenes                             */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Lior Elazary <elazary@usc.edu>
00033 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/RCBot/SceneRec.H $
00034 // $Id: SceneRec.H 9412 2008-03-10 23:10:15Z farhan $
00035 //
00036 
00037 #ifndef SCENEREC_H
00038 #define SCENEREC_H
00039 
00040 #include "Component/ModelComponent.H"
00041 #include "Component/ModelParam.H"
00042 #include "SIFT/ScaleSpace.H"
00043 #include "SIFT/VisualObject.H"
00044 #include "SIFT/Keypoint.H"
00045 #include "SIFT/VisualObjectDB.H"
00046 #include "Image/Image.H"
00047 #include "Image/Pixels.H"
00048 
00049 #include <pthread.h>
00050 
00051 //! Class to recognize scenes and get landmark positions
00052 class SceneRec : public ModelComponent
00053 {
00054 public:
00055 
00056   SceneRec(OptionManager &mgr,
00057            const std::string& descrName = "Scene Recognition",
00058            const std::string& tagName = "SceneRec");
00059 
00060   //! Destructor
00061   ~SceneRec();
00062 
00063   //! Setup up with image to be processed
00064   void newInput(const Image< PixRGB<byte> > img);
00065 
00066   //! Is the last given input done processing?
00067   bool outputReady();
00068 
00069   //! Get the feature point and return the current leg.
00070   //Used for landmark navigation
00071   short getLandmarkLoc(Point2D<int> &loc);
00072 
00073   //! Main process for computing locations
00074   void computeLocation();
00075 
00076   //! Train the system on a given feature location
00077   void trainFeature(Image<PixRGB<byte> > &img, Point2D<int> loc,
00078                     Dims window, short leg);
00079 
00080   //! Load the current and the next vdb from position 'leg'
00081   void loadVisualDB(short leg);
00082 
00083 protected:
00084   virtual void start1();
00085   virtual void stop2();
00086 
00087 private:
00088   Image< PixRGB<byte> > workImg;     // current color image
00089   short currentLeg;                  // the current leg in the path
00090   int objNum;                        // for naming the objects
00091 
00092   VisualObjectDB *currentLegVdb;     // the current landmark we are looking for
00093   VisualObjectDB *nextLegVdb;        // the next landmark we are looking for
00094 
00095   Point2D<int> landmarkLoc;               // the landmarkLoc location we are after
00096 
00097   // thread stuff
00098   pthread_t *worker;
00099   pthread_mutex_t jobLock, locLock, vdbLock;
00100   pthread_cond_t jobCond;
00101 
00102   bool jobDone;
00103 
00104   // get the information for found landmarks
00105   void getLandmarkInfo(float &scale, Point2D<int> &loc, unsigned int nmatch,
00106                        std::vector< rutz::shared_ptr<VisualObjectMatch> > &matches,
00107                        Image<PixRGB<byte> > &img);
00108   Dims winsize;
00109 };
00110 
00111 #endif
00112 
00113 // ######################################################################
00114 /* So things look consistent in everyone's emacs... */
00115 /* Local Variables: */
00116 /* indent-tabs-mode: nil */
00117 /* End: */
Generated on Sun May 8 08:41:17 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3