00001 /*!@file Devices/VectorField.H Vector field class to compute vector 00002 histogram field */ 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00006 // 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: Farhan Baluch 00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/VectorField.H $ 00036 // $Id: VectorField.H 12962 2010-03-06 02:13:53Z irock $ 00037 // 00038 00039 #ifndef VectorField_H_DEFINED 00040 #define VectorField_H_DEFINED 00041 00042 #include "Component/ModelComponent.H" 00043 #include "Component/ModelParam.H" 00044 #include "Util/Types.H" // for byte 00045 #include "Image/Image.H" 00046 #include "Image/Pixels.H" 00047 #include "Image/vec2.h" 00048 00049 using namespace geom; 00050 00051 class VectorField : public ModelComponent 00052 { 00053 public: 00054 //! Default constructor; see ModelComponent.H 00055 VectorField(OptionManager& mgr, 00056 const std::string& descrName = "VectorField", 00057 const std::string& tagName = "VectorField", 00058 const int width=300, const int height=300); 00059 00060 //!constructor from field 00061 VectorField(Image<geom::vec2f> afield){ 00062 itsField = afield; itsDims=afield.getDims(); 00063 } 00064 00065 00066 //! Destructor 00067 ~VectorField(); 00068 00069 //!getField() -- returns the current vector field. 00070 Image<geom::vec2f> getField(); 00071 00072 /*!updateField() -- update the current field based on some sensor data 00073 of type Point2D<int> a; where a.i = distance a.j=angle of obstacle 00074 since this can be pretty implementation specific we keep this virtual 00075 so that different algorithms can implement their own implementation of 00076 this method. 00077 */ 00078 virtual Image<PixRGB<byte> > updateField( 00079 std::vector<Point2D<float> > sensorData, Point2D<int> robotPos, 00080 float robotOrient, Point2D<int> goal) 00081 { 00082 Image<PixRGB<byte> > emptyImg(1,1,ZEROS); 00083 return emptyImg; 00084 } 00085 00086 //!plotField() -- plot the current vector Field. 00087 Image<PixRGB<byte> > plotField(int spacing); 00088 00089 //!plotGridField() -- plot the current vector Field. 00090 Image<PixRGB<byte> > plotGridField(int spacing); 00091 00092 //!getVectorAt() -- get the vector at current robot location 00093 geom::vec2f getVectorAt(Point2D<int> location); 00094 00095 //!setVectorAt() -- get the vector at current robot location 00096 void setVectorAt(Point2D<int> location, geom::vec2f val); 00097 00098 //!scaleFieldby -- scale vector field by factor 00099 void scaleFieldBy(float factor); 00100 00101 //!scaleGoalFieldby -- scale Goal vector field by factor 00102 void scaleGoalFieldBy(float factor); 00103 00104 //!make unit length -- set all vectors in vector field to fixed length 00105 void makeUnitLength(); 00106 00107 //!normalizeTo -- normalize to a max factor 00108 void normalizeTo(float maxFactor); 00109 00110 //!rotateField -- rotate the vector field by some angle 00111 void rotateField(float ang); 00112 00113 //!rotateGoalField -- rotate the vector field by some angle 00114 void rotateGoalField(float ang); 00115 00116 00117 protected: 00118 00119 Image<geom::vec2f> itsField; 00120 Image<geom::vec2f> itsGoalField; 00121 std::vector<Point2D<float> > itsSensorData; 00122 Point2D<int> itsRobotPos; 00123 float itsRobotOrientation; 00124 Point2D<float> itsGoal; 00125 00126 Dims itsDims; 00127 }; 00128 00129 00130 00131 00132 00133 00134 00135 #endif 00136 00137 // ###################################################################### 00138 /* So things look consistent in everyone's emacs... */ 00139 /* Local Variables: */ 00140 /* indent-tabs-mode: nil */ 00141 /* End: */