00001 /** 00002 \file Robots/LoBot/io/LoInputSource.H 00003 00004 \brief Input source encapsulation for the Lobot/Robolocust project. 00005 00006 This file defines the lobot::InputSource class, which is used to wrap 00007 around the classes responsible for the different kinds of input lobot 00008 can handle. These inputs include video streams, the laser range finder 00009 and a direct connection to actual locusts. 00010 */ 00011 00012 // //////////////////////////////////////////////////////////////////// // 00013 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00014 // by the University of Southern California (USC) and the iLab at USC. // 00015 // See http://iLab.usc.edu for information about this project. // 00016 // //////////////////////////////////////////////////////////////////// // 00017 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00018 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00019 // in Visual Environments, and Applications'' by Christof Koch and // 00020 // Laurent Itti, California Institute of Technology, 2001 (patent // 00021 // pending; application number 09/912,225 filed July 23, 2001; see // 00022 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00023 // //////////////////////////////////////////////////////////////////// // 00024 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00025 // // 00026 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00027 // redistribute it and/or modify it under the terms of the GNU General // 00028 // Public License as published by the Free Software Foundation; either // 00029 // version 2 of the License, or (at your option) any later version. // 00030 // // 00031 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00032 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00033 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00034 // PURPOSE. See the GNU General Public License for more details. // 00035 // // 00036 // You should have received a copy of the GNU General Public License // 00037 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00038 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00039 // Boston, MA 02111-1307 USA. // 00040 // //////////////////////////////////////////////////////////////////// // 00041 // 00042 // Primary maintainer for this file: mviswana usc edu 00043 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/io/LoInputSource.H $ 00044 // $Id: LoInputSource.H 13037 2010-03-23 01:00:53Z mviswana $ 00045 // 00046 00047 #ifndef LOBOT_INPUT_SOURCE_DOT_H 00048 #define LOBOT_INPUT_SOURCE_DOT_H 00049 00050 //------------------------------ HEADERS -------------------------------- 00051 00052 // lobot headers 00053 #include "Robots/LoBot/io/LoImageSource.H" 00054 #include "Robots/LoBot/io/LoLaserRangeFinder.H" 00055 00056 #include "Robots/LoBot/config/LoDefaults.H" 00057 #include "Robots/LoBot/misc/LoTypes.H" 00058 #include "Robots/LoBot/util/range.hh" 00059 00060 // INVT image support 00061 #include "Image/Dims.H" 00062 00063 //----------------------------- NAMESPACE ------------------------------- 00064 00065 namespace lobot { 00066 00067 //------------------------- CLASS DEFINITION ---------------------------- 00068 00069 /** 00070 \class lobot::InputSource 00071 \brief Input sources wrapper for Lobot/Robolocust project. 00072 00073 This class wraps around lobot::ImageSource and lobot::LaserRangeFinder 00074 so that its clients need only worry about interfacing with this one 00075 class instead of having to mess around with the APIs of many different 00076 classes. 00077 */ 00078 class InputSource { 00079 // Prevent copy and assignment 00080 InputSource(const InputSource&) ; 00081 InputSource& operator=(const InputSource&) ; 00082 00083 /// The input may be coming either from a video stream (i.e., FireWire 00084 /// camera or MPEG file) or from the laser range finder. 00085 ImageSource<PixelType>* m_video ; 00086 LaserRangeFinder* m_laser ; 00087 00088 public: 00089 /// This constructor sets up an input source to read from an image 00090 /// source (either FireWire cameras or MPEG files). Usually, if there 00091 /// are multiple cameras or MPEGs involved, the image source will be 00092 /// set up to combine these multiple input images into a single image. 00093 InputSource(ImageSource<PixelType>*) ; 00094 00095 /// This constructor sets up the laser range finder as the input 00096 /// source. 00097 InputSource(LaserRangeFinder*) ; 00098 00099 /// Returns true if the input source is configured to use video. 00100 bool using_video() const {return m_video != 0 ;} 00101 00102 /// Returns true if the input source is configured to use laser. 00103 bool using_laser() const {return m_laser != 0 ;} 00104 00105 /// Return the size of the input image if the input really is a video 00106 /// source; throw an exception otherwise. 00107 Dims get_image_size() const ; 00108 00109 /// Return the grayscale version of the input image. Throws an 00110 /// exception if the input source is not a video stream. 00111 GrayImage get_grayscale_image() const ; 00112 00113 /// Return the angular range of the laser range finder. Throw an 00114 /// exception if the input source is not the laser range finder. 00115 range<int> lrf_angular_range() const ; 00116 00117 /// Return the distance reading corresponding to the supplied angle. 00118 /// Throw an exception if the input source is not the laser range 00119 /// finder. 00120 int get_distance(int angle) const ; 00121 00122 /// Return the average distance in an angular range. Throw an 00123 /// exception if the input source is not the laser range finder. 00124 //@{ 00125 float average_distance(int min, int max) const ; 00126 float average_distance(const range<int>& R) const { 00127 return average_distance(R.min(), R.max()) ; 00128 } 00129 //@} 00130 00131 /// Clean-up 00132 ~InputSource() ; 00133 } ; 00134 00135 //----------------------------------------------------------------------- 00136 00137 } // end of namespace encapsulating this file's definitions 00138 00139 #endif 00140 00141 /* So things look consistent in everyone's emacs... */ 00142 /* Local Variables: */ 00143 /* indent-tabs-mode: nil */ 00144 /* End: */