Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Reporter.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_Reporter_h
00002 #define Impala_Core_VideoSet_Reporter_h
00003 
00004 #include "Basis/CmdOptions.h"
00005 #include "Basis/Timer.h"
00006 #include "Core/VideoSet/Listener.h"
00007 #include "Core/VideoSet/VideoSet.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace VideoSet
00014 {
00015 
00016 
00024 class Reporter : public Listener
00025 {
00026 public:
00027 
00028     Reporter(Reporter* master)
00029     {
00030         mMaster = master;
00031         CmdOptions& options = CmdOptions::GetInstance();
00032         mReport = options.GetInt("report");
00033         mNrDone = 0;
00034         mTotalNrFramesInBookmarks = 0;
00035         mReportArray = true;
00036     }
00037 
00038     virtual void
00039     HandleNewWalk(VideoSet* vs)
00040     {
00041         if (mMaster)
00042             ILOG_DEBUG("..   new walk");
00043     }
00044 
00045     virtual void
00046     HandleNewWalk(VideoSet* vs, int nrBookmarks)
00047     {
00048         if (mMaster)
00049             ILOG_DEBUG("..   new walk, nrBookmarks = " << nrBookmarks);
00050     }
00051 
00052     /*
00053     virtual void
00054     HandleNewDir(VideoSet* vs, int dirId)
00055     {
00056         if (mMaster)
00057             ILOG_DEBUG("..   new dir id = " << dirId);
00058     }
00059 
00060     virtual void
00061     HandleDoneDir(VideoSet* vs, int dirId)
00062     {
00063         if (mMaster)
00064             ILOG_DEBUG("..   done dir id = " << dirId);
00065     }
00066     */
00067 
00068     virtual void
00069     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00070     {
00071         if (mMaster)
00072             ILOG_INFO("..   new file id = " << fileId << " name = "
00073                       << vs->GetFile(fileId));
00074     }
00075 
00076     virtual void
00077     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src,
00078                   int bookmarkNr, Geometry::VxRectangle vr)
00079     {
00080         if (mMaster)
00081             ILOG_INFO("..   new file id = " << fileId << ", bookmark = "
00082                       << bookmarkNr);
00083     }
00084 
00085     virtual void
00086     HandleDoneFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00087     {
00088         if (mMaster)
00089             ILOG_INFO("..   done file id = " << fileId);
00090         int nrError = ILOG_ERROR_COUNT;
00091         if (mMaster && ((nrError > 0) || (mReport > 0)))
00092             ILOG_INFO("done file=" << fileId << " error=" << ILOG_ERROR_COUNT);
00093     }
00094 
00095     virtual void
00096     HandleDoneFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src,
00097                    int bookmarkNr, Geometry::VxRectangle vr)
00098     {
00099         if (mMaster)
00100             ILOG_INFO("..   done file id = " << fileId << ", bookmark = "
00101                       << bookmarkNr);
00102     }
00103 
00104     virtual void
00105     HandleNewShot(VideoSet* vs, int fileId, Stream::RgbDataSrc* src, int shotId)
00106     {
00107         if (mMaster)
00108             ILOG_DEBUG("..   new shot id = " << shotId);
00109     }
00110 
00111     virtual void
00112     HandleDoneShot(VideoSet* vs, int fileId, Stream::RgbDataSrc* src, int shotId)
00113     {
00114         if (mMaster)
00115             ILOG_DEBUG("..   done shot id = " << shotId);
00116     }
00117 
00118     virtual void
00119     HandleNewFrame(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00120     {
00121         if (mMaster)
00122         {
00123             int frameNr = (src) ? src->FrameNr() : 0;
00124             ILOG_DEBUG("..   new frame number = " << frameNr);
00125         }
00126         if (mMaster)
00127         {
00128             mMaster->AllDoneFrame();
00129             return;
00130         }
00131         mDoPrint = false;
00132         mNrDone++;
00133         if ((mReport > 0) && (mNrDone % mReport == 0))
00134             mDoPrint = true;
00135         if (mDoPrint)
00136         {
00137             int nrFiles = vs->NrFiles();
00138             int perc = (int) (((double) fileId / (double) nrFiles) * 100);
00139             if (src)
00140                 ILOG_INFO("--   frame " << src->FrameNr() << " of "
00141                           << src->LastFrame()+1 << ", at nr " << mNrDone
00142                           << " (at file " << fileId << " of "
00143                           << nrFiles << " = " << perc << "%)")
00144             else
00145                 ILOG_INFO("--   frame (no src available), at nr " << mNrDone
00146                           << " (at file " << fileId
00147                           << " of " << nrFiles << " = " << perc << "%)");
00148         }
00149         Array::ArraySystem::Instance().MarkMemoryUsage(false);
00150     }
00151 
00152     virtual void
00153     HandleNewFrame(VideoSet* vs, int fileId, Stream::RgbDataSrc* src,
00154                    Geometry::Rectangle rect, std::string anno)
00155     {
00156         if (mMaster)
00157         {
00158             int frameNr = (src) ? src->FrameNr() : 0;
00159             ILOG_DEBUG("..   new frame number = " << frameNr);
00160         }
00161         if (mMaster)
00162         {
00163             mMaster->AllDoneFrame();
00164             return;
00165         }
00166         mDoPrint = false;
00167         mNrDone++;
00168         if ((mReport > 0) && (mNrDone % mReport == 0))
00169             mDoPrint = true;
00170         if (mDoPrint)
00171         {
00172             int nrFrames = mTotalNrFramesInBookmarks;
00173             int perc = (int) (((double)mNrDone / (double)nrFrames) * 100);
00174             ILOG_INFO("--   at nr " << mNrDone << " of " << nrFrames
00175                       << " (" << perc << "%)");
00176         }
00177         Array::ArraySystem::Instance().MarkMemoryUsage(false);
00178     }
00179 
00180     virtual void
00181     HandleDoneWalk(VideoSet* vs)
00182     {
00183         if (mMaster)
00184             ILOG_DEBUG("..   done walk");
00185     }
00186 
00187     virtual void
00188     HandleDoneWalk(VideoSet* vs, int nrBookmarks)
00189     {
00190         if (mMaster)
00191             ILOG_DEBUG("..   done walk, nrBookmarks = " << nrBookmarks);
00192     }
00193 
00194     void
00195     FinalReport()
00196     {
00197         int nr = (mNrDone != 0) ? mNrDone : 1;
00198         ILOG_INFO("DONE time avg=" << mTimerTotal.SplitTimeStr(nr) <<
00199                   " total=" << mTimerTotal.SplitTimeStr() <<
00200                   " error=" << ILOG_ERROR_COUNT);
00201     }
00202 
00203     bool
00204     DoPrint()
00205     {
00206         return mDoPrint;
00207     }
00208 
00209     void
00210     SetReportArray(bool flag)
00211     {
00212         mReportArray = flag;
00213     }
00214 
00215     void
00216     SetTotalNrFramesInBookmarks(int nr)
00217     {
00218         mTotalNrFramesInBookmarks = nr;
00219     }
00220 
00221 private:
00222 
00223     void
00224     AllDoneFrame()
00225     {
00226         if (mReportArray)
00227             Array::ArraySystem::Instance().CheckMemoryUsageSinceMark(false);
00228         if (mDoPrint)
00229         {
00230             ILOG_INFO("++ time avg=" << mTimerReport.SplitTimeStr(mReport)
00231                       << " total=" << mTimerTotal.SplitTimeStr()
00232                       << " error=" << ILOG_ERROR_COUNT);
00233             mTimerReport.Start();
00234         }
00235     }
00236 
00237     Reporter*   mMaster;
00238     int         mReport;
00239     int         mNrDone;
00240     bool        mReportArray;
00241     Timer       mTimerTotal;
00242     Timer       mTimerReport;
00243     bool        mDoPrint;
00244     int         mTotalNrFramesInBookmarks;
00245 
00246     ILOG_VAR_DEC;
00247 };
00248 
00249 ILOG_VAR_INIT(Reporter, Impala.Core.VideoSet);
00250 
00251 } // namespace VideoSet
00252 } // namespace Core
00253 } // namespace Impala
00254 
00255 #endif

Generated on Fri Mar 19 09:31:14 2010 for ImpalaSrc by  doxygen 1.5.1