00001 /** 00002 \file Robots/LoBot/ui/LoLocustViz.H 00003 \brief Locust LGMD spike rate visualizer. 00004 00005 This file defines a class that implements a drawable for visualizing 00006 the LGMD spike rates of all the (virtual) locusts. The visualization 00007 resembles that of the laser range finder. 00008 */ 00009 00010 // //////////////////////////////////////////////////////////////////// // 00011 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00012 // by the University of Southern California (USC) and the iLab at USC. // 00013 // See http://iLab.usc.edu for information about this project. // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00016 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00017 // in Visual Environments, and Applications'' by Christof Koch and // 00018 // Laurent Itti, California Institute of Technology, 2001 (patent // 00019 // pending; application number 09/912,225 filed July 23, 2001; see // 00020 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00021 // //////////////////////////////////////////////////////////////////// // 00022 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00023 // // 00024 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00025 // redistribute it and/or modify it under the terms of the GNU General // 00026 // Public License as published by the Free Software Foundation; either // 00027 // version 2 of the License, or (at your option) any later version. // 00028 // // 00029 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00030 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00031 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00032 // PURPOSE. See the GNU General Public License for more details. // 00033 // // 00034 // You should have received a copy of the GNU General Public License // 00035 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00036 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00037 // Boston, MA 02111-1307 USA. // 00038 // //////////////////////////////////////////////////////////////////// // 00039 // 00040 // Primary maintainer for this file: mviswana usc edu 00041 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/ui/LoLocustViz.H $ 00042 // $Id: LoLocustViz.H 13811 2010-08-21 02:00:08Z mviswana $ 00043 // 00044 00045 #ifndef LOBOT_LOCUST_LGMD_VISUALIZER_DOT_H 00046 #define LOBOT_LOCUST_LGMD_VISUALIZER_DOT_H 00047 00048 //------------------------------ HEADERS -------------------------------- 00049 00050 // lobot headers 00051 #include "Robots/LoBot/ui/LoDrawable.H" 00052 #include "Robots/LoBot/misc/LoVector.H" 00053 00054 // Standard C++ headers 00055 #include <vector> 00056 00057 //----------------------------- NAMESPACE ------------------------------- 00058 00059 namespace lobot { 00060 00061 //------------------------- CLASS DEFINITION ---------------------------- 00062 00063 // Forward declarations 00064 class LocustModel ; 00065 00066 /** 00067 \class lobot::LocustViz 00068 \brief A drawable for visualizing the LGMD spike rates. 00069 00070 This class uses OpenGL to visualize the spike rates of all the 00071 locusts. The visualization resembles that of a range sensor such as 00072 the laser range finder. Each locust's spike rate is drawn as a ray 00073 starting at the visualizer's center. This ray's direction corresponds 00074 to the direction in which its associated locust is looking. The 00075 magnitude of the ray represents the amount of spiking activity 00076 associated with that locust. A set of concentric rings is used to help 00077 the user gauge the numerical value associated with the spike rate 00078 rays. 00079 */ 00080 class LocustViz : public Drawable { 00081 // Prevent copy and assignment 00082 LocustViz(const LocustViz&) ; 00083 LocustViz& operator=(const LocustViz&) ; 00084 00085 /// Since this class visualizes the spike rates of all the locusts, it 00086 /// will need to store references to these locusts so that it can 00087 /// retrieve the spike rates when it comes time to perform rendering. 00088 const std::vector<LocustModel*>& m_locusts ; 00089 00090 /// The locust model stores the direction in which a locust looks in 00091 /// polar form. For the rendering, we need to convert this to a 00092 /// Cartesian vector. Since a locust's direction remains fixed once 00093 /// its model interface object is created, we don't have to keep 00094 /// performing the same polar-to-Cartesian conversions over and over. 00095 /// Instead, we compute the unit vectors associated with each locust's 00096 /// radial direction on initialization and simply scale those vectors 00097 /// by the current spike rates to obtain the vectors for 00098 /// visualization. 00099 /// 00100 /// This data member stores the precomputed unit vectors for each of 00101 /// the locusts. 00102 std::vector<Vector> m_directions ; 00103 00104 /// To properly setup the coordinate system for the visualization, we 00105 /// need to know the maximum spike rate. This parameter will be 00106 /// obtained from the locust model during initialization. 00107 float m_spike_max ; 00108 00109 /// Once we know the maximum spike rate, we have all the information 00110 /// we need to draw the concentric rings mentioned above. Thus, we 00111 /// store the necessary rendering commands in an OpenGL display list. 00112 unsigned int m_display_list ; 00113 00114 public: 00115 /// Initialization: precompute the direction vectors for each of the 00116 /// locusts and set the max spike rate. 00117 LocustViz(const std::vector<LocustModel*>&) ; 00118 00119 private: 00120 /// OpenGL related initialization: create the display list for drawing 00121 /// the concentric rings. 00122 void gl_init() ; 00123 00124 /// This method renders the latest spike rates obtained from all the 00125 /// locusts. The visualization resembles that of the laser range 00126 /// finder in "ray" mode. 00127 void render_me() ; 00128 00129 /// OpenGL related clean-up: delete the display list used to render 00130 /// the concentric rings. 00131 void gl_cleanup() ; 00132 00133 public: 00134 /// Clean-up. 00135 ~LocustViz() ; 00136 } ; 00137 00138 //----------------------------------------------------------------------- 00139 00140 } // end of namespace encapsulating this file's definitions 00141 00142 #endif 00143 00144 /* So things look consistent in everyone's emacs... */ 00145 /* Local Variables: */ 00146 /* indent-tabs-mode: nil */ 00147 /* End: */