test-Attentionator.C

00001 /*test-Attentionater.C*/
00002 
00003 #include "Component/ModelManager.H"
00004 #include "Media/FrameSeries.H"
00005 #include "Transport/FrameIstream.H"
00006 #include "Media/MediaOpts.H"
00007 #include "Image/Image.H"
00008 #include "Image/Pixels.H"
00009 #include "Raster/Raster.H"
00010 #include "Image/CutPaste.H"
00011 #include "BeoSub/IsolateColor.H"
00012 #include "Image/DrawOps.H"
00013 #include "Image/ColorOps.H"
00014 #include "GUI/XWinManaged.H"
00015 #include "Neuro/EnvVisualCortex.H"
00016 #include "Image/ShapeOps.H"
00017 #include "Image/MathOps.H"
00018 #include "Util/MathFunctions.H"
00019 #include "SeaBee/Attentionator.H"
00020 
00021 
00022 int main(int argc, char* argv[])
00023 {
00024 
00025   MYLOGVERB = LOG_INFO;
00026 
00027   ModelManager manager("Attentionater Tester");
00028 
00029   nub::soft_ref<InputFrameSeries> ifs(new InputFrameSeries(manager));
00030   manager.addSubComponent(ifs);
00031 
00032   nub::soft_ref<Attentionator> attentionator(new Attentionator(manager));
00033   manager.addSubComponent(attentionator);
00034 
00035  // nub::soft_ref<EnvVisualCortex> EVC(new EnvVisualCortex(manager));
00036   //manager.addSubComponent(EVC);
00037 
00038   manager.exportOptions(MC_RECURSE);
00039 
00040   // Parse command-line:
00041   if (manager.parseCommandLine(argc, argv,
00042                                "[image {*.ppm}]",
00043                                0, 1)
00044       == false) return(1);
00045 
00046 
00047   manager.setOptionValString(&OPT_InputFrameDims, convertToString(ifs->peekDims()));
00048 
00049   manager.setModelParamVal("InputFrameDims", ifs->peekDims(),
00050                            MC_RECURSE | MC_IGNORE_MISSING);
00051 
00052   manager.start();
00053   int w = ifs->getWidth(),  h = ifs->getHeight();
00054   std::string dims = convertToString(Dims(w, h));
00055   LINFO("image size: [%dx%d]", w, h);
00056 
00057 
00058   bool goforever = true;
00059 
00060   rutz::shared_ptr<XWinManaged> dispWin;
00061   dispWin.reset(new XWinManaged(Dims(w*2,h*2), 0, 0, "test-Attentionator Display"));
00062 
00063   // input and output image
00064   Image< PixRGB<byte> > img(w,h, NO_INIT);
00065 
00066         while(goforever)
00067         {
00068                 Image< PixRGB<byte> > dispImg(w*2,h*2, ZEROS);
00069 
00070                 ifs->updateNext();
00071                 img = ifs->readRGB();
00072                 attentionator->updateImage(img);
00073 
00074                 if(!img.initialized()) {Raster::waitForKey(); break; }
00075 
00076                 inplacePaste(dispImg, img, Point2D<int>(0,0));
00077                 inplacePaste(dispImg, attentionator->getSaliencyMap(), Point2D<int>(0,img.getHeight()));
00078                 drawCross(img, attentionator->getSalientPoint(), PixRGB <byte> (0, 255, 0), 5, 3);
00079                 inplacePaste(dispImg, img, Point2D<int>(w,0));
00080 
00081                 dispWin->drawImage(dispImg, 0, 0);
00082         }
00083         Raster::waitForKey();
00084         // get ready to terminate:
00085         manager.stop();
00086   return 0;
00087 }
00088 
00089 // ######################################################################
00090 /* So things look consistent in everyone's emacs... */
00091 /* Local Variables: */
00092 /* indent-tabs-mode: nil */
00093 /* End: */
Generated on Sun May 8 08:06:46 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3