EGMM.C

Go to the documentation of this file.
00001 /*!@file SceneUnderstanding/EGMM.C features based on edges of mixture of Gaussian  */
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: Lior Elazary <elazary@usc.edu>
00034 // $HeadURL: $
00035 // $Id: $
00036 //
00037 
00038 #ifndef EGMM_C_DEFINED
00039 #define EGMM_C_DEFINED
00040 
00041 #include "Component/ModelManager.H"
00042 #include "Image/DrawOps.H"
00043 #include "Image/MathOps.H"
00044 //#include "Image/OpenCVUtil.H"
00045 #include "Image/Layout.H"
00046 #include "plugins/SceneUnderstanding/EGMM.H"
00047 #include "Simulation/SimEventQueue.H"
00048 #include "Simulation/SimEvents.H"
00049 #include "Media/MediaSimEvents.H"
00050 #include "Channels/InputFrame.H"
00051 #include "Image/Kernels.H"
00052 #include "Image/FilterOps.H"
00053 #include "Image/Convolutions.H"
00054 #include "GUI/DebugWin.H"
00055 #include <math.h>
00056 #include <fcntl.h>
00057 #include <limits>
00058 #include <string>
00059 
00060 const ModelOptionCateg MOC_EGMM = {
00061   MOC_SORTPRI_3,   "EGMM-Related Options" };
00062 
00063 // Used by: SimulationViewerEyeMvt
00064 const ModelOptionDef OPT_EGMMShowDebug =
00065   { MODOPT_ARG(bool), "EGMMShowDebug", &MOC_EGMM, OPTEXP_CORE,
00066     "Show debug img",
00067     "egmm-debug", '\0', "<true|false>", "false" };
00068 
00069 
00070 // ######################################################################
00071 EGMM::EGMM(OptionManager& mgr, const std::string& descrName,
00072     const std::string& tagName) :
00073   SimModule(mgr, descrName, tagName),
00074   SIMCALLBACK_INIT(SimEventInputFrame),
00075   SIMCALLBACK_INIT(SimEventSaveOutput),
00076   itsShowDebug(&OPT_EGMMShowDebug, this)
00077 
00078 {
00079 }
00080 
00081 // ######################################################################
00082 EGMM::~EGMM()
00083 {
00084         LINFO("Destory Module");
00085 
00086 }
00087 
00088 // ######################################################################
00089 void EGMM::onSimEventInputFrame(SimEventQueue& q,
00090                                   rutz::shared_ptr<SimEventInputFrame>& e)
00091 {
00092   // here is the inputs image:
00093   const Image<PixRGB<byte> > inimg = e->frame().asRgb();
00094 
00095   itsCurrentImg = inimg;
00096 
00097 
00098   evolve();
00099 
00100 }
00101 
00102 // ######################################################################
00103 void EGMM::onSimEventSaveOutput(SimEventQueue& q, rutz::shared_ptr<SimEventSaveOutput>& e)
00104 {
00105   if (itsShowDebug.getVal())
00106     {
00107       // get the OFS to save to, assuming sinfo is of type
00108       // SimModuleSaveInfo (will throw a fatal exception otherwise):
00109       nub::ref<FrameOstream> ofs =
00110         dynamic_cast<const SimModuleSaveInfo&>(e->sinfo()).ofs;
00111       Layout<PixRGB<byte> > disp = getDebugImage();
00112       ofs->writeRgbLayout(disp, "EGMM", FrameInfo("EGMM", SRC_POS));
00113     }
00114 }
00115 
00116 // ######################################################################
00117 void EGMM::evolve()
00118 {
00119 
00120 }
00121 
00122 Layout<PixRGB<byte> > EGMM::getDebugImage()
00123 {
00124   Layout<PixRGB<byte> > outDisp;
00125   outDisp = itsCurrentImg;
00126   return outDisp;
00127 
00128 }
00129 
00130 //Create and destory the brain
00131 extern "C" nub::ref<SimModule> createObj( OptionManager& manager,
00132  const std::string& name)
00133 {
00134   return nub::ref<SimModule>(new EGMM(manager));
00135 }
00136 
00137 
00138 // ######################################################################
00139 /* So things look consistent in everyone's emacs... */
00140 /* Local Variables: */
00141 /* indent-tabs-mode: nil */
00142 /* End: */
00143 
00144 #endif
00145 
Generated on Sun May 8 08:41:09 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3