Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

vetInput.cpp

Go to the documentation of this file.
00001 
00017  #include "vetInput.h"
00018  #include "vetUtility.h"
00019 
00020 
00026 #include <time.h>
00027 
00028 //CLK_TCK
00029 //CLOCKS_PER_SEC
00030 
00031 
00032 
00040 vetInput::vetInput(float fps)
00041  {
00042         v_elab_start = 0;
00043         setFrameRate(fps);
00044 
00045         DEBUGMSG("vetInput::vetInput(float fps) [CONTRUCTOR] ", fps)
00046  }
00047 
00048 
00049 
00064 VETRESULT vetInput::setFrameRate(float fps)
00065  {
00066         if (fps < 0.)
00067                 return VETRET_PARAM_ERR;
00068 
00069         v_framerate = fps;
00070 
00071         if ( fps == 0 )
00072                 v_sleeptime = 0;
00073         else
00074                 v_sleeptime = (long)( (float)1000 / fps ); // milliseconds
00075 
00076         DEBUGMSG("VETRESULT vetInput::setFrameRate(float fps)", fps)
00077 
00078         return VETRET_OK;
00079  }
00080 
00081 
00090 inline void vetInput::setElaborationStart()
00091  {
00092         v_elab_start = clock();
00093  }
00094 
00106 inline long vetInput::getElaborationTime()
00107  {
00108         return 1000 * (clock() - v_elab_start) / CLOCKS_PER_SEC;//CLK_TCK;
00109  }
00110 
00111 
00112 
00128 vetInput& vetInput::operator >> (vetFrameRGB24& img)
00129  {
00130         INFO("vetInput& vetInput::operator >> (vetFrameYUV420& img) [pushing data]")
00131 
00132         setElaborationStart();
00133 
00134         extractTo(img);
00135 
00136         if ( v_sleeptime && v_sleeptime > (long)getElaborationTime())
00137                 vetUtility::vetSleep( v_sleeptime - (long)getElaborationTime() );    // milliseconds
00138 
00139         DEBUG(getElaborationTime());
00140         return *this;
00141  }
00142 
00143 
00159 vetInput& vetInput::operator >> (vetFrameYUV420& img)
00160  {
00161         INFO("vetInput& vetInput::operator >> (vetFrameYUV420& img) [pushing data]")
00162 
00163         setElaborationStart();
00164 
00165         extractTo(img);
00166 
00167         if ( v_sleeptime && v_sleeptime > (long)getElaborationTime())
00168                 vetUtility::vetSleep( v_sleeptime - (long)getElaborationTime() );    // milliseconds
00169 
00170         DEBUG(getElaborationTime());
00171         return *this;
00172  }
00173 
00174 
00190 vetInput& vetInput::operator >> (vetFrameT<unsigned char>& img)
00191  {
00192         INFO("vetInput& vetInput::operator >> (vetFrameT& img) [pushing data]")
00193 
00194         setElaborationStart();
00195 
00196         extractTo(img);
00197 
00198         if ( v_sleeptime && v_sleeptime > (long)getElaborationTime())
00199                 vetUtility::vetSleep( v_sleeptime - (long)getElaborationTime() );    // milliseconds
00200 
00201         DEBUG(getElaborationTime());
00202         return *this;
00203  }
00204 
00205 

Generated on Tue Jan 24 11:59:04 2006 for VETLib by  doxygen 1.4.4