EyeTracker.C

Go to the documentation of this file.
00001 /*!@file Psycho/EyeTracker.C Abstraction of an eye tracker device */
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: Laurent Itti <itti@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Psycho/EyeTracker.C $
00035 // $Id: EyeTracker.C 14176 2010-10-28 04:28:19Z ilink $
00036 //
00037 
00038 #ifndef PSYCHO_EYETRACKER_C_DEFINED
00039 #define PSYCHO_EYETRACKER_C_DEFINED
00040 
00041 #include "Psycho/EyeTracker.H"
00042 #include "Component/EventLog.H"
00043 #include "Util/sformat.H"
00044 
00045 // ######################################################################
00046 EyeTracker::EyeTracker(OptionManager& mgr, const std::string& descrName,
00047                        const std::string& tagName) :
00048   ModelComponent(mgr, descrName, tagName),
00049   itsEventLog(), itsIsTracking(false)
00050 {  }
00051 
00052 // ######################################################################
00053 EyeTracker::~EyeTracker()
00054 {  }
00055 
00056 // ######################################################################
00057 void EyeTracker::setEventLog(nub::soft_ref<EventLog> elog)
00058 { itsEventLog = elog; }
00059 
00060 // ######################################################################
00061 void EyeTracker::start1()
00062 {
00063   // reset session number:
00064   itsSession = 0;
00065 }
00066 
00067 // ######################################################################
00068 int EyeTracker::getSession() const
00069 { return itsSession; }
00070 
00071 // ######################################################################
00072 void EyeTracker::calibrate(nub::soft_ref<PsychoDisplay> d)
00073 {
00074   LINFO("Calibration not supported in this tracker.");
00075 }
00076 
00077 // ######################################################################
00078 void EyeTracker::setBackgroundColor(nub::soft_ref<PsychoDisplay> d)
00079 {
00080   LINFO("SetBackgroundColor not supported in this tracker.");
00081 }
00082 
00083 // ######################################################################
00084 void EyeTracker::manualDriftCorrection(Point2D<double> eyepos, 
00085                                                                                        Point2D<double> targetpos)
00086 {
00087   LINFO("Recalibration not supported in this tracker.");
00088 }
00089 
00090 // ######################################################################
00091 void EyeTracker::recalibrate(nub::soft_ref<PsychoDisplay> d, int repeats)
00092 {
00093   LINFO("Recalibration not supported in this tracker.");
00094 }
00095 
00096 // ######################################################################
00097 void EyeTracker::calibrateOnline(nub::soft_ref<PsychoDisplay> d)
00098 {
00099   LFATAL("online calibration not supported on this tracker");
00100 }
00101 
00102 // ######################################################################
00103 void EyeTracker::closeSDL()
00104 {
00105   LFATAL("online calibration not supported on this tracker");
00106 }
00107 
00108 // ######################################################################
00109 void EyeTracker::openSDL()
00110 {
00111   LFATAL("online calibration not supported on this tracker");
00112 }
00113 
00114 // ######################################################################
00115 void EyeTracker::track(const bool startstop)
00116 {
00117   if (startstop)
00118     {
00119       if (itsIsTracking)
00120         LERROR("Request to start tracking ignored, already tracking...");
00121       else
00122         {
00123           this->startTracking(); // derived classes implement this
00124           if (itsEventLog.isValid())
00125             itsEventLog->
00126               pushEvent(sformat("----- Eye Tracker Start session %d -----",
00127                                 itsSession));
00128           itsIsTracking = true;
00129         }
00130     }
00131   else
00132     {
00133       if (itsIsTracking == false)
00134         LERROR("Request to stop tracking ignored, not tracking...");
00135       else
00136         {
00137           this->stopTracking();  // derived classes implement this
00138           if (itsEventLog.isValid())
00139             itsEventLog->
00140               pushEvent(sformat("----- Eye Tracker Stop session %d -----",
00141                                 itsSession));
00142           ++itsSession;   // ready for next session:
00143           itsIsTracking = false;
00144         }
00145     }
00146 }
00147 
00148 // ######################################################################
00149 bool EyeTracker::isTracking() const
00150 { return itsIsTracking; }
00151 
00152 // ######################################################################
00153 void EyeTracker::clearEyeStatus()
00154 {
00155   while (isFixating()) ;
00156   while (isSaccade()) ;
00157 }
00158 
00159 // ######################################################################
00160 Point2D<int> EyeTracker::getCalibEyePos()
00161 {        LFATAL("not supported");
00162         return Point2D<int>(-1,-1);}
00163 
00164 // #####################################################################
00165 void EyeTracker::requestQuickEyeS()
00166 {
00167     LFATAL("can't save eyeS only eyetrackers with online calibration support this");
00168 }
00169 
00170 // ####################################################################
00171 
00172 void EyeTracker::setCurrentStimFile(std::string filename)
00173 {
00174     itsCurrentStimFile = filename;
00175 }
00176 
00177 // ####################################################################
00178 
00179 std::string EyeTracker::getCurrentStimFile()
00180 {
00181     if(!itsCurrentStimFile.empty())
00182             return itsCurrentStimFile;
00183         else
00184         {  LERROR("itsCurrentStimFile not set");
00185             return NULL;
00186         }
00187 
00188 
00189 }
00190 
00191 
00192 
00193 /* So things look consistent in everyone's emacs... */
00194 /* Local Variables: */
00195 /* mode: c++ */
00196 /* indent-tabs-mode: nil */
00197 /* End: */
00198 
00199 #endif // PSYCHO_EYETRACKER_C_DEFINED
Generated on Sun May 8 08:41:13 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3