ForwardVision.C

Go to the documentation of this file.
00001 /*!@file BeoSub/BeeBrain/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/BeoSub/BeeBrain/ForwardVision.C $
00034 // $Id: ForwardVision.C 9412 2008-03-10 23:10:15Z farhan $
00035 //
00036 //////////////////////////////////////////////////////////////////////////
00037 
00038 #include "BeoSub/BeeBrain/ForwardVision.H"
00039 
00040 // ######################################################################
00041 ForwardVisionAgent::ForwardVisionAgent(std::string name) : SensorAgent(name)
00042 {
00043 //   pipeRecognizer = BeoSubPipe();
00044 //   crossRecognizer = BeoSubPipe();
00045 //   binRecognizer = BeoSubPipe();
00046 
00047 }
00048 
00049 // ######################################################################
00050 //Scheduler
00051 bool ForwardVisionAgent::pickAndExecuteAnAction()
00052 {
00053   bool lookedForObject = false;
00054 
00055   if(!itsJobs.empty())
00056     {
00057       //first clean out any jobs which are to be ignored
00058       cleanJobs();
00059 
00060       for(itsJobsItr = itsJobs.begin(); itsJobsItr != itsJobs.end(); ++itsJobsItr)
00061         {
00062           rutz::shared_ptr<OceanObject> currentOceanObject = (*itsJobsItr)->oceanObject;
00063           Job* currentJob = *itsJobsItr;
00064 
00065           //find it based on its type
00066           if(currentOceanObject->getType()  == OceanObject::PIPE)
00067             {
00068               lookForPipe(currentJob);
00069             }
00070           else if(currentOceanObject->getType() == OceanObject::CROSS)
00071             {
00072               lookForCross(currentJob);
00073             }
00074           else if(currentOceanObject->getType() == OceanObject::BIN)
00075             {
00076               lookForBin(currentJob);
00077             }
00078           else if(currentOceanObject->getType() == OceanObject::BUOY)
00079             {
00080               lookForBuoy(currentJob);
00081             }
00082 
00083           lookedForObject = true;
00084         }
00085 
00086       return lookedForObject;
00087     }
00088   else
00089     {
00090       return false;
00091     }
00092 
00093 }
00094 
00095 // ######################################################################
00096 //Actions
00097 void ForwardVisionAgent::lookForPipe(Job* j)
00098 {
00099   if(j->status == NOT_STARTED) { j->status = IN_PROGRESS; }
00100 
00101   DataTypes jobDataType = j->dataType;
00102   rutz::shared_ptr<OceanObject> jobOceanObject = j->oceanObject;
00103 
00104   bool isFound = false;
00105 
00106 //   std::vector<LineSegment2D> lines = getHoughLines(cameraImage, outputImage);
00107 
00108   if(jobDataType == POSITION)
00109     {
00110       Do("Looking for pipe blob center");
00111 //       uint stalePointCount = 0;
00112 //       Point2D<int> projPoint = pipeRecognizer->getPipeProjPoint(lines, stalePointCount);
00113 //       if(projPoint.isValid() && stalePointCount < 10)
00114 //         {
00115           isFound = true;
00116 //           jobOceanObject->setPosition(Point3D(projPoint.i, projPoint.j, -1));
00117 //         }
00118     }
00119 
00120   oceanObjectUpdate(jobOceanObject, isFound);
00121 }
00122 
00123 // ######################################################################
00124 void ForwardVisionAgent::lookForBin(Job* j)
00125 {
00126   if(j->status == NOT_STARTED) { j->status = IN_PROGRESS; }
00127 
00128   DataTypes jobDataType = j->dataType;
00129   rutz::shared_ptr<OceanObject> jobOceanObject = j->oceanObject;
00130 
00131   bool isFound = false;
00132 
00133 //   std::vector<LineSegment2D> lines = getHoughLines(cameraImage, outputImage);
00134 
00135   if(jobDataType == POSITION)
00136     {
00137       Do("Looking for bin center");
00138 //       Point2D<int> binCenter = binRecognizer->getBinCenter(lines);
00139 //       if(pipeCenter.isValid())
00140 //         {
00141           isFound = true;
00142 //           jobOceanObject->setPosition(Point3D(binCenter.i, binCenter.j, -1));
00143 //         }
00144     }
00145 
00146   oceanObjectUpdate(jobOceanObject, isFound);
00147 
00148 }
00149 
00150 // ######################################################################
00151 void ForwardVisionAgent::lookForCross(Job* j)
00152 {
00153   j->status = IN_PROGRESS;
00154   DataTypes jobDataType = j->dataType;
00155   rutz::shared_ptr<OceanObject> jobOceanObject = j->oceanObject;
00156 
00157   bool isFound = false;
00158 
00159 //   std::vector<LineSegment2D> lines = getHoughLines(cameraImage, outputImage);
00160 
00161   if(jobDataType == POSITION)
00162     {
00163       Do("Looking for cross blob center");
00164  //      uint stalePointCount = 0;
00165 //       Point2D<int> crossCenter = crossRecognizer->getCrossCenter(lines,stalePointCount);
00166 //       if(pipeCenter.isValid() && stalePointCount < 10)
00167 //         {
00168           isFound = true;
00169 //           jobOceanObject->setPosition(Point3D(projPoint.i, projPoint.j, -1));
00170 //         }
00171     }
00172 
00173   oceanObjectUpdate(jobOceanObject, isFound);
00174 }
00175 
00176 // ######################################################################
00177 void ForwardVisionAgent::lookForBuoy(Job* j)
00178 {
00179   j->status = IN_PROGRESS;
00180   DataTypes jobDataType = j->dataType;
00181   rutz::shared_ptr<OceanObject> jobOceanObject = j->oceanObject;
00182 
00183   bool isFound = false;
00184 
00185 //   std::vector<LineSegment2D> lines = getHoughLines(cameraImage, outputImage);
00186 
00187   if(jobDataType == POSITION)
00188     {
00189       Do("Looking for buoy center");
00190  //      uint stalePointCount = 0;
00191 //       Point2D<int> crossCenter = crossRecognizer->getCrossCenter(lines,stalePointCount);
00192 //       if(pipeCenter.isValid() && stalePointCount < 10)
00193 //         {
00194           isFound = true;
00195 //           jobOceanObject->setPosition(Point3D(projPoint.i, projPoint.j, -1));
00196 //         }
00197     }
00198   else if(jobDataType == MASS)
00199     {
00200       Do("Looking for buoy mass");
00201 //       float crossMass = pipeRecognizer->getCrossMass();
00202 //       if(crossMass >= 0)
00203 //         {
00204           isFound = true;
00205 //           jobOceanObject->setMass(crossMass);
00206 //         }
00207     }
00208   else if(jobDataType == FREQUENCY)
00209     {
00210       Do("Looking for buoy frequency");
00211 //       float crossMass = pipeRecognizer->getCrossMass();
00212 //       if(crossMass >= 0)
00213 //         {
00214           isFound = true;
00215 //           jobOceanObject->setMass(crossMass);
00216 //         }
00217     }
00218 
00219   oceanObjectUpdate(jobOceanObject, isFound);
00220 }
00221 
00222 // ######################################################################
00223 void ForwardVisionAgent::oceanObjectUpdate( rutz::shared_ptr<OceanObject> o, bool isFound)
00224 {
00225   if(isFound)
00226     {
00227       if(o->getStatus() == OceanObject::NOT_FOUND)
00228         {
00229           o->setStatus(OceanObject::FOUND);
00230 //           cortex->msgObjectUpdate();
00231         }
00232     }
00233   else
00234     {
00235       if(o->getStatus() == OceanObject::FOUND)
00236         {
00237           o->setStatus(OceanObject::LOST);
00238 //           cortex->msgObjectUpdate();
00239         }
00240     }
00241 }
00242 
00243 // ######################################################################
00244 /* So things look consistent in everyone's emacs... */
00245 /* Local Variables: */
00246 /* indent-tabs-mode: nil */
00247 /* End: */
00248 
Generated on Sun May 8 08:40:16 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3