EyeTrackerConfigurator.C

Go to the documentation of this file.
00001 /*!@file Psycho/EyeTrackerConfigurator.C Select an EyeTracker type */
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/EyeTrackerConfigurator.C $
00035 // $Id: EyeTrackerConfigurator.C 12686 2010-01-27 21:48:44Z beobot $
00036 //
00037 
00038 #ifndef PSYCHO_EYETRACKERCONFIGURATOR_C_DEFINED
00039 #define PSYCHO_EYETRACKERCONFIGURATOR_C_DEFINED
00040 
00041 #include "Psycho/EyeTrackerConfigurator.H"
00042 #include "Psycho/EyeTracker.H"
00043 #include "Psycho/EyeTrackerISCAN.H"
00044 #include "Psycho/EyeTrackerDML.H"
00045 #include "Psycho/EyeTrackerUDP.H"
00046 #include "Psycho/EyeTrackerStub.H"
00047 #include "Psycho/EyeTrackerTIL.H"
00048 #include "Psycho/EyeTrackerEyeLink.H"
00049 #include "Component/OptionManager.H"
00050 #include "Psycho/PsychoOpts.H"
00051 
00052 // ######################################################################
00053 EyeTrackerConfigurator::
00054 EyeTrackerConfigurator(OptionManager& mgr,
00055                        const std::string& descrName,
00056                        const std::string& tagName) :
00057   ModelComponent(mgr, descrName, tagName),
00058   itsETtype(&OPT_EyeTrackerType, this),
00059   itsET(new EyeTrackerStub(mgr))
00060 {
00061   this->addSubComponent(itsET);
00062 }
00063 
00064 // ######################################################################
00065 EyeTrackerConfigurator::~EyeTrackerConfigurator()
00066 {  }
00067 
00068 // ######################################################################
00069 nub::ref<EyeTracker> EyeTrackerConfigurator::getET() const
00070 { return itsET; }
00071 
00072 // ######################################################################
00073 void EyeTrackerConfigurator::paramChanged(ModelParamBase* const param,
00074                                           const bool valueChanged,
00075                                           ParamClient::ChangeStatus* status)
00076 {
00077   ModelComponent::paramChanged(param, valueChanged, status);
00078 
00079   // was that a change of our baby's name?
00080   if (param == &itsETtype) {
00081     // some info message:
00082     LINFO("Configuring ET of type %s", itsETtype.getVal().c_str());
00083 
00084     // let's unregister our current EyeTracker (when we later reset()
00085     // the nub::ref, the current EyeTracker will unexport its
00086     // command-line options):
00087     LINFO("Resetting EyeTracker...");
00088     removeSubComponent(*itsET);
00089 
00090     // instantiate an EyeTracker of the appropriate type:
00091 
00092     // #################### No eye-tracker:
00093     if (itsETtype.getVal().compare("None") == 0 ||
00094         itsETtype.getVal().compare("Stub") == 0)
00095       itsET.reset(new EyeTrackerStub(getManager()));
00096 
00097     // #################### ISCAN:
00098     else if (itsETtype.getVal().compare("ISCAN") == 0)
00099       itsET.reset(new EyeTrackerISCAN(getManager()));
00100 
00101     // #################### DML (Doug Munoz Lab):
00102     else if (itsETtype.getVal().compare("DML") == 0)
00103       itsET.reset(new EyeTrackerDML(getManager()));
00104 
00105     // #################### DML (Doug Munoz Lab):
00106     else if (itsETtype.getVal().compare("UDP") == 0)
00107       itsET.reset(new EyeTrackerUDP(getManager()));
00108 
00109     // #################### TIL (Tadashi Isa Lab):
00110     else if (itsETtype.getVal().compare("TIL") == 0)
00111       itsET.reset(new EyeTrackerTIL(getManager()));
00112 
00113     // #################### EyeLink-II:
00114     else if (itsETtype.getVal().compare("EL") == 0)
00115       itsET.reset(new EyeTrackerEyeLink(getManager()));
00116 
00117     // #################### Unknown:
00118     else LFATAL("Unknown EyeTracker type: %s", itsETtype.getVal().c_str());
00119 
00120     // add our baby as a subcomponents of us so that it will
00121     // become linked to the manager through us (hopefully we are
00122     // registered with the manager), which in turn will allow it to
00123     // export command-line options and get configured:
00124     addSubComponent(itsET);
00125 
00126     // export options:
00127     itsET->exportOptions(MC_RECURSE);
00128   }
00129 }
00130 
00131 // ######################################################################
00132 /* So things look consistent in everyone's emacs... */
00133 /* Local Variables: */
00134 /* mode: c++ */
00135 /* indent-tabs-mode: nil */
00136 /* End: */
00137 
00138 #endif // PSYCHO_EYETRACKERCONFIGURATOR_C_DEFINED
Generated on Sun May 8 08:41:13 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3