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

vetDoctor.cpp

Go to the documentation of this file.
00001 
00018 #include "vetDoctor.h"
00019 #include "../vetUtility.h"
00020 
00021 
00027 vetDoctor::vetDoctor(RUNMODE mode) : vetOutput()
00028  {
00029         DEBUGMSG("vetDoctor::vetDoctor(RUNMODE mode) : vetOutput() [CONTRUCTOR]", mode)
00030 
00031         runmode = mode;
00032         v_sleeptime = 0;
00033 
00034         reset();
00035  }
00036 
00037 
00046 VETRESULT vetDoctor::reset(bool startTimers)
00047  {
00048         lastFps = 0;
00049         mediumFps = 0;
00050         lastExTime = 0;
00051         mediumExTime = 0;
00052         v_sleeptime = 0;
00053 
00054         if ( startTimers )
00055          {
00056                 lastFrameTime = clock();
00057                 frameCount = 1;
00058          }
00059         else
00060          {
00061                 frameCount = 0;
00062                 lastFrameTime = 0;
00063          }
00064         return VETRET_OK;
00065  }
00066 
00067 
00068 
00077 VETRESULT vetDoctor::setInputFrameRate(float fps)
00078  {
00079         if (fps < 0.)
00080                 return VETRET_PARAM_ERR;
00081 
00082         if ( fps == 0 )
00083                 v_sleeptime = 0;
00084         else
00085                 v_sleeptime = (long)( (float)1000 / fps ); // milliseconds
00086 
00087         return VETRET_OK;
00088  }
00089 
00097 void vetDoctor::updateFps()
00098  {
00099         if ( frameCount == 0 || clock() - lastFrameTime == 0)
00100          {
00101                 lastFrameTime = clock();
00102                 frameCount++;
00103                 return;
00104          }
00105                                                                                 //CLOCKS_PER_SEC;//CLK_TCK;
00106         lastFps = 1  / ( ( clock() - lastFrameTime ) / CLOCKS_PER_SEC ); // fps = 1/elapsedsecond
00107         mediumFps = (mediumFps * (frameCount-1) + lastFps ) / frameCount;
00108 
00109         lastFrameTime = clock();
00110         frameCount++;
00111  }
00112 
00120 void vetDoctor::updateExtime()
00121  {
00122         if ( frameCount == 0 || clock() - lastFrameTime == 0 )
00123          {
00124                 lastExTime = clock();
00125                 return;
00126          }
00127 
00128                                                                                 //CLOCKS_PER_SEC;//CLK_TCK;
00129         lastExTime = 1000 * ( clock() - lastFrameTime ) / CLOCKS_PER_SEC;       //milliseconds
00130         mediumExTime = (mediumExTime * (frameCount-1) + lastExTime ) / frameCount;
00131  }
00132 
00133 
00134 long vetDoctor::getElapsedTime() const
00135  {
00136         return (long) ( 1000 * ( clock() - lastFrameTime ) / CLOCKS_PER_SEC);   //milliseconds
00137  }
00138 
00139 
00140 
00141 
00142 
00154 VETRESULT vetDoctor::importFrom(vetFrameYUV420& img)
00155  {
00156         INFO("int vetDoctor::importFrom(vetFrameYUV420& img) [reading data]")
00157 
00158         return VETRET_NOT_IMPLEMENTED;
00159  }
00160 
00172 VETRESULT vetDoctor::importFrom(vetFrameRGB24& img)
00173  {
00174         INFO("int vetDoctor::importFrom(vetFrameRGB24& img) [reading data]")
00175 
00176         return VETRET_NOT_IMPLEMENTED;
00177  }
00178 
00190 VETRESULT vetDoctor::importFrom(vetFrameT<unsigned char>& img)
00191  {
00192         INFO("int vetDoctor::importFrom(vetFrameT<unsigned char>& img) [reading data]")
00193 
00194         return VETRET_NOT_IMPLEMENTED;
00195  }
00196 
00197 
00207 void vetDoctor::operator << (vetFrameYUV420& img)
00208  {
00209         INFO("void vetDoctor::operator << (vetFrameYUV420& img) [importing data]")
00210 
00211         updateFps();
00212 
00213         if ( runmode )
00214                 importFrom(img);
00215 
00216         updateExtime();
00217 
00218         if ( v_sleeptime )
00219                 vetUtility::vetSleep(v_sleeptime);
00220  }
00221 
00231 void vetDoctor::operator << (vetFrameRGB24& img)
00232  {
00233         INFO("void vetDoctor::operator << (vetFrameRGB24& img) [importing data]")
00234 
00235         updateFps();
00236 
00237         if ( runmode )
00238                 importFrom(img);
00239 
00240         updateExtime();
00241 
00242         if ( v_sleeptime )
00243                 vetUtility::vetSleep(v_sleeptime);
00244  }
00245 
00246 
00256 void vetDoctor::operator << (vetFrameT<unsigned char>& img)
00257  {
00258         INFO("void vetDoctor::operator << (vetFrameT& img) [importing data]")
00259 
00260         updateFps();
00261 
00262         if ( runmode )
00263                 importFrom(img);
00264 
00265         updateExtime();
00266 
00267         if ( v_sleeptime )
00268                 vetUtility::vetSleep(v_sleeptime);
00269  }
00270 
00271 
00272 
00273 
00274 
00275 
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284 
00285 
00286 
00287 
00288 
00289 

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