SalientRegionTracker.H

00001 /*!@file Beobot/BeobotBrainMT.H template matching tracker
00002   on conspicuity maps                                                   */
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: Christian Siagian <siagian@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Beobot/SalientRegionTracker.H $
00035 // $Id: SalientRegionTracker.H 12962 2010-03-06 02:13:53Z irock $
00036 //
00037 
00038 
00039 // ######################################################################
00040 
00041 #ifndef BEOBOT_SALIENTREGIONTRACKER_H_DEFINED
00042 #define BEOBOT_SALIENTREGIONTRACKER_H_DEFINED
00043 
00044 #include "Component/ModelComponent.H"
00045 #include "Component/ModelParam.H"
00046 #include "Neuro/VisualCortex.H"
00047 #include "Image/Image.H"
00048 #include "Image/ImageSet.H"
00049 #include "Image/ColorOps.H"
00050 #include "Image/PyramidOps.H"
00051 #include "Image/Pixels.H"
00052 #include "GUI/XWinManaged.H"
00053 #include "Raster/Raster.H"
00054 #include "Util/Timer.H"
00055 
00056 #include "Beobot/BeobotBrainMT.H"
00057 
00058 #include "SIFT/VisualObject.H"
00059 #include "SIFT/VisualObjectMatch.H"
00060 
00061 
00062 
00063 // ######################################################################
00064 //!
00065 class SalientRegionTracker : public ModelComponent
00066 {
00067 public:
00068 
00069   // ######################################################################
00070   /*! @name Constructors and Destructors */
00071   //@{
00072 
00073   //! Constructor
00074   SalientRegionTracker(OptionManager& mgr,
00075                        const std::string& descrName = "Salient Region Tracker",
00076                        const std::string& tagName   = "SalientRegionTracker");
00077 
00078   //! Destructor
00079   virtual ~SalientRegionTracker();
00080 
00081   //@}
00082 
00083   void clear();
00084 
00085   void move(nub::soft_ref<SalientRegionTracker> tracker2, uint i);
00086 
00087   void input
00088   (Image<PixRGB<byte> > image, ImageSet<float> cmap,
00089    bool resetTracker,
00090    std::vector<Point2D<int> > points, std::vector<Rectangle> rects,
00091    std::vector<rutz::shared_ptr<VisualObject> > visualObjects);
00092 
00093 
00094   inline uint getNumTrackedPoints() const;
00095 
00096   inline Point2D<int> getCurrTrackedPoints(uint i) const;
00097   inline std::vector<Point2D<int> > getCurrTrackedPoints() const;
00098 
00099   inline Rectangle getCurrTrackedROI(uint i) const;
00100   inline std::vector<Rectangle> getCurrTrackedROI() const;
00101 
00102   inline Point2D<int> getPrevTrackedPointsScaled(uint i) const;
00103   inline std::vector<Point2D<int> > getPrevTrackedPointsScaled() const;
00104 
00105   inline ImageSet<float> getTrackerBias(uint i) const;
00106   inline std::vector<ImageSet<float> > getTrackerBias() const;
00107 
00108   inline Point2D<int> getTrackerBiasOffset(uint i) const;
00109   inline std::vector<Point2D<int> > getTrackerBiasOffset() const;
00110 
00111   inline Image<PixRGB<byte> > getOriginalInputImage() const;
00112   inline void setOriginalInputImage(Image<PixRGB<byte> > img);
00113 
00114   inline Image<PixRGB<byte> > getCurrInputImage() const;
00115   inline void setCurrInputImage(Image<PixRGB<byte> > img);
00116 
00117 protected:
00118   //void start1(); //!< get started
00119   //void stop2();  //!< get stopped
00120 
00121 private:
00122 
00123   void track();
00124   void trackCmaps();
00125   void trackVisualObjects();
00126 
00127   ImageSet<float> setNewBias
00128   (Point2D<int> inTrackLoc, Point2D<int> &biasOffset);
00129 
00130   Point2D<int> trackPoint
00131   (ImageSet<float> &bias, Point2D<int> biasOffset,
00132    Point2D<int> trackLoc);
00133 
00134   void updateTemplate(Point2D<int> upLeft, ImageSet<float> &bias);
00135 
00136   Image<float> getBiasedSMap(ImageSet<float> bias);
00137 
00138   // tracker and current results
00139   ImageSet<float> itsCurrCmap;
00140 
00141   std::vector<ImageSet<float> > itsTrackerBias;
00142   std::vector<Point2D<int> >    itsTrackerBiasOffset;
00143 
00144   std::vector<Point2D<int> > itsCurrTrackedPoints;
00145   std::vector<Point2D<int> > itsPrevTrackedPointsScaled;
00146 
00147   std::vector<rutz::shared_ptr<VisualObject> >
00148   itsCurrTrackedVisualObjects;
00149   std::vector<Rectangle> itsCurrTrackedROI;
00150 
00151   Image<PixRGB<byte> > itsOriginalInputImage;
00152   Image<PixRGB<byte> > itsCurrInputImage;
00153 
00154   Timer itsTimer;
00155 
00156   bool itsResetTracker;
00157 
00158   rutz::shared_ptr<XWinManaged> itsWin;
00159 };
00160 
00161 // ######################################################################
00162 // Implementation for SalientRegionTracker inline functions
00163 // ######################################################################
00164 
00165 
00166 // ######################################################################
00167 inline uint SalientRegionTracker::getNumTrackedPoints() const
00168 { return itsCurrTrackedPoints.size(); }
00169 
00170 inline Point2D<int>
00171 SalientRegionTracker::getCurrTrackedPoints(uint i) const
00172 {
00173   ASSERT(i < itsCurrTrackedPoints.size());
00174   return itsCurrTrackedPoints[i];
00175 }
00176 
00177 inline std::vector<Point2D<int> >
00178 SalientRegionTracker::getCurrTrackedPoints() const
00179 { return itsCurrTrackedPoints; }
00180 
00181 
00182 inline Rectangle
00183 SalientRegionTracker::getCurrTrackedROI(uint i) const
00184 {
00185   ASSERT(i < itsCurrTrackedROI.size());
00186   return itsCurrTrackedROI[i];
00187 }
00188 
00189 inline std::vector<Rectangle>
00190 SalientRegionTracker::getCurrTrackedROI() const
00191 { return itsCurrTrackedROI; }
00192 
00193 
00194 inline Point2D<int>
00195 SalientRegionTracker::getPrevTrackedPointsScaled(uint i) const
00196 {
00197   ASSERT(i < itsPrevTrackedPointsScaled.size());
00198   return itsPrevTrackedPointsScaled[i];
00199 }
00200 
00201 inline std::vector<Point2D<int> >
00202 SalientRegionTracker::getPrevTrackedPointsScaled() const
00203 {
00204   return itsPrevTrackedPointsScaled;
00205 }
00206 
00207 inline ImageSet<float>
00208 SalientRegionTracker::getTrackerBias(uint i) const
00209 {
00210   ASSERT(i < itsTrackerBias.size());
00211   return itsTrackerBias[i];
00212 }
00213 
00214 inline std::vector<ImageSet<float> >
00215 SalientRegionTracker::getTrackerBias() const
00216 {
00217   return itsTrackerBias;
00218 }
00219 
00220 inline Point2D<int>
00221 SalientRegionTracker::getTrackerBiasOffset(uint i) const
00222 {
00223   ASSERT(i < itsTrackerBiasOffset.size());
00224   return itsTrackerBiasOffset[i];
00225 }
00226 
00227 inline std::vector<Point2D<int> >
00228 SalientRegionTracker::getTrackerBiasOffset() const
00229 {
00230   return itsTrackerBiasOffset;
00231 }
00232 
00233 inline Image<PixRGB<byte> >
00234 SalientRegionTracker::getOriginalInputImage() const
00235 { return itsOriginalInputImage; }
00236 inline void
00237 SalientRegionTracker::setOriginalInputImage
00238 (Image<PixRGB<byte> > img)
00239 { itsOriginalInputImage = img;  }
00240 
00241 inline Image<PixRGB<byte> >
00242 SalientRegionTracker::getCurrInputImage() const
00243 { return itsCurrInputImage; }
00244 inline void SalientRegionTracker::setCurrInputImage
00245 (Image<PixRGB<byte> > img)
00246 { itsCurrInputImage = img;  }
00247 
00248 #endif
00249 
00250 // ######################################################################
00251 /* So things look consistent in everyone's emacs... */
00252 /* Local Variables: */
00253 /* indent-tabs-mode: nil */
00254 /* End: */
Generated on Sun May 8 08:40:13 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3