SimulationViewerHand.H

Go to the documentation of this file.
00001 /*!@file Neuro/SimulationViewerHand.H comparison between saliency and
00002   human hands movement reaction (joystick, mouse, keyboard) */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003   //
00006 // by the University of Southern California (USC) and the iLab at USC.  //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: Dicky Nauli Sihite <sihite@usc.edu>
00035 // $HeadURL:
00036 // $Id:
00037 //
00038 
00039 #ifndef SIMULATIONVIEWERHAND_H_DEFINED
00040 #define SIMULATIONVIEWERHAND_H_DEFINED
00041 
00042 #include "Component/ModelParam.H"
00043 #include "Image/ImageCache.H"
00044 //#include "Image/ImageSet.H"
00045 //#include "Image/LevelSpec.H"
00046 #include "Neuro/SimulationViewer.H"
00047 #include "Simulation/SimEvents.H"
00048 
00049 #include <map>
00050 #include <vector>
00051 
00052 class HandData;
00053 class SpatialMetrics;
00054 class ofstream;
00055 class SimTime;
00056 
00057 typedef Point2D<int> (*Point2DTransform)(Point2D<int> P);
00058 
00059 //! Measure salience at human eye positions
00060 class SimulationViewerHand : public SimulationViewer {
00061 public:
00062   // ######################################################################
00063   /*! @name Constructors and destructors */
00064   //@{
00065 
00066   //! Constructor. See ModelComponent.H.
00067   SimulationViewerHand(OptionManager& mgr,
00068                        const std::string& descrName =
00069                        "Hand Simulation Viewer",
00070                        const std::string& tagName =
00071                        "SimulationViewerHand");
00072   
00073   //! Destructor
00074   virtual ~SimulationViewerHand();
00075   
00076   //@}
00077 
00078 protected:
00079   //! Callback for every clock tick
00080   SIMCALLBACK_DECLARE(SimulationViewerHand, SimEventClockTick);
00081 
00082   //! Callback for every time we should save our outputs
00083   SIMCALLBACK_DECLARE(SimulationViewerHand, SimEventSaveOutput);
00084 
00085   //! Save our various results
00086   void save1(const ModelComponentSaveInfo& sinfo);
00087   
00088   //! Get the attention/eye/head trajectory image
00089   virtual Image< PixRGB<byte> > getTraj(SimEventQueue& q);
00090 
00091   nub::ref<SpatialMetrics> itsMetrics;//!< metrics that depend on input size
00092   
00093   OModelParam<bool> itsSaveTraj;      //!< save trajectory?
00094   OModelParam<bool> itsSaveCombo;     //!< save combo?
00095   OModelParam<bool> itsDisplayHand;  //!< display Hand position
00096   OModelParam<int> itsPatchSize;      //!< size of marker at eye position
00097   OModelParam<bool> itsEraseMarker;   //!< erase marker at each frame
00098   OModelParam<int> itsMaxComboWidth; //!< max width of getTraj()
00099 
00100   virtual void start1(); //!< get started
00101   virtual void stop1();  //!< get stopped
00102 
00103   virtual void drawHand(const rutz::shared_ptr<HandData> data, const uint trackerNum);  // overloaded by HandRegion
00104 
00105   // overloaded by HandRegion to do its output
00106   virtual void extraSampleProcessing(const rutz::shared_ptr<HandData>);
00107 
00108   Image< PixRGB<byte> > itsDrawings;  // our drawings - black is transparent!
00109   // these drawings include, from SVHand: the eyetrace
00110   // from SVHandRegion: the names and borders of regions
00111 
00112   SimTime itsCurrTime;
00113   uint itsFrameNumber;     // this member is never used in SVHand
00114 
00115   bool itsHeaderCrafted;
00116   std::vector<std::string> itsOutFields;
00117 
00118   struct GHandFormat {
00119     PixRGB<byte> col;
00120     std::string label; // depends on OModelParam
00121     int pSize; // patch size
00122     // shape? other aspects?
00123   };
00124 
00125   std::vector<GHandFormat> itsHandStyles;
00126 private:
00127   // Used in DrawHand for coordinate system
00128   // Get the grid coordinate of position W-th and H-th of a
00129   // grid system with src size of block
00130   inline Dims getGridCoord(Dims src, int W_, int H_) {
00131     Dims dst (src.w() * W_, src.h() * H_);
00132     return dst; 
00133   };
00134   std::map<int, rutz::shared_ptr<HandData> > itsTargets;
00135 };
00136 
00137 #endif
00138 
00139 // ######################################################################
00140 /* So things look consistent in everyone's emacs... */
00141 /* Local Variables: */
00142 /* indent-tabs-mode: nil */
00143 /* End: */
Generated on Sun May 8 08:41:04 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3