TNOobject.C

Go to the documentation of this file.
00001 /*!@file VFAT/TNOobject.C container for saccade and saliency data per sample
00002  */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00006 // University of Southern California (USC) and the iLab at USC.         //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: T Nathan Mundhenk <mundhenk@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/VFAT/TNOobject.C $
00036 // $Id: TNOobject.C 4663 2005-06-23 17:47:28Z rjpeters $
00037 //
00038 
00039 // ############################################################
00040 // ############################################################
00041 // ##### --- VFAT ---
00042 // ##### Vision Feature Analysis Tool:
00043 // ##### T. Nathan Mundhenk nathan@mundhenk.com
00044 // ##### Laurent Itti itti@pollux.usc.edu
00045 // #####
00046 // ############################################################
00047 // ############################################################
00048 
00049 #include "Util/Assert.H"
00050 
00051 #define NEWSIZE 100
00052 
00053 TNOobject::TNOobject()
00054 {
00055   itr = 0;
00056   featureNumberSet = false;
00057 }
00058 
00059 /************************************************************************/
00060 
00061 TNOobject::~TNOobject()
00062 {}
00063 
00064 /************************************************************************/
00065 
00066 void TNOobject::setLabel(unsigned int _testImage, string _subject)
00067 {
00068   testImage = _testImage; subject = _subject;
00069 }
00070 
00071 /************************************************************************/
00072 
00073 void TNOobject::setFeatureNumber(unsigned int _featureNumber)
00074 {
00075   if(featureNumberSet)
00076     LINFO("WARNING: resetting feature number size. Avoid doing this");
00077   featureNumberSet = true;
00078   featureNumber = _featureNumber;
00079   protoFeature.resize(featureNumber,0.0F);
00080   string filler = "undefined";
00081   featureLabel.resize(featureNumber,filler);
00082 }
00083 
00084 /************************************************************************/
00085 
00086 void TNOobject::getDataSamples(unsigned int* _dataSamples)
00087 {
00088   _dataSamples = &dataSamples;
00089 }
00090 
00091 /************************************************************************/
00092 void TNOobject::getSubject(string* _subject)
00093 {
00094   _subject = &subject;
00095 }
00096 
00097 /************************************************************************/
00098 
00099 void TNOobject::getTestImage(unsigned int* _testImage)
00100 {
00101   _testImage = &testImage;
00102 }
00103 
00104 /************************************************************************/
00105 
00106 void TNOobject::setFeatureLabel(std::vector<string> _featureLabel)
00107 {
00108   featureLabel = _featureLabel;
00109 }
00110 
00111 /************************************************************************/
00112 
00113 void TNOobject::getFeatureLabel(std::vector<string>* _featureLabel)
00114 {
00115   _featureLable = &featureLabel;
00116 }
00117 
00118 /************************************************************************/
00119 
00120 void TNOobject::getFeatureNumber(unsigned int* _featureNumber)
00121 {
00122   _featureNumber = &featureNumber;
00123 }
00124 
00125 /************************************************************************/
00126 
00127 bool TNOobject::setIterator(unsigned int _iter)
00128 {
00129   if(_iter < dataSamples)
00130   {
00131     itr               = _iter;
00132     sampleNumberItr   = &sampleNumber[itr];
00133     sampleTypeItr     = &sampleType[itr];
00134     posXItr           = &posX[itr];
00135     posYItr           = &posY[itr];
00136     jumpToXItr        = &jumpToX[itr];
00137     jumpToYItr        = &jumpToY[itr];
00138     jumpSizeItr       = &jumpSize[itr];
00139     commentItr        = &comment[itr];
00140     maskItr           = &mask[itr];
00141     featureItr        = &feature[itr];
00142     featureLabelItr   = &featureLabel[itr];
00143 
00144     return true;
00145   }
00146   LINFO("WARNING: Attempted to access index out of bounds");
00147   return false;
00148 }
00149 
00150 /************************************************************************/
00151 
00152 void TNOobject::getIterator(unsigned int* _iter)
00153 {
00154   _iter = &itr;
00155 }
00156 
00157 /************************************************************************/
00158 void TNOobject::increaseSize(unsigned int size)
00159 {
00160   string filler = "undefined";
00161 
00162   sampleNumber.resize(sampleNumber.size() + size,0);
00163   sampleType.resize(sampleNumber.size() + size,0);
00164   posX.resize(sampleNumber.size() + size,0.0F);
00165   posY.resize(sampleNumber.size() + size,0.0F);
00166   jumpToX.resize(sampleNumber.size() + size,0.0F);
00167   jumpToY.resize(sampleNumber.size() + size,0.0F);
00168   jumpSize.resize(sampleNumber.size() + size,0);
00169   comment.resize(sampleNumber.size() + size,filler);
00170   mask.resize(sampleNumber.size() + size,false);
00171   feature.resize(sampleNumber.size() + size,protoFeature);
00172   featureLabel.resize(sampleNumber.size() + size,filler);
00173 
00174   sampleNumberItr   = &sampleNumber[itr];
00175   sampleTypeItr     = &sampleType[itr];
00176   posXItr           = &posX[itr];
00177   posYItr           = &posY[itr];
00178   jumpToXItr        = &jumpToX[itr];
00179   jumpToYItr        = &jumpToY[itr];
00180   jumpSizeItr       = &jumpSize[itr];
00181   commentItr        = &comment[itr];
00182   maskItr           = &mask[itr];
00183   featureItr        = &feature[itr];
00184   featureLabelItr   = &featureLabel[itr];
00185 }
00186 
00187 /************************************************************************/
00188 
00189 void TNOobject::getSubject(string* _subject)
00190 {
00191   _subject = &subject;
00192 }
00193 
00194 /************************************************************************/
00195 
00196 void TNOobject::getTestImage(unsigned int* _testImage)
00197 {
00198   _testImage = &testImage;
00199 }
00200 
00201 /************************************************************************/
00202 
00203 void TNOobject::getFeatureNumber(unsigned int* _featureNumber)
00204 {
00205   _featureNumber = &featureNumber;
00206 }
00207 
00208 /************************************************************************/
00209 
00210 void TNOobject::setSaccadeNext(unsigned int _sampleNumber,
00211                                unsigned int _sampleType,
00212                                float _posX, float _posY, float _jumpToX,
00213                                float _jumpToY,
00214                                unsigned int _jumpSize, string _comment,
00215                                bool _mask,
00216                                std::vector<double> _feature)
00217 {
00218   ASSERT(featureNumberSet);
00219   if(sampleNumberItr == sampleNumber.end())
00220   {
00221     increaseSize(NEWSIZE);
00222   }
00223   if(_feature.size() != featureLabel.size())
00224     LINFO("WARNING: feature list and label size mismatch");
00225 
00226   ++sampleNumberItr* = _sampleNumber; ++sampleTypeItr* = _sampleType;
00227   ++posXItr* = _posX; ++posYItr* = _posY;
00228   ++jumpToXItr* = _jumpToX; ++jumpToYItr* = _jumpToY;
00229   ++commentItr* = _comment; ++maskItr* = _mask;
00230   ++featureItr* = _feature;
00231 
00232   itr++; dataSamples++;
00233 }
00234 
00235 /************************************************************************/
00236 
00237 bool TNOobject::getSaccadeNext(unsigned int* _sampleNumber,
00238                                unsigned int* _sampleType,
00239                                float* _posX, float* _posY, float* _jumpToX,
00240                                float* _jumpToY,
00241                                unsigned int* _jumpSize, string* _comment,
00242                                bool* _mask,
00243                                std::vector<double>* _feature)
00244 {
00245   if(itr <= dataSamples)
00246   {
00247     _sampleNumber = ++sampleNumberItr; _sampleType = ++sampleTypeItr;
00248     _posX = ++posXItr; _posY = ++posYItr;
00249     _jumpToX = ++jumpToXItr; _jumpToY = ++jumpToYItr;
00250     _comment = ++commentItr; _mask = ++maskItr;
00251     _feature = ++featureItr;
00252 
00253     itr++;
00254   }
00255   else
00256     LINFO("WARNING: iterator past bounds");
00257 
00258   if(itr != dataSamples)
00259     return false;
00260 
00261   return true;
00262 }
00263 
00264 /************************************************************************/
00265 
00266 bool TNOobject::setSaccade(unsigned int _dataSample,
00267                             unsigned int _sampleNumber,
00268                             unsigned int _sampleType,
00269                             float _posX, float _posY, float _jumpToX,
00270                             float _jumpToY,
00271                             unsigned int _jumpSize, string _comment,
00272                             bool _mask,
00273                             std::vector<double> _feature)
00274 {
00275   if(_dataSample < dataSamples)
00276   {
00277     if(_feature.size() != featureLabel.size())
00278       LINFO("WARNING: feature list and label size mismatch");
00279 
00280     sampleNumber[_dataSample]    = _sampleNumber;
00281     sampleType[_dataSample]      = _sampleType;
00282     posX[_dataSample]            = _posX;
00283     posY[_dataSample]            = _posY;
00284     jumpToX[_dataSample]         = _jumpToX;
00285     jumpSize[_dataSample]        = _jumpSize;
00286     comment[_dataSample]         = _comment;
00287     mask[_dataSample]            = _mask;
00288     feature[_dataSample]         = _feature;
00289 
00290     return true;
00291   }
00292   return false;
00293   LINFO("WARNING: Attempted to access index out of bounds");
00294 }
00295 
00296 /************************************************************************/
00297 
00298 bool TNOobject::getSaccade(unsigned int _dataSample
00299                            unsigned int _sampleNumber,
00300                            unsigned int* _sampleType,
00301                            float* _posX, float* _posY, float* _jumpToX,
00302                            float* _jumpToY,
00303                            unsigned int* _jumpSize, string* _comment,
00304                            bool* _mask
00305                            std::vector<double>* _feature)
00306 {
00307   if(_dataSample < dataSamples)
00308   {
00309     _sampleNumber     = &sampleNumber[_dataSample];
00310     _sampleType       = &sampleType[_dataSample];
00311     _posX             = &posX[_dataSample];
00312     _posY             = &posY[_dataSample];
00313     _jumpToX          = &jumpToX[_dataSample];
00314     _jumpSize         = &jumpSize[_dataSample];
00315     _comment          = &comment[_dataSample];
00316     _mask             = &mask[_dataSample];
00317     _feature          = &feature[_dataSample];
00318     return true;
00319   }
00320   return false;
00321   LINFO("WARNING: Attempted to access index out of bounds");
00322 }
00323 
00324 
00325 
Generated on Sun May 8 08:42:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3