EyeTrackerISCAN.H

Go to the documentation of this file.
00001 /*!@file Psycho/EyeTrackerISCAN.H Abstraction for an ISCAN eye tracker */
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/EyeTrackerISCAN.H $
00035 // $Id: EyeTrackerISCAN.H 14159 2010-10-22 04:04:17Z ilink $
00036 //
00037 
00038 #ifndef PSYCHO_EYETRACKERISCAN_H_DEFINED
00039 #define PSYCHO_EYETRACKERISCAN_H_DEFINED
00040 
00041 #include "Psycho/EyeTracker.H"
00042 #include "Component/ModelParam.H"
00043 #include "rutz/atomic.h"
00044 class Serial;
00045 class ParPort;
00046 
00047 
00048 //! Interface to an ISCAN RK-464 eye-tracker
00049 /*! There are two modes of operation which can be used with the ISCAN
00050   tracker: trigger via serial port and no data streaming, or trigger
00051   via parallel port and data streaming over serial. */
00052 class EyeTrackerISCAN : public EyeTracker
00053 {
00054 public:
00055   //! Constructor
00056   EyeTrackerISCAN(OptionManager& mgr,
00057                   const std::string& descrName = "Eye Tracker ISCAN",
00058                   const std::string& tagName = "EyeTrackerISCAN");
00059   //! Destructor
00060   virtual ~EyeTrackerISCAN();
00061 
00062   //! Calibrate the tracker, full calibration
00063   /*! Here we do a 9-point calibration. */
00064   virtual void calibrate(nub::soft_ref<PsychoDisplay> d);
00065 
00066   //! Calibrate the tracker, quick re-calibration
00067   /*! Since there is no quick calibration for ISCAN, this is like a
00068     full calibration. */
00069   virtual void recalibrate(nub::soft_ref<PsychoDisplay> d, int repeats);
00070 
00071   //! Perform an online calibration
00072 
00073   virtual void calibrateOnline(nub::soft_ref<PsychoDisplay> d);
00074 
00075   //! Is the subject fixating?
00076   /*! TODO: This only works in parallel trigger mode. We check that eye
00077     position remains within a tolerance over a period of time (see
00078     model parameters). */
00079   virtual bool isFixating();
00080 
00081   //! Is the subject in a saccade?
00082   /*! TODO: give this some functionality */
00083   virtual bool isSaccade();
00084 
00085   //! Get current eye position
00086   /*! TODO: we need to think about calibration */
00087   virtual Point2D<int> getEyePos() const;
00088 
00089   //! Get current fixation position
00090   /*! TODO: we need to think about calibration */
00091   virtual Point2D<int> getFixationPos() const;
00092 
00093   //! Get the current calibrated eye position
00094   virtual Point2D<int> getCalibEyePos();
00095 
00096   //!Get the calibration set
00097   virtual CalibrationTransform::Data getCalibrationSet(nub::soft_ref<PsychoDisplay> d) const;
00098 
00099   //i want a quick calibrated eyeS file in the end
00100    void requestQuickEyeS();
00101 
00102 
00103 protected:
00104   //! Start the tracker
00105   /*! If serial trigger is selected, we send a single byte of value
00106     132 to start the ISCAN tracker. Otherwise, we violently set all
00107     pins of the parallel port to 0 to start the tracker. */
00108   virtual void startTracking();
00109 
00110   //! Stop the tracker
00111   /*! If serial trigger is selected, we send a single byte of value
00112     136 to stop the ISCAN tracker. Otherwise, we violently set all
00113     pins of the parallel port to 1 to stop the tracker. */
00114   virtual void stopTracking();
00115 
00116   OModelParam<bool> itsParTrig; //!< Use parallel-port start/stop trigger
00117   OModelParam<std::string> itsSerDev; //! device filename for serial port
00118   OModelParam<std::string> itsParDev; //! device filename for parallel port
00119 
00120   virtual void start1(); //!< get started
00121   virtual void start2(); //!< get started
00122   bool itsRequestQuickEyeS;
00123 private:
00124   nub::soft_ref<Serial> itsSerial;
00125   nub::soft_ref<ParPort> itsParPort;
00126   int itsRecalibCount;
00127   AffineTransform itsAffine;
00128 
00129   //live eye position polling stuff
00130   static void* eyePosPollThread(void* p);
00131 
00132   struct EyePosEvent
00133   {
00134     int64 tim;
00135     Point2D<int16> pt;
00136   };
00137 
00138   std::vector<EyePosEvent> itsEyePosEvents;
00139   pthread_t itsEyePosPollThread;
00140   rutz::atomic_int_t itsCurrentRawEyePos;
00141   rutz::atomic_int_t itsCurrentCalibEyePos;
00142   rutz::atomic_int_t itsCurrentCalibEyePosX;
00143   rutz::atomic_int_t itsCurrentCalibEyePosY;
00144 };
00145 
00146 
00147 // ######################################################################
00148 /* So things look consistent in everyone's emacs... */
00149 /* Local Variables: */
00150 /* mode: c++ */
00151 /* indent-tabs-mode: nil */
00152 /* End: */
00153 
00154 #endif // PSYCHO_EYETRACKERISCAN_H_DEFINED
Generated on Sun May 8 08:41:13 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3