00001 /*!@file Psycho/EyeTrace.H An eye movement trace */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00005 // by the 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: John Shen <shenjohn@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Psycho/EyeTrace.H $ 00035 // 00036 00037 #ifndef PSYCHO_EYETRACE_H_DEFINED 00038 #define PSYCHO_EYETRACE_H_DEFINED 00039 00040 #include "Image/Pixels.H" 00041 #include "Psycho/PixPerDeg.H" 00042 #include "Psycho/EyeData.H" 00043 //#include "Psycho/HandData.H" //remove me 00044 #include "Util/SimTime.H" 00045 #include "rutz/shared_ptr.h" 00046 #include "Component/ParamMap.H" 00047 00048 #include <string> 00049 #include <vector> 00050 00051 //! An eye movement trace 00052 /*! This class encapsulates a simple eye movement trace and provides 00053 I/O functions. */ 00054 class EyeTrace { 00055 public: 00056 00057 // ###################################################################### 00058 /*! @name Constructors, destructor and initialization */ 00059 //@{ 00060 00061 //! Constructor from a file on disk, use given display color 00062 EyeTrace(const std::string& filename, const PixRGB<byte>& color); 00063 00064 //! Destructor 00065 ~EyeTrace(); 00066 00067 //@} 00068 00069 // ###################################################################### 00070 /*! @name Data access functions */ 00071 //@{ 00072 00073 //! Did sample of given index happen before given time? 00074 /*! Typically one would keep incrementing the index until we return 00075 false here, at which point it would be time to increment the 00076 time. Note that we will always return false after the index gets 00077 past all available samples in the trace. */ 00078 bool hasData(const size_t index, const SimTime& t) const; 00079 00080 //! Do we have a sample for the given index? 00081 /*! This will return true as long as the index is not past the 00082 available amount of data. */ 00083 bool hasData(const size_t index) const; 00084 00085 //! Get the data for a given index 00086 /*! Note that this will throw a fatal error if we don't have data 00087 for that index; so be sure to check with hasData() first. */ 00088 rutz::shared_ptr<EyeData> data(const size_t index) const; 00089 00090 //We need to be able to export the RawExtraData as well and pass it through... 00091 00092 //! Get our display color 00093 PixRGB<byte> color() const; 00094 00095 //! Get number of available (non-trash) samples 00096 size_t size() const; 00097 //! Get number of parsed events (if any) 00098 size_t numEvents() const; 00099 //! Deprecated command, as new markup may apply to more than saccades 00100 size_t numSaccades() const; 00101 00102 //@} 00103 00104 // ###################################################################### 00105 /*! @name Metadata access functions */ 00106 //@{ 00107 00108 //! Get sampling period 00109 SimTime period() const; 00110 00111 //! Get filename 00112 std::string filename() const; 00113 00114 //! Get filename, without extension if any 00115 std::string basename() const; 00116 00117 //! Get pixels-per-degree of the display 00118 PixPerDeg ppd() const; 00119 //@} 00120 00121 private: 00122 // forbid assignment and copy-construction: 00123 EyeTrace& operator=(const EyeTrace& e); 00124 EyeTrace(const EyeTrace& e); 00125 00126 //decode status to SaccadeState 00127 const SaccadeState getStatus( const int) const; 00128 00129 // add data from an unformatted line 00130 bool pushData(const std::string line); 00131 bool isEventField(const std::string field) const; 00132 std::string itsFilename; 00133 PixRGB<byte> itsColor; 00134 SimTime itsPeriod; 00135 size_t itsTrash; 00136 PixPerDeg itsPPD; 00137 uint itsNumEvents; 00138 00139 std::vector<std::string> itsFields; 00140 00141 // for internal use only! 00142 struct RawEyeData { 00143 float x, y, diam; 00144 int status; 00145 rutz::shared_ptr<ParamMap> extraData; // may be NULL if no extra data 00146 }; 00147 std::vector<RawEyeData> itsData; 00148 std::vector<rutz::shared_ptr<ParamMap> > itsEvents; 00149 }; 00150 00151 00152 // ###################################################################### 00153 /* So things look consistent in everyone's emacs... */ 00154 /* Local Variables: */ 00155 /* mode: c++ */ 00156 /* indent-tabs-mode: nil */ 00157 /* End: */ 00158 00159 #endif // PSYCHO_EYETRACE_H_DEFINED