GistEstimatorConfigurator.C

Go to the documentation of this file.
00001 /*!@file Neuro/GistEstimatorConfigurator.C
00002   future expansions for run-time options                                */
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: Christian Siagian <siagian@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/GistEstimatorConfigurator.C $
00036 // $Id: GistEstimatorConfigurator.C 10535 2008-12-17 03:37:06Z mviswana $
00037 //
00038 
00039 #include "Neuro/GistEstimatorConfigurator.H"
00040 #include "Component/OptionManager.H"
00041 #include "Neuro/GistEstimatorStd.H"
00042 #include "Neuro/GistEstimatorGen.H"
00043 #include "Neuro/GistEstimatorFFT.H"
00044 #include "Neuro/GistEstimatorTexton.H"
00045 #include "Neuro/GistEstimatorBeyondBoF.H"
00046 #include "Neuro/GistEstimatorContextBased.H"
00047 #include "Neuro/GistEstimatorSurfPMK.H"
00048 #include "Neuro/GistEstimatorStub.H"
00049 #include "Neuro/NeuroOpts.H"
00050 
00051 // ######################################################################
00052 GistEstimatorConfigurator::
00053 GistEstimatorConfigurator(OptionManager& mgr,
00054                           const std::string& descrName,
00055                           const std::string& tagName) :
00056   ModelComponent(mgr, descrName, tagName),
00057   itsGEtype(&OPT_GistEstimatorType, this),
00058   itsGE(new GistEstimatorStub(mgr))
00059 {
00060   addSubComponent(itsGE);
00061 }
00062 
00063 // ######################################################################
00064 GistEstimatorConfigurator::~GistEstimatorConfigurator()
00065 {  }
00066 
00067 // ######################################################################
00068 nub::ref<GistEstimator> GistEstimatorConfigurator::getGE() const
00069 { return itsGE; }
00070 
00071 // ######################################################################
00072 void GistEstimatorConfigurator::paramChanged(ModelParamBase* const param,
00073                                              const bool valueChanged,
00074                                              ParamClient::ChangeStatus* status)
00075 {
00076   ModelComponent::paramChanged(param, valueChanged, status);
00077 
00078   // was that a change of our baby's name?
00079   if (param == &itsGEtype) {
00080     // if we had one, let's unregister it (when we later reset() the
00081     // nub::ref, the current GistEstimator will unexport its
00082     // command-line options):
00083     removeSubComponent(*itsGE);
00084 
00085     // instantiate a controller of the appropriate type:
00086     if (itsGEtype.getVal().compare("None") == 0 ||
00087         itsGEtype.getVal().compare("Stub") == 0)
00088       itsGE.reset(new GistEstimatorStub(getManager()));
00089     else if (itsGEtype.getVal().compare("Std") == 0)
00090       itsGE.reset(new GistEstimatorStd(getManager()));
00091 #ifdef HAVE_FFTW3_H
00092     else if (itsGEtype.getVal().compare("FFT") == 0)
00093       itsGE.reset(new GistEstimatorFFT(getManager()));
00094 #endif
00095     else if (itsGEtype.getVal().compare("Texton") == 0)
00096       itsGE.reset(new GistEstimatorTexton(getManager()));
00097     else if (itsGEtype.getVal().compare("BeyondBoF") == 0 ||
00098              itsGEtype.getVal().compare("BBoF") == 0 ||
00099              itsGEtype.getVal().compare("bbof") == 0)
00100       itsGE.reset(new GistEstimatorBeyondBoF(getManager()));
00101     else if (itsGEtype.getVal().compare("SurfPMK") == 0 ||
00102              itsGEtype.getVal().compare("Surf") == 0 ||
00103              itsGEtype.getVal().compare("surf") == 0)
00104       itsGE.reset(new GistEstimatorSurfPMK(getManager()));
00105     else if (itsGEtype.getVal().compare("ContextBased") == 0 ||
00106              itsGEtype.getVal().compare("CB") == 0)
00107       itsGE.reset(new GistEstimatorContextBased(getManager()));
00108     else if (itsGEtype.getVal().compare("Gen") == 0)
00109       itsGE.reset(new GistEstimatorGen(getManager()));
00110     else
00111       LFATAL("Unknown GistEstimator type %s", itsGEtype.getVal().c_str());
00112 
00113     // add our baby as a subcomponent of us so that it will become
00114     // linked to the manager through us (hopefully we are registered
00115     // with the manager), which in turn will allow it to export its
00116     // command-line options and get configured:
00117 
00118     addSubComponent(itsGE);
00119 
00120     // tell it to export its options:
00121     itsGE->exportOptions(MC_RECURSE);
00122 
00123     // some info message:
00124     LINFO("Selected GE of type %s", itsGEtype.getVal().c_str());
00125   }
00126 }
00127 
00128 
00129 // ######################################################################
00130 /* So things look consistent in everyone's emacs... */
00131 /* Local Variables: */
00132 /* indent-tabs-mode: nil */
00133 /* End: */
Generated on Sun May 8 08:05:24 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3