test-RegSaliency.C

Go to the documentation of this file.
00001 /*!@file CUDA/test-RegSaliency.C tests the reg saliency code */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // 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
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CUDA/test-RegSaliency.C $
00035 // $Id: test-RegSaliency.C 12962 2010-03-06 02:13:53Z irock $
00036 //
00037 
00038 
00039 #include "Component/ModelManager.H"
00040 #include "CUDA/RegSaliency.H"
00041 #include "Image/Image.H"
00042 #include "Image/Pixels.H"
00043 #include "Image/ColorOps.H"
00044 #include "Neuro/NeuroOpts.H"
00045 #include "Raster/Raster.H"
00046 #include "Raster/GenericFrame.H"
00047 #include "Media/FrameSeries.H"
00048 #include "Transport/FrameIstream.H"
00049 #include "Transport/FrameInfo.H"
00050 #include "Transport/FrameOstream.H"
00051 #include "Util/Timer.H"
00052 
00053 #include <signal.h>
00054 #include <stdlib.h>
00055 #include <unistd.h>
00056 
00057 
00058 // ######################################################################
00059 int main(const int argc, const char **argv)
00060 {
00061 
00062   // instantiate a model manager (for camera input):
00063   ModelManager manager("CudaSaliency Tester");
00064 
00065   // NOTE: make sure you register your OutputFrameSeries with the
00066   // manager before you do your InputFrameSeries, to ensure that
00067   // outputs for the current frame get saved before the next input
00068   // frame is loaded.
00069   nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager));
00070   manager.addSubComponent(ofs);
00071 
00072   nub::ref<InputFrameSeries> ifs(new InputFrameSeries(manager));
00073   manager.addSubComponent(ifs);
00074 
00075   nub::ref<RegSaliency> smt(new RegSaliency(manager));
00076   manager.addSubComponent(smt);
00077 
00078   // Parse command-line:
00079   if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return(1);
00080 
00081 
00082 
00083   // ######################################################################
00084   // let's do it!
00085   manager.start();
00086   ifs->startStream();
00087 
00088   while(true)
00089     {
00090       const FrameState is = ifs->updateNext();
00091       if (is == FRAME_COMPLETE)
00092         break;
00093 
00094       GenericFrame input = ifs->readFrame();
00095       if (!input.initialized())
00096         break;
00097 
00098       const Image<PixRGB<byte> > inimg = input.asRgb();
00099       smt->doInput(inimg);
00100 
00101       const FrameState os = ofs->updateNext();
00102       Image<float> out = smt->getOutput();
00103       out = rescaleBilinear(out,inimg.getDims());
00104       const Image<PixRGB<byte> > colout = inimg + toRGB(out);
00105       GenericFrame output = GenericFrame(colout);
00106 
00107       ofs->writeFrame(output, "test",
00108                    FrameInfo("reg saliency frame", SRC_POS));
00109       printf("input frame number %d\n",ifs->frame());
00110       if (os == FRAME_FINAL)
00111         break;
00112       //status = seq->evolve();
00113     }
00114 
00115   // get ready to terminate:
00116   manager.stop();
00117 
00118   return 0;
00119 }
00120 
00121 
00122 // ######################################################################
00123 /* So things look consistent in everyone's emacs... */
00124 /* Local Variables: */
00125 /* indent-tabs-mode: nil */
00126 /* End: */
Generated on Sun May 8 08:40:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3