VisualTracker.H

Go to the documentation of this file.
00001 /*!@file Image/VisualTracker.H Interface to VisualTracker */
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: Lior Elazary <elazary@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/VisualTracker.H $
00035 // $Id: VisualTracker.H 13551 2010-06-10 21:56:32Z itti $
00036 //
00037 
00038 #ifndef VisualTracker_H_DEFINED
00039 #define VisualTracker_H_DEFINED
00040 
00041 #include "Image/OpenCVUtil.H"  // must be first to avoid conflicting defs of int64, uint64
00042 
00043 #include "Component/ModelComponent.H"
00044 #include "Component/ModelParam.H"
00045 #include "Simulation/SimEvents.H"
00046 #include "Simulation/SimModule.H"
00047 #include "Image/Image.H"
00048 #include "Media/MediaSimEvents.H"
00049 #include "Channels/InputFrame.H"
00050 
00051 class  SimEventSetVisualTracker;
00052 
00053 class VisualTracker : public SimModule
00054 {
00055 public:
00056 
00057   //Constructor
00058   VisualTracker(OptionManager& mgr,
00059           const std::string& descrName = "VisualTracker",
00060           const std::string& tagName = "VisualTracker");
00061 
00062   ~VisualTracker();
00063 
00064   void start2();
00065 
00066   //! initalize the tracker
00067   void initTracker(Dims imageDims);
00068 
00069   //! Set the target point to track
00070   void setTargets(const Image<byte>& grey, const Point2D<int> loc);
00071 
00072   //! Set the target as a region to track
00073   void setTargets(const Image<byte>& grey, const Image<byte>& target);
00074 
00075   //! Get the location of track points
00076   Point2D<int> trackObjects(const Image<byte>& grey);
00077 
00078   //! Get the location of track objects
00079   Point2D<int> trackTemplObject(const Image<byte>& grey, double &err);
00080 
00081 protected:
00082   //! Callback for when a new input frame is available
00083   SIMCALLBACK_DECLARE(VisualTracker, SimEventInputFrame);
00084 
00085   SIMCALLBACK_DECLARE(VisualTracker, SimEventSetVisualTracker);
00086 
00087 private:
00088 
00089 #ifdef HAVE_OPENCV
00090     int itsMaxNumPoints;
00091     int itsCurrentNumPoints;
00092     CvPoint2D32f* itsCurrentPoints;
00093     CvPoint2D32f* itsPreviousPoints;
00094     IplImage *itsCurrentPyramid;
00095     IplImage *itsPreviousPyramid;
00096     Image<byte> itsPreviousGreyImg;
00097     Image<byte> itsCurrentGreyImg;
00098     char* itsTrackStatus;
00099     float* itsTrackError;
00100     int itsTrackFlags;
00101 
00102     CvHistogram *itsObjectHist; //the histogram of the object
00103     IplImage* itsBackproject;
00104     CvRect itsTrackWindow;
00105 
00106     Point2D<int> itsCurrentTargetLoc;
00107 
00108 
00109     //For kalman filtering
00110     bool itsUseKalman;
00111     CvKalman* itsKalman;
00112 #endif
00113 
00114     Image<byte> itsTargetTempl;
00115 
00116     bool itsInitTracker;
00117     bool itsTracking;
00118 
00119     OModelParam<int> itsTrackWindowSize;
00120     OModelParam<int> itsInitTrackWindowSize;
00121 
00122 };
00123 
00124 
00125 
00126 /* ############################### Ganglion sim events ######################## */
00127 class SimEventVisualTracker : public SimEvent
00128 {
00129 public:
00130   SimEventVisualTracker(SimModule* src, Point2D<int>& targetLoc, bool tracking) :
00131     SimEvent(src), itsTargetLoc(targetLoc),
00132     itsTracking(tracking)
00133   {}
00134 
00135   virtual ~SimEventVisualTracker(){}
00136 
00137   const Point2D<int> getTargetLoc() { return itsTargetLoc; }
00138   const bool isTracking() { return itsTracking; }
00139 
00140 private:
00141   const Point2D<int>& itsTargetLoc;
00142   bool itsTracking;
00143 };
00144 
00145 /* ############################### Ganglion sim events ######################## */
00146 class SimEventSetVisualTracker : public SimEvent
00147 {
00148 public:
00149   SimEventSetVisualTracker(SimModule* src, Point2D<int>& targetLoc) :
00150     SimEvent(src), itsTargetLoc(targetLoc)
00151   {}
00152 
00153   virtual ~SimEventSetVisualTracker(){}
00154 
00155   const Point2D<int> getTargetLoc() { return itsTargetLoc; }
00156 
00157 private:
00158   const Point2D<int>& itsTargetLoc;
00159 };
00160 
00161 
00162 #endif
00163 // ######################################################################
00164 /* So things look consistent in everyone's emacs... */
00165 /* Local Variables: */
00166 /* indent-tabs-mode: nil */
00167 /* End: */
Generated on Sun May 8 08:05:16 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3