LoInputSource.C

Go to the documentation of this file.
00001 /**
00002    \file Robots/LoBot/io/LoInputSource.C
00003 
00004    \brief This file defines the non-inline member functions of the
00005    lobot::InputSource class, which is used to wrap around the classes
00006    responsible for the different kinds of input lobot can handle.
00007 */
00008 
00009 // //////////////////////////////////////////////////////////////////// //
00010 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00011 // by the University of Southern California (USC) and the iLab at USC.  //
00012 // See http://iLab.usc.edu for information about this project.          //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00015 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00016 // in Visual Environments, and Applications'' by Christof Koch and      //
00017 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00018 // pending; application number 09/912,225 filed July 23, 2001; see      //
00019 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00020 // //////////////////////////////////////////////////////////////////// //
00021 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00024 // redistribute it and/or modify it under the terms of the GNU General  //
00025 // Public License as published by the Free Software Foundation; either  //
00026 // version 2 of the License, or (at your option) any later version.     //
00027 //                                                                      //
00028 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00029 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00030 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00031 // PURPOSE.  See the GNU General Public License for more details.       //
00032 //                                                                      //
00033 // You should have received a copy of the GNU General Public License    //
00034 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00035 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00036 // Boston, MA 02111-1307 USA.                                           //
00037 // //////////////////////////////////////////////////////////////////// //
00038 //
00039 // Primary maintainer for this file: Manu Viswanathan mviswana usc edu
00040 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/io/LoInputSource.C $
00041 // $Id: LoInputSource.C 12853 2010-02-16 16:33:21Z mviswana $
00042 //
00043 
00044 //------------------------------ HEADERS --------------------------------
00045 
00046 // lobot headers
00047 #include "Robots/LoBot/io/LoInputSource.H"
00048 #include "Robots/LoBot/misc/LoExcept.H"
00049 
00050 //----------------------------- NAMESPACE -------------------------------
00051 
00052 namespace lobot {
00053 
00054 //-------------------------- INITIALIZATION -----------------------------
00055 
00056 // Read input from an image source
00057 InputSource::InputSource(ImageSource<PixelType>* is)
00058    : m_video(is),
00059      m_laser(0)
00060 {}
00061 
00062 // Read input from a laser range finder
00063 InputSource::InputSource(LaserRangeFinder* lrf)
00064    : m_video(0),
00065      m_laser(lrf)
00066 {}
00067 
00068 //---------------------- VIDEO SOURCE INTERFACE -------------------------
00069 
00070 Dims InputSource::get_image_size() const
00071 {
00072    if (m_video)
00073       return m_video->getImageSize() ;
00074    throw vstream_error(NO_VIDEOSTREAM_SOURCE) ;
00075 }
00076 
00077 GrayImage InputSource::get_grayscale_image() const
00078 {
00079    if (m_video)
00080       return m_video->getImageGray() ;
00081    throw vstream_error(NO_VIDEOSTREAM_SOURCE) ;
00082 }
00083 
00084 //------------------- LASER RANGE FINDER INTERFACE ----------------------
00085 
00086 range<int> InputSource::lrf_angular_range() const
00087 {
00088    if (m_laser)
00089       return m_laser->get_angular_range() ;
00090    throw lrf_error(NO_LRF_SOURCE) ;
00091 }
00092 
00093 int InputSource::get_distance(int angle) const
00094 {
00095    if (m_laser)
00096       return m_laser->get_distance(angle) ;
00097    throw lrf_error(NO_LRF_SOURCE) ;
00098 }
00099 
00100 float InputSource::average_distance(int min, int max) const
00101 {
00102    if (m_laser)
00103       return m_laser->average_distance(min, max) ;
00104    throw lrf_error(NO_LRF_SOURCE) ;
00105 }
00106 
00107 //----------------------------- CLEAN-UP --------------------------------
00108 
00109 InputSource::~InputSource() {}
00110 
00111 //-----------------------------------------------------------------------
00112 
00113 } // end of namespace encapsulating this file's definitions
00114 
00115 /* So things look consistent in everyone's emacs... */
00116 /* Local Variables: */
00117 /* indent-tabs-mode: nil */
00118 /* End: */
Generated on Sun May 8 08:05:54 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3