psycho-color-calib.C

Go to the documentation of this file.
00001 /*!@file AppPsycho/psycho-color-calib.C display RGB colors for luminance calibration */
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: David J. Berg <dberg@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppPsycho/psycho-color-calib-eval.C $
00035 
00036 #include "Component/ModelManager.H"
00037 #include "Component/ModelOptionDef.H"
00038 #include "Image/Image.H"
00039 #include "Psycho/PsychoDisplay.H"
00040 #include "Psycho/PsychoOpts.H"
00041 #include "Component/ComponentOpts.H"
00042 #include "GUI/SDLdisplay.H"
00043 #include "Neuro/NeuroOpts.H"
00044 
00045 #include <vector>
00046 
00047 
00048 static const ModelOptionDef OPT_RValue =
00049   { MODOPT_ARG(uint), "RValue", &MOC_DISPLAY, OPTEXP_CORE,
00050     "intensity value to use in red image [0-255]","rval", '\0', "<uint>", "255" };
00051 
00052 static const ModelOptionDef OPT_GValue =
00053   { MODOPT_ARG(uint), "GValue", &MOC_DISPLAY, OPTEXP_CORE,
00054     "intensity value to use in green image [0-255]","gval", '\0', "<uint>", "255" };
00055 
00056 static const ModelOptionDef OPT_BValue =
00057   { MODOPT_ARG(uint), "BValue", &MOC_DISPLAY, OPTEXP_CORE,
00058     "intensity value to use in blue image [0-255]","bval", '\0', "<uint>", "255" };
00059 
00060 static const ModelOptionDef OPT_ColDisplayTime =
00061   { MODOPT_ARG(uint), "DisplayTime", &MOC_DISPLAY, OPTEXP_CORE,
00062     "time in millesconds to display image","displaytime", '\0', "<uint>", "3000" };
00063 
00064 static const ModelOptionDef OPT_RepTimes =
00065   { MODOPT_ARG(uint), "RepTime", &MOC_DISPLAY, OPTEXP_CORE,
00066     "times to repeat RGB sequence","RepTime", '\0', "<uint>", "2" };
00067 
00068 // ######################################################################
00069 extern "C" int main(const int argc, char** argv)
00070 {
00071   MYLOGVERB = LOG_INFO;  // suppress debug messages
00072   
00073   // Instantiate a ModelManager:
00074   ModelManager manager("Psycho Color Calibration");
00075 
00076   OModelParam<uint> r(&OPT_RValue, &manager);
00077   OModelParam<uint> g(&OPT_GValue, &manager);
00078   OModelParam<uint> b(&OPT_BValue, &manager);
00079   OModelParam<uint> dtime(&OPT_ColDisplayTime, &manager);
00080   OModelParam<uint> loops(&OPT_RepTimes, &manager);
00081   
00082   // Instantiate our various ModelComponents:
00083   nub::soft_ref<PsychoDisplay> d(new PsychoDisplay(manager));
00084   manager.addSubComponent(d);
00085 
00086   // Parse command-line:
00087   if (manager.parseCommandLine(argc, argv, "", 0, 0) == false)
00088     return(1);
00089 
00090   // let's get all our ModelComponent instances started:
00091   manager.start();
00092     
00093   int w = d->getWidth();
00094   int h = d->getHeight();
00095   
00096   std::vector<Image<PixRGB<byte> > > images;
00097   // r
00098   images.push_back(Image<PixRGB<byte> >(w,h, NO_INIT));
00099   images.back().clear(PixRGB<byte>(r.getVal(),0,0));
00100 
00101   //g
00102   images.push_back(Image<PixRGB<byte> >(w,h, NO_INIT));
00103   images.back().clear(PixRGB<byte>(0,g.getVal(),0));
00104 
00105   //b
00106   images.push_back(Image<PixRGB<byte> >(w,h, NO_INIT));
00107   images.back().clear(PixRGB<byte>(0,0,b.getVal()));
00108 
00109   //rgb
00110   images.push_back(Image<PixRGB<byte> >(w,h, NO_INIT));
00111   images.back().clear(PixRGB<byte>(r.getVal(),g.getVal(),b.getVal()));
00112   
00113   for (uint cc = 0; cc < loops.getVal(); ++cc)
00114     for (uint ii = 0; ii < images.size(); ++ii)
00115       {
00116         d->displayImage(images[ii],false);
00117         
00118         if (dtime.getVal() == 0)
00119           d->waitForKey();                  
00120         else
00121           usleep(dtime.getVal() * 1000);
00122       }
00123   
00124   // stop all our ModelComponents
00125   manager.stop();
00126   
00127   // all done!
00128   return 0;
00129 }
00130 
00131 // ######################################################################
00132 /* So things look consistent in everyone's emacs... */
00133 /* Local Variables: */
00134 /* indent-tabs-mode: nil */
00135 /* End: */
Generated on Sun May 8 08:04:11 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3