Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NeuroSimEvents.H

Go to the documentation of this file.
00001 /*!@file Neuro/NeuroSimEvents.H SimEvent derivatives for neuro modules */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
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/Neuro/NeuroSimEvents.H $
00035 // $Id: NeuroSimEvents.H 11647 2009-09-03 01:18:22Z itti $
00036 //
00037 
00038 #ifndef NEURO_NEUROSIMEVENTS_H_DEFINED
00039 #define NEURO_NEUROSIMEVENTS_H_DEFINED
00040 
00041 #include "Channels/InputFrame.H"
00042 #include "Neuro/WTAwinner.H"
00043 #include "Neuro/SaccadeBodyPart.H"
00044 #include "Neuro/SaccadeController.H"
00045 #include "Simulation/SimEvent.H"
00046 #include "Simulation/SimReq.H"
00047 #include "Util/TransientStatus.H"
00048 #include "Channels/ChannelVisitor.H"
00049 
00050 class EyeData;
00051 class ParamMap;
00052 class RawVisualCortex;
00053 class IntegerRawVisualCortex;
00054 class EnvVisualCortex2;
00055 class ChannelMaps;
00056 class VisualCortexEyeMvt;
00057 
00058 // ######################################################################
00059 //! The WinnerTakeAll selected a winner
00060 class SimEventWTAwinner : public SimEvent {
00061 public:
00062   //! Constuctor
00063   SimEventWTAwinner(SimModule* src, const WTAwinner w, const uint shiftnum);
00064 
00065   //! Destructor
00066   virtual ~SimEventWTAwinner();
00067 
00068   //! Get a description for printing out
00069   /*! Shows regular SimEvent info, plus winner coordinates. */
00070   virtual std::string toString() const;
00071 
00072   //! Get the winner
00073   const WTAwinner& winner() const;
00074 
00075   //! Get the attention shift number (0-based)
00076   uint shiftNum() const;
00077 
00078 private:
00079   const WTAwinner itsWinner;
00080   const uint itsShiftNum;
00081 };
00082 
00083 // ######################################################################
00084 //! The TargetChecker hit a one or more targets
00085 class SimEventTargetsHit : public SimEvent {
00086 public:
00087   //! Constuctor
00088   SimEventTargetsHit(SimModule* src, const int numhit);
00089 
00090   //! Destructor
00091   virtual ~SimEventTargetsHit();
00092 
00093   //! Get a description for printing out
00094   /*! Shows regular SimEvent info, plus number of targets hit. */
00095   virtual std::string toString() const;
00096 
00097   //! Get the number of targets hit this time
00098   int numHits() const;
00099 
00100 private:
00101   const int itsNumHits;
00102 };
00103 
00104 // ######################################################################
00105 //! A new image is available from the retina
00106 class SimEventRetinaImage : public SimEvent {
00107 public:
00108   //! Constuctor
00109   SimEventRetinaImage(SimModule* src, const InputFrame& ifr,
00110                       const Rectangle& rawinprect,
00111                       const Point2D<int> offset);
00112 
00113   //! Destructor
00114   virtual ~SimEventRetinaImage();
00115 
00116   //! Get a description for printing out
00117   virtual std::string toString() const;
00118 
00119   //! Get the frame
00120   const InputFrame& frame() const;
00121 
00122   //! Get the raw input rectangle
00123   const Rectangle& rawInputRectangle() const;
00124 
00125   //! Translate a raw eye position from stimulus coordinates to retinal
00126   virtual Point2D<int> rawToRetinal(const Point2D<int>& rawpos) const;
00127 
00128   //! Translate a retinal eye position back into raw stimulus coordinates
00129   virtual Point2D<int> retinalToRaw(const Point2D<int>& retpos) const;
00130 
00131   //! Get the coordinates of the center of the image
00132   virtual Point2D<int> center() const;
00133 
00134   //! Get the retinal/raw offset
00135   /*! Use with caution! Prefer using rawToRetinal() and retinalToRaw() instead. */
00136   const Point2D<int>& offset() const;
00137 
00138 private:
00139   const InputFrame      itsFrame;
00140   const Rectangle       itsRawInputRectangle;
00141   const Point2D<int>    itsOffset;
00142 };
00143 
00144 // ######################################################################
00145 //! A new output is available from the VisualCortex
00146 class SimEventVisualCortexOutput : public SimEvent {
00147 public:
00148   //! Constuctor
00149   SimEventVisualCortexOutput(SimModule* src, const Image<float>& vcout);
00150 
00151   //! Destructor
00152   virtual ~SimEventVisualCortexOutput();
00153 
00154   //! Get a description for printing out
00155   virtual std::string toString() const;
00156 
00157   //! Get the VisualCortex output
00158   /*! A factor of 1.0 will return the raw, unnormalized map. A factor
00159     of 0.0F will normalize the map to a range of [0..255]. Any other
00160     factor will be used to multiply the map values. */
00161   const Image<float> vco(const float factor = 1.0F) const;
00162 
00163 private:
00164   const Image<float> itsMap;
00165 };
00166 
00167 // ######################################################################
00168 //! A new output is available from the SaliencyMap
00169 class SimEventSaliencyMapOutput : public SimEvent {
00170 public:
00171   //! Constuctor
00172   SimEventSaliencyMapOutput(SimModule* src, const Image<float>& smout);
00173 
00174   //! Destructor
00175   virtual ~SimEventSaliencyMapOutput();
00176 
00177   //! Get a description for printing out
00178   virtual std::string toString() const;
00179 
00180   //! Get the SaliencyMap output
00181   /*! A factor of 1.0 will return the raw, unnormalized map. A factor
00182     of 0.0F will normalize the map to a range of [0..255]. Any other
00183     factor will be used to multiply the map values. */
00184   const Image<float> sm(const float factor = 1.0F) const;
00185 
00186 private:
00187   const Image<float> itsMap;
00188 };
00189 
00190 // ######################################################################
00191 //! A new output is available from the GistEstimator
00192 class SimEventGistOutput : public SimEvent {
00193 public:
00194   //! Constuctor
00195   SimEventGistOutput(SimModule* src, const Image<float>& gout);
00196 
00197   //! Destructor
00198   virtual ~SimEventGistOutput();
00199 
00200   //! Get a description for printing out
00201   virtual std::string toString() const;
00202 
00203   //! Get the gist feature vector
00204   const Image<float> gv() const;
00205 
00206 private:
00207   const Image<float> itsGistVector;
00208 };
00209 
00210 // ######################################################################
00211 //! A new output is available from the TaskRelevanceMap
00212 class SimEventTaskRelevanceMapOutput : public SimEvent {
00213 public:
00214   //! Constuctor
00215   SimEventTaskRelevanceMapOutput(SimModule* src, const Image<float>& smout);
00216 
00217   //! Destructor
00218   virtual ~SimEventTaskRelevanceMapOutput();
00219 
00220   //! Get a description for printing out
00221   virtual std::string toString() const;
00222 
00223   //! Get the TaskRelevanceMap output
00224   /*! A factor of 1.0 will return the raw, unnormalized map. A factor
00225     of 0.0F will normalize the map to a range of [0..255]. Any other
00226     factor will be used to multiply the map values. */
00227   const Image<float> trm(const float factor = 1.0F) const;
00228 
00229 private:
00230   const Image<float> itsMap;
00231 };
00232 
00233 // ######################################################################
00234 //! A new output is available from the AttentionGuidanceMap
00235 class SimEventAttentionGuidanceMapOutput : public SimEvent {
00236 public:
00237   //! Constuctor
00238   SimEventAttentionGuidanceMapOutput(SimModule* src,
00239                                      const Image<float>& agmout);
00240 
00241   //! Destructor
00242   virtual ~SimEventAttentionGuidanceMapOutput();
00243 
00244   //! Get a description for printing out
00245   virtual std::string toString() const;
00246 
00247   //! Get the AttentionGuidanceMap output
00248   /*! A factor of 1.0 will return the raw, unnormalized map. A factor
00249     of 0.0F will normalize the map to a range of [0..255]. Any other
00250     factor will be used to multiply the map values. */
00251   const Image<float> agm(const float factor = 1.0F) const;
00252 
00253 private:
00254   const Image<float> itsMap;
00255 };
00256 
00257 // ######################################################################
00258 //! A new output is available from the AttentionGate
00259 class SimEventAttentionGateOutput : public SimEvent {
00260 public:
00261   //! Constuctor
00262   SimEventAttentionGateOutput(SimModule* src,
00263                               const Image<float>& agmout,
00264                               const Image<float>& lamout,
00265                               const Image<float>& camout,
00266                               const unsigned int lamframe);
00267 
00268   //! Destructor
00269   virtual ~SimEventAttentionGateOutput();
00270 
00271   //! Get a description for printing out
00272   virtual std::string toString() const;
00273 
00274   //! Attention gate map
00275   const Image<float> ag(const float factor = 1.0F) const;
00276 
00277   //! What finally got through in the last attention map
00278   const Image<float> lam(const float factor = 1.0F) const;
00279 
00280   //! candidate for what will get through in the current attention map
00281   const Image<float> cam(const float factor = 1.0F) const;
00282 
00283   //! What was the frame number on our last attention gate;
00284   const unsigned int lamFrame() const;
00285 private:
00286   const Image<float> itsMap;
00287   const Image<float> itsLastAttMap;
00288   const Image<float> itsCurrAttMap;
00289   const unsigned int itsLastFrame;
00290 };
00291 
00292 // ######################################################################
00293 struct SimEventAttentionGateStageTwoObjects
00294 {
00295   int                              n;
00296   Image<int>                       segments;
00297   Image<float>                     fdistance;
00298   std::vector<int>                 x;
00299   std::vector<int>                 y;
00300   std::vector<int>                 id;
00301   std::vector<float>               val;
00302   std::vector<std::vector<float> > features;
00303 };
00304 
00305 class SimEventAttentionGateStageTwoSegments : public SimEvent {
00306 public:
00307   //! Constuctor
00308   SimEventAttentionGateStageTwoSegments(SimModule* src,
00309                                const Image<bool>& candidates,
00310                                const SimEventAttentionGateStageTwoObjects& obj,
00311                                const int          segnum);
00312 
00313   //! Destructor
00314   ~SimEventAttentionGateStageTwoSegments();
00315 
00316   //! Which attention gate regions are open from stage one
00317   const Image<bool> candidates() const;
00318 
00319   //! What are the attention gate regions
00320   const SimEventAttentionGateStageTwoObjects obj() const;
00321 
00322   //! how many segments were found
00323   const int segnum() const;
00324 
00325 private:
00326   const Image<bool>                          itsCandidates;
00327   const SimEventAttentionGateStageTwoObjects itsObjects;
00328   const int                                  itsSegmentNum;
00329 };
00330 
00331 // ######################################################################
00332 //! A new output is available from the ShapeEstimator
00333 class SimEventShapeEstimatorOutput : public SimEvent {
00334 public:
00335   //! Constuctor
00336   SimEventShapeEstimatorOutput(SimModule* src,
00337                                const Image<float>& winmap,
00338                                const Image<byte>& objmask,
00339                                const Image<byte>& iormask,
00340                                const Image<float>& smoothmask,
00341                                const Image<float>& cumsmoothmask,
00342                                const std::string& winlabel,
00343                                const bool isshaped);
00344 
00345   //! Destructor
00346   virtual ~SimEventShapeEstimatorOutput();
00347 
00348   //! Get a description for printing out
00349   virtual std::string toString() const;
00350 
00351   //! Get the map where the winner was found
00352   const Image<float>& winningMap() const;
00353 
00354   //! Get the object mask
00355   /*! The object mask is a binary mask {0,255} specifiying the extend
00356     of the object (255 inside the object and 0 outside). Its dims are
00357     the dims of the map where the object was segmented (depends on
00358     shape estimator mode used). */
00359   const Image<byte>& objectMask() const;
00360 
00361   //! Get the IOR mask
00362   /*! The IOR mask is a byte map [0,255] - 0 everywhere outside the
00363    object, (winMapNormalized * 255) everywhere inside the object this
00364    is used for IOR in a graded manner - the stronger the winning
00365    property is in a certain position, the stronger this position is
00366    inhibited. */
00367   const Image<byte>& iorMask() const;
00368 
00369   //! Get the smooth mask
00370   /*! The smooth mask is a float map [0.0,1.0] in input image
00371    coordinates created from the object mask by scaling it up and
00372    smoothing out the edges with some specified smoothing method. */
00373   const Image<float>& smoothMask() const;
00374 
00375   //! Get the cumulative smooth mask
00376   /*! The cumulative smooth mask a merger of all smooth masks since
00377     the last reset(). */
00378   Image<float> cumSmoothMask() const;
00379 
00380   //! Get a negative of the cumulative smooth mask
00381   Image<float> negCumSmoothMask() const;
00382 
00383   //! Get description of the feature/conspic/saliency map used for masks
00384   const std::string& winningLabel() const;
00385 
00386   //! Get object area, in original input pixels
00387   uint objectArea() const;
00388 
00389   //! Did the shape extraction succeed?
00390   /*! If this returns true, then the ShapeEstimator was able to find a
00391     shape to extract. Otherwise it fell back to just using a disk at
00392     the attended location. The masks always contain something, just
00393     sometimes that thing may be a disk rather than a nicely segmented
00394     object. */
00395   bool isShaped() const;
00396 
00397 private:
00398   const Image<float> itsWinningMap;
00399   const Image<byte> itsObjMask;
00400   const Image<byte> itsIORmask;
00401   const Image<float> itsSmoothMask;
00402   const Image<float> itsCumSmoothMask;
00403   const std::string itsWinLabel;
00404   const bool itsIsShaped;
00405 };
00406 
00407 // ######################################################################
00408 //! A SaccadeController may post this at every evolve
00409 /*! Note how you cannot implement an object of this type, since it
00410   contains a pure virtual function. Use SimEventSaccadeStatusEye or
00411   SimEventSaccadeStatusHead instead. */
00412 class SimEventSaccadeStatus : public SimEvent {
00413 public:
00414   //! Constuctor
00415   SimEventSaccadeStatus(SimModule* src, const Point2D<int>& pos,
00416                         const SaccadeState state,
00417                         const SaccadeState prevState,
00418                         const bool blinkState,
00419                         const bool prevBlinkState);
00420 
00421   //! Destructor
00422   virtual ~SimEventSaccadeStatus();
00423 
00424   //! Get a description for printing out
00425   virtual std::string toString() const;
00426 
00427   //! Get the position
00428   const Point2D<int>& position() const;
00429 
00430   //! Are we in/out/beginning/ending unknown/junk mode?
00431   TransientStatus unknownStatus() const;
00432 
00433   //! Are we in/out/beginning/ending fixation?
00434   TransientStatus fixationStatus() const;
00435 
00436   //! Are we in/out/beginning/ending saccade?
00437   TransientStatus saccadeStatus() const;
00438 
00439   //! Are we in/out/beginning/ending blink?
00440   TransientStatus blinkStatus() const;
00441 
00442   //! Are we in/out/beginning/ending smooth pursuit?
00443   TransientStatus smoothPursuitStatus() const;
00444 
00445   //! Get the body part, used by toString()
00446   virtual SaccadeBodyPart bodyPart() const = 0;
00447 
00448 private:
00449   const Point2D<int> itsPosition;
00450   const SaccadeState itsState;
00451   const SaccadeState itsPrevState;
00452   const bool itsBlinkState;
00453   const bool itsPrevBlinkState;
00454 };
00455 
00456 // ######################################################################
00457 //! An Eye SaccadeController may post this at every evolve
00458 class SimEventSaccadeStatusEye : public SimEventSaccadeStatus {
00459 public:
00460   //! Constuctor
00461   SimEventSaccadeStatusEye(SimModule* src, const Point2D<int>& pos,
00462                            const SaccadeState state,
00463                            const SaccadeState prevState,
00464                            const bool blinkState,
00465                            const bool prevBlinkState);
00466 
00467   //! Destructor
00468   virtual ~SimEventSaccadeStatusEye();
00469 
00470   //! Get the body part
00471   SaccadeBodyPart bodyPart() const;
00472 };
00473 
00474 // ######################################################################
00475 //! An Head SaccadeController may post this at every evolve
00476 class SimEventSaccadeStatusHead : public SimEventSaccadeStatus {
00477 public:
00478   //! Constuctor
00479   SimEventSaccadeStatusHead(SimModule* src, const Point2D<int>& pos,
00480                             const SaccadeState state,
00481                             const SaccadeState prevState,
00482                             const bool blinkState,
00483                             const bool prevBlinkState);
00484 
00485   //! Destructor
00486   virtual ~SimEventSaccadeStatusHead();
00487 
00488   //! Get the body part
00489   SaccadeBodyPart bodyPart() const;
00490 };
00491 
00492 // ######################################################################
00493 //! An EyeTrackerSaccadeController may post this
00494 class SimEventEyeTrackerData : public SimEvent {
00495 public:
00496   //! Constuctor
00497   SimEventEyeTrackerData(SimModule* src, rutz::shared_ptr<EyeData> d,
00498                          const uint trackernum,
00499                          const std::string& trackerfname,
00500                          const PixRGB<byte>& trackercolor);
00501 
00502   //! Destructor
00503   virtual ~SimEventEyeTrackerData();
00504 
00505   //! Get the eye data
00506   rutz::shared_ptr<EyeData> data() const;
00507 
00508   //! Get the tracker number
00509   uint trackerNum() const;
00510 
00511   //! Get the tracker filename
00512   std::string trackerFilename() const;
00513 
00514   //! Get the tracker color
00515   PixRGB<byte> trackerColor() const;
00516 
00517 private:
00518   rutz::shared_ptr<EyeData> itsData;
00519   const uint itsTrackerNum;
00520   const std::string itsTrackerFname;
00521   const PixRGB<byte> itsTrackerColor;
00522 };
00523 
00524 // ######################################################################
00525 //! A virtual or real robot may post this
00526 /*! this stores information about my coordinates and such for use
00527     in a real or virtual scene that a robot could move around in
00528 */
00529 class SimEventMyCoordinates : public SimEvent {
00530 public:
00531   //! Constuctor
00532   SimEventMyCoordinates(SimModule* src,       const int UTM,
00533                         const double heading, const double pitch,
00534                         const double range,
00535                         const std::vector<std::vector<int> >& local,
00536                         const std::vector<double>& gaze,
00537                         const std::vector<std::vector<double> >& eye);
00538 
00539   //! Destructor
00540   virtual ~SimEventMyCoordinates();
00541 
00542   //! UTM zone, sign designates North/South.
00543   int getSignedUTMzone() const;
00544 
00545   //! My Heading in degrees
00546   double getHeading() const;
00547 
00548   //! My Pitch in degrees
00549   double getPitch() const;
00550 
00551   //! Range in cm
00552   double getRange() const;
00553 
00554   //! Local origin coordinates in cm relative to UTM {0,0,0}.
00555   /*! {local[3],coord_min[3],coord_max[3]}  each in X,Y,Z format
00556    */
00557   const std::vector<std::vector<int> > getLocalCoords() const;
00558 
00559   //! Quaternion XYZ center of gaze from LabelSceneGraph
00560   const std::vector<double> getCenterOfGaze() const;
00561 
00562   //! Simulation Eye (Camera) Position (eye,center,up)
00563   /*!{eye[3],center[3],up[3]} fetched from osg::Matrix _viewingmat
00564      Each in 3D format. Tells me where my eye is and where I'm looking
00565      at in world coords from OSG. Get to the position and orientation
00566      of a modelview matrix, using the same convention as gluLookAt.
00567      Here we convert to a standard data type so we can use it with
00568      other classes.
00569   */
00570   const std::vector<std::vector<double> > getEye() const;
00571 
00572 private:
00573   //! UTM zone, sign designates North/South.
00574   const int itsSignedUTMzone;
00575   //! My Heading in degrees
00576   const double itsHeading;
00577   //! My Pitch in degrees
00578   const double itsPitch;
00579   //! Range in cm
00580   const double itsRange;
00581   //! Local origin coordinates in cm relative to UTM {0,0,0}.
00582   /*! {local[3],coord_min[3],coord_max[3]}  each in X,Y,Z format.
00583       An array of size [3][3].
00584    */
00585   const std::vector<std::vector<int> > itsLocalCoords;
00586   //! Quaternion XYZ center of gaze.
00587   /*! An array of size [3]. */
00588   const std::vector<double> itsCenterOfGaze;
00589   //! Simulation Eye (Camera) Position (eye,center,up).
00590   /*!{eye[3],center[3],up[3]} fetched from osg::Matrix _viewingmat
00591      Each in X,Y,Z format. Tells me where my eye is and where I'm looking
00592      at in world coords from OSG.
00593      An array of size [3][3].
00594   */
00595   const std::vector<std::vector<double> > itsEye;
00596 };
00597 
00598 // ######################################################################
00599 //! A map from each x,y in the retina to a real world coordinate R=X, G=Y, B=Z
00600 class SimEventRetinaCoordMap : public SimEvent {
00601 public:
00602   SimEventRetinaCoordMap(SimModule* src, const Image<PixRGB<float> > loc);
00603 
00604   virtual ~SimEventRetinaCoordMap();
00605 
00606   Image<PixRGB<float> > getItsLocationMap() const;
00607 private:
00608   //! The current location map we are working from.
00609   const Image<PixRGB<float> > itsLocationMap;
00610 };
00611 
00612 // ######################################################################
00613 //! A map from saliency to real world coordinates with values
00614 /*! PixHyper contains the x,y and z world coordinates that each
00615     salient value coresponds to. The 4th value is the actuall saliency
00616     value from the saliency image used to generate this map. Use the
00617     direct pixel access "p" to get the values. See RetinaToWorld.C/H
00618     to see how to generate or access this data. */
00619 class SimEventSaliencyCoordMap : public SimEvent {
00620 public:
00621   SimEventSaliencyCoordMap(SimModule* src,
00622                            const Image<PixHyper<float,4> > loc,
00623                            const std::vector<int> msc,
00624                            const float val);
00625 
00626   virtual ~SimEventSaliencyCoordMap();
00627   //! Get the hyper map which is {x,y,z,val}
00628   /*! This is a merger between the RetinaCoord location map from the
00629     retina and the saliency map. Each pixel coresponds to a location
00630     in space with its saliency value. These are set for example like this:
00631 
00632     for each pixel in an iterator, if this is cmap:
00633 
00634        cmap->p[0] = loc->p[0];  // X
00635        cmap->p[1] = loc->p[1];  // Y
00636        cmap->p[2] = loc->p[2];  // Z
00637        cmap->p[3] = *saliency;  // Saliency Value  */
00638   Image<PixHyper<float,4> > getItsLocationMap() const;
00639 
00640   //! Return the coordinate and value of maximum saliency [X,Y,Z,U,V]
00641   /*! Here, U (width) and V (height) are the screen projection coords
00642       while X,Y and Z are the real world coords.
00643   */
00644   std::vector<int> getMaxSalCurrent() const;
00645 
00646   //! return the maximum saliency value associated with getMaxSalCurrent
00647   float getMaxSalValue() const;
00648 
00649 private:
00650   //! The current location map we are working from.
00651   const Image<PixHyper<float,4> > itsLocationMap;
00652   //! The current point of maximum saliency [X,Y,Z,U,V]
00653   /*! Here, U (width) and V (height) are the screen coords while X,Y and Z are
00654       the real world coords.
00655   */
00656   const std::vector<int> itsMaxSalCurrent;
00657   //! maximum saliency value associated with getMaxSalCurrent
00658   const float itsMaxSalValue;
00659 };
00660 
00661 // ######################################################################
00662 //! Trigger a ChannelVisitor on VisualCortex
00663 /*! This request is checked for and caught by VisualCortex. Upon
00664     receipt, VisualCortex will first call preProcessing(), the accept
00665     the visitor, and finally call postProcessing(). */
00666 class SimReqVCXchanVis : public SimReq {
00667 public:
00668   //! Construct from a pre-loaded ParamMap
00669   SimReqVCXchanVis(SimModule* src, rutz::shared_ptr<ChannelVisitor> vis);
00670 
00671   //! Destructor
00672   virtual ~SimReqVCXchanVis();
00673 
00674   //! Run some pre-processing before we accept()
00675   /*! On the base class, this is a no-op. */
00676   virtual void preProcessing(RawVisualCortex *vcx);
00677 
00678   //! Get our visitor
00679   rutz::shared_ptr<ChannelVisitor> visitor() const;
00680 
00681   //! Run some post-processing after we accept()
00682   /*! On the base class, this is a no-op. */
00683   virtual void postProcessing(RawVisualCortex *vcx);
00684 
00685 private:
00686   rutz::shared_ptr<ChannelVisitor> itsVisitor;
00687 };
00688 
00689 // ######################################################################
00690 //! Indicate which object we are biasing for (use for statistics)
00691 class SimEventObjectToBias : public SimEvent {
00692 public:
00693   SimEventObjectToBias(SimModule* src, const std::string& objName);
00694 
00695   virtual ~SimEventObjectToBias();
00696 
00697   const std::string& name() const;
00698 
00699 private:
00700   const std::string itsObjName;
00701 };
00702 
00703 // ######################################################################
00704 //! A new target mask is available, TargetChecker will check for this and use the new mask
00705 class SimEventTargetMask : public SimEvent {
00706 public:
00707   //! Constuctor
00708   SimEventTargetMask(SimModule* src, const Image<byte>& tmask);
00709 
00710   //! Destructor
00711   virtual ~SimEventTargetMask();
00712 
00713   //! Get a description for printing out
00714   virtual std::string toString() const;
00715 
00716   //! Get the target mask
00717   const Image<byte> mask() const;
00718 
00719 private:
00720   const Image<byte> itsMask;
00721 };
00722 
00723 // ######################################################################
00724 //! Request VCX features at a given location
00725 /*! PROGRAMMER NOTE: This is an example of a read/write SimReq,
00726     whereby the VCX directly dumps its features into the request and
00727     posts nothing in return. The object that did a request() of this
00728     event can then directly use the results in the event as soon as
00729     request() returns. If features() is empty after the event has been
00730     requested, then it means that no VisualCortex caught it and there are
00731     no features available. */
00732 class SimReqVCXfeatures : public SimReq {
00733 public:
00734   //! Constuctor
00735   SimReqVCXfeatures(SimModule* src, const Point2D<int>& p);
00736 
00737   //! Destructor
00738   virtual ~SimReqVCXfeatures();
00739 
00740   //! Get a description for printing out
00741   virtual std::string toString() const;
00742 
00743   //! Get access to the location of the features
00744   const Point2D<int>& loc() const;
00745 
00746   //! Get read/write access to the features
00747   std::vector<float>& features();
00748 
00749 private:
00750   const Point2D<int> itsLoc;
00751   std::vector<float> itsFeatures;
00752 };
00753 
00754 // ######################################################################
00755 //! Request VCX internal maps
00756 /*! PROGRAMMER NOTE: This is an example of a read/write SimReq,
00757     whereby the VCX directly dumps its features into the request and
00758     posts nothing in return. The object that did a request() of this
00759     event can then directly use the results in the event as soon as
00760     request() returns. While this object is quite benign as long as
00761     everything runs on a same machine, beware that it is potentially
00762     quite costly to transport from one machine to another via
00763     network. */
00764 class SimReqVCXmaps : public SimReq {
00765 public:
00766   //! Constuctor
00767   SimReqVCXmaps(SimModule* src);
00768 
00769   //! Destructor
00770   virtual ~SimReqVCXmaps();
00771 
00772   //! Get the ChannelMaps object that will contain all the VCX maps
00773   rutz::shared_ptr<ChannelMaps> channelmaps() const;
00774 
00775 private:
00776   rutz::shared_ptr<ChannelMaps> itsChannelMaps;
00777 
00778   friend class VisualCortexStd;
00779   friend class VisualCortexInt;
00780   friend class VisualCortexEnv;
00781   friend class VisualCortexEyeMvt;
00782   void populateChannelMaps(RawVisualCortex *vcx);
00783   void populateChannelMaps(IntegerRawVisualCortex *vcx);
00784   void populateChannelMaps(EnvVisualCortex2 *vcx);
00785   void populateChannelMaps(VisualCortexEyeMvt *vcx);
00786 };
00787 
00788 // ######################################################################
00789 //! A new output is available from the VisualBuffer
00790 class SimEventVisualBufferOutput : public SimEvent {
00791 public:
00792   //! Constuctor
00793   SimEventVisualBufferOutput(SimModule* src, const Image<float>& buf,
00794                              const int smlev, const Dims& smdims, const Point2D<int>& retoff);
00795 
00796   //! Destructor
00797   virtual ~SimEventVisualBufferOutput();
00798 
00799   //! Get a description for printing out
00800   virtual std::string toString() const;
00801 
00802   //! Get the buffer
00803   const Image<float>& buffer() const;
00804 
00805   //! transform coord from retinotopic/retinal-scale to world-centered/sm-scale
00806   Point2D<int> retinalToBuffer(const Point2D<int>& p) const;
00807 
00808   //! transform coord from world-centered/sm-scale to retinotopic/retinal-scale
00809   Point2D<int> bufferToRetinal(const Point2D<int>& p) const;
00810 
00811   //! SM dims
00812   const Dims& smdims() const;
00813 
00814   //! SM level
00815   int smlev() const;
00816 
00817 private:
00818   const Image<float> itsVisualBuffer;
00819   const int itsSMlev;
00820   const Dims itsSMdims;
00821   const Point2D<int> itsRetinaOffset;
00822 };
00823 
00824 // ######################################################################
00825 /* So things look consistent in everyone's emacs... */
00826 /* Local Variables: */
00827 /* mode: c++ */
00828 /* indent-tabs-mode: nil */
00829 /* End: */
00830 
00831 #endif // NEURO_NEUROSIMEVENTS_H_DEFINED

Generated on Mon Nov 23 15:46:35 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4