FrameGrabberConfigurator.C

Go to the documentation of this file.
00001 /*!@file Devices/FrameGrabberConfigurator.C Base class for a frame grabber device */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003   //
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/Devices/FrameGrabberConfigurator.C $
00035 // $Id: FrameGrabberConfigurator.C 14459 2011-02-01 18:56:07Z ehu $
00036 //
00037 
00038 #include "Devices/FrameGrabberConfigurator.H"
00039 
00040 #include "Component/OptionManager.H"
00041 #include "Devices/DeviceOpts.H"
00042 #include "Devices/FrameGrabberFactory.H"
00043 #include "Transport/BobDeinterlacer.H"
00044 
00045 // ######################################################################
00046 FrameGrabberConfigurator::
00047 FrameGrabberConfigurator(OptionManager& mgr,
00048                          const std::string& descrName,
00049                          const std::string& tagName) :
00050   ModelComponent(mgr, descrName, tagName),
00051   itsGrabberType(&OPT_FrameGrabberType, this),
00052   itsDeinterlacerType(&OPT_DeinterlacerType, this),
00053   itsGrabber()
00054 {  }
00055 
00056 // ######################################################################
00057 FrameGrabberConfigurator::~FrameGrabberConfigurator()
00058 {  }
00059 
00060 // ######################################################################
00061 nub::soft_ref<FrameIstream> FrameGrabberConfigurator::getFrameGrabber() const
00062 {
00063   if (itsDeinterlacer.isValid())
00064     {
00065       itsDeinterlacer->setDelegate(itsGrabber);
00066       return itsDeinterlacer;
00067     }
00068 
00069   // else... we have no deinterlacer, so just return the plain grabber
00070   return itsGrabber;
00071 }
00072 
00073 // ######################################################################
00074 void FrameGrabberConfigurator::
00075 paramChanged(ModelParamBase* const param,
00076              const bool valueChanged,
00077              ParamClient::ChangeStatus* status)
00078 {
00079   ModelComponent::paramChanged(param, valueChanged, status);
00080 
00081   // was that a change of our baby's name?
00082   if (param == &itsGrabberType) {
00083     // if we had one, let's unregister it and destroy it; upon
00084     // destruction, it will unexport its command-line options:
00085     if (itsGrabber.isValid())
00086       { removeSubComponent(*itsGrabber); itsGrabber.reset(NULL); }
00087 
00088     // instantiate a grabber of the appropriate type:
00089     if (itsGrabberType.getVal().compare("None") == 0)
00090       itsGrabber.reset(NULL);
00091     else if (itsGrabberType.getVal().compare("V4L") == 0)
00092       itsGrabber = makeV4Lgrabber(getManager());
00093     else if (itsGrabberType.getVal().compare("V4L2") == 0)
00094       itsGrabber = makeV4L2grabber(getManager());
00095     else if (itsGrabberType.getVal().compare("1394") == 0)
00096       itsGrabber = makeIEEE1394grabber(getManager());
00097     else if (itsGrabberType.getVal().compare("XC") == 0)
00098       itsGrabber = makeXCgrabber(getManager());
00099     else if (itsGrabberType.getVal().compare("XCFLEX") == 0)
00100       itsGrabber = makeXCgrabberFlex(getManager());
00101     else if (itsGrabberType.getVal().compare("KINECT") == 0)
00102       itsGrabber = makeKinectgrabber(getManager());
00103     else if (itsGrabberType.getVal().compare("OPENNI") == 0)
00104       itsGrabber = makeOpenNIgrabber(getManager());
00105     else
00106       LFATAL("Unknown FrameGrabber type %s", itsGrabberType.getVal().c_str());
00107 
00108     // add our baby as a subcomponent of us so that it will become
00109     // linked to the manager through us (hopefully we are registered
00110     // with the manager), which in turn will allow it to export its
00111     // command-line options and get configured:
00112     if (itsGrabber.isValid()) {
00113       addSubComponent(itsGrabber);
00114 
00115       // tell the controller to export its options:
00116       itsGrabber->exportOptions(MC_RECURSE);
00117     }
00118 
00119     // some info message:
00120     LINFO("Selected FrameGrabber of type %s", itsGrabberType.getVal().c_str());
00121   }
00122 
00123   else if (param == &itsDeinterlacerType) {
00124     if (itsDeinterlacer.isValid())
00125       {
00126         removeSubComponent(*itsDeinterlacer);
00127         itsDeinterlacer.reset(NULL);
00128       }
00129 
00130     if (itsDeinterlacerType.getVal().compare("None") == 0)
00131       itsDeinterlacer.reset(NULL);
00132     else if (itsDeinterlacerType.getVal().compare("Bob") == 0)
00133       itsDeinterlacer.reset(new BobDeinterlacer(getManager()));
00134     else
00135       LFATAL("Unknown Deinterlacer type %s",
00136              itsDeinterlacerType.getVal().c_str());
00137 
00138     if (itsDeinterlacer.isValid()) {
00139       addSubComponent(itsDeinterlacer);
00140 
00141       itsDeinterlacer->exportOptions(MC_RECURSE);
00142     }
00143 
00144     // some info message:
00145     LINFO("Selected Deinterlacer of type %s",
00146           itsDeinterlacerType.getVal().c_str());
00147   }
00148 }
00149 
00150 
00151 // ######################################################################
00152 /* So things look consistent in everyone's emacs... */
00153 /* Local Variables: */
00154 /* indent-tabs-mode: nil */
00155 /* End: */
Generated on Sun May 8 08:40:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3