ForwardVision.C

Go to the documentation of this file.
00001 /*!@file SeaBee/ForwardVision.C Forward Vision Agent         */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Michael Montalbo <montalbo@usc.edu>
00033 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/SeaBee/ForwardVision.C $
00034 // $Id: ForwardVision.C 10794 2009-02-08 06:21:09Z itti $
00035 //
00036 //////////////////////////////////////////////////////////////////////////
00037 
00038 #include "ForwardVision.H"
00039 
00040 // ######################################################################
00041 ForwardVisionAgent::ForwardVisionAgent(
00042                                        //    rutz::shared_ptr<AgentManager> ama,
00043                 nub::soft_ref<EnvVisualCortex> evc,
00044                 const std::string& name) :
00045         itsEVC(evc)
00046 {
00047   itsDebugImage = Image<PixRGB<byte> >(320,240,ZEROS);
00048   itsFrameNumber = 0;
00049 }
00050 
00051 // ######################################################################
00052 //Scheduler
00053 bool ForwardVisionAgent::pickAndExecuteAnAction()
00054 {
00055   //
00056   //if(itsCurrentMission->missionName != Mission::NONE)
00057   //  {
00058   //    rutz::shared_ptr<Image<PixRGB<byte> > >
00059   //      currImg( new Image<PixRGB<byte> >(itsAgentManager->getCurrentForwardImage()));
00060   //
00061   //    if(currImg->initialized())
00062   //      {
00063   //        lookForSaliency(currImg);
00064   //      }
00065   //    else
00066   //      {
00067   //        usleep(10000);
00068   //      }
00069   //
00070   //  }
00071   return true;
00072 
00073 }
00074 
00075 // ######################################################################
00076 //Actions
00077 Point2D<int> ForwardVisionAgent::lookForBuoy(const Image<PixRGB<byte> >& img)
00078 {
00079   LINFO("Look for buoy");
00080 
00081   itsDebugImage = img;
00082   int smap_level = itsEVC->getMapLevel();
00083 
00084   //look for the most salient point and go toward it
00085   itsEVC->input(img);
00086   Image<float> vcxmap = itsEVC->getVCXmap();
00087 
00088   Point2D<int> maxPos(-1,-1); float maxVal = -1;
00089   findMax(vcxmap, maxPos, maxVal);
00090 
00091   Point2D<int> buoyLoc (maxPos.i<<smap_level,
00092                         maxPos.j<<smap_level);
00093   if (img.getVal(buoyLoc).red > img.getVal(buoyLoc).green && img.getVal(buoyLoc).red > img.getVal(buoyLoc).blue)
00094     {
00095       if(buoyLoc.isValid())
00096         {
00097           drawCircle(itsDebugImage,
00098                      buoyLoc,
00099                      10, PixRGB<byte>(255,0,0));
00100         }
00101 
00102     }
00103 
00104   LINFO("%d %d",buoyLoc.i,buoyLoc.j);
00105   return buoyLoc;
00106 
00107 }
00108 
00109 void ForwardVisionAgent::lookForSaliency(rutz::shared_ptr<Image<PixRGB<byte> > > img)
00110 {
00111 //   LINFO("Looking for salient features...");
00112 
00113 //   rutz::shared_ptr<SensorResult> saliency(new SensorResult(SensorResult::SALIENCY));
00114 //   saliency->setStatus(SensorResult::NOT_FOUND);
00115 
00116 //   int smap_level = itsEVC->getMapLevel();
00117 
00118 //   //look for the most salient point and go toward it
00119 //   itsEVC->input(*img);
00120 //   Image<float> vcxmap = itsEVC->getVCXmap();
00121 
00122 //   Point2D<int> maxPos(-1,-1); float maxVal = -1;
00123 //   findMax(vcxmap, maxPos, maxVal);
00124 
00125 //   if (maxVal > 150)
00126 //     {
00127 //       drawCircle(*img,
00128 //                  Point2D<int>(maxPos.i<<smap_level,
00129 //                               maxPos.j<<smap_level),
00130 //                  10, PixRGB<byte>(255,0,0));
00131 //       saliency->setStatus(SensorResult::FOUND);
00132 
00133 //       itsAgentManager->updateSensorResult(saliency);
00134 //     }
00135 
00136 //   itsAgentManager->drawForwardImage(img);
00137 }
00138 
00139 // ######################################################################
00140 /* So things look consistent in everyone's emacs... */
00141 /* Local Variables: */
00142 /* indent-tabs-mode: nil */
00143 /* End: */
00144 
Generated on Sun May 8 08:40:16 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3