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

Video.h

Go to the documentation of this file.
00001 #ifndef Impala_Visualization_Video_h
00002 #define Impala_Visualization_Video_h
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 namespace Impala {
00008 namespace Visualization {
00009 
00010 class Video
00011 {
00012 
00013 public:
00014 
00015     int mType;
00016     int mId;
00017     int mSubId;
00018     std::string mBasePath;
00019     std::string mFileNameSuffix;
00020     std::string mBasePathAnnotated;
00021     std::string mFileNameSuffixAnnotated;
00022 
00023     Video()
00024     {
00025     }
00026 
00027     Video(int nrOfFrames, float timePerFrame, int nrOfFirstFrame = 0)
00028     {
00029         mTotalNrOfFrames = nrOfFrames;
00030         mNrOfFirstFrame = nrOfFirstFrame;
00031         mNrOfLastFrame = nrOfFirstFrame + nrOfFrames - 1;
00032         mTimePerFrame = timePerFrame;
00033     }
00034 
00035     virtual ~Video()
00036     {
00037     }
00038 
00039     void GetFramePath(int frameNr, char* const buffer) const
00040     {
00041         GetFramePath(frameNr, buffer, mBasePath, mFileNameSuffix);
00042     }
00043 
00044     void GetFramePathAnnotated(int frameNr, char* const buffer) const
00045     {
00046         GetFramePath(frameNr, buffer, 
00047             mBasePathAnnotated.empty() ? mBasePath : mBasePathAnnotated, 
00048             mFileNameSuffixAnnotated.empty() ? mFileNameSuffix : mFileNameSuffixAnnotated);
00049     }
00050 
00051     float GetTimePerFrame() const
00052     {
00053         return mTimePerFrame;
00054     }
00055 
00056     int GetTotalNrOfFrames() const
00057     {
00058         return mTotalNrOfFrames;
00059     }
00060 
00061     int GetNrOfFirstFrame() const
00062     {
00063         return mNrOfFirstFrame;
00064     }
00065 
00066     int GetNrOfLastFrame() const
00067     {
00068         return mNrOfLastFrame;
00069     }
00070 
00071 
00072     float GetTimePast(int frameNr) const
00073     {
00074         return (float) (frameNr - mNrOfFirstFrame) * mTimePerFrame;
00075     }
00076 
00077     int GetMostRecentFrameNr(int timeInSec) const
00078     {
00079         return GetMostRecentFrameNr((float) timeInSec);
00080     }
00081 
00082     int GetMostRecentFrameNr(float timeInSec) const
00083     {
00084         return (int) (timeInSec / mTimePerFrame) + mNrOfFirstFrame;
00085     }
00086 
00087     bool IsMovementFrame(int frameNr) const
00088     {
00089         std::vector<int>::const_iterator iter = mFrameNrsCamMoving.begin();
00090         while (iter != mFrameNrsCamMoving.end())
00091         {
00092             if (*iter > frameNr)
00093                 return false;
00094             else if (*iter == frameNr)
00095                 return true;
00096             iter++;
00097         }
00098         return false;
00099     }
00100 
00101     void AddMovementFrame(int frameNr)
00102     {
00103         mFrameNrsCamMoving.push_back(frameNr);
00104     }
00105 
00106 
00107 private:
00108 
00109     int mTotalNrOfFrames;
00110     int mNrOfFirstFrame;
00111     int mNrOfLastFrame;
00112     float mTimePerFrame;
00113     std::vector<int> mFrameNrsCamMoving;
00114 
00115     void GetFramePath(int frameNr, char* const buffer, const std::string& basePath, const std::string suffix) const
00116     {
00117         if (mType == 1)
00118         {
00119 #ifdef RICHARD
00120             sprintf(buffer, "%s%05d%s", basePath.c_str(), frameNr, suffix.c_str());
00121 #else
00122             static std::string sequenceNames[] = {"argument", "gesticulation", "pickpocketing"};
00123             static int sequenceSizes[] = {232, 80, 179};
00124             static int emptySize = 200;
00125             int seqId = 0;
00126             bool showEmpty = false;
00127             
00128             for (int i = 0; i < 3; i++)
00129                 if (frameNr < sequenceSizes[i])
00130                 {
00131                     seqId = i;
00132                     showEmpty = false;
00133                     break;
00134                 }
00135                 else
00136                 {
00137                     frameNr -= sequenceSizes[i];
00138                     if (frameNr < emptySize)
00139                     {
00140                         showEmpty = true;
00141                         break;
00142                     }
00143                     else
00144                         frameNr -= emptySize;
00145                 }
00146 
00147             //sprintf(buffer, "%s%03d%s", basePath.c_str(), frameNr, suffix.c_str());
00148             if (showEmpty)
00149                 sprintf(buffer, "%sempty_r%i.jpg", basePath.c_str(), mSubId);
00150             else
00151                 sprintf(buffer, "%s%s/image%03d%s", basePath.c_str(), sequenceNames[seqId].c_str(), frameNr, suffix.c_str());
00152 #endif
00153         }
00154         else
00155         {
00156             sprintf(buffer, "%s%05d%s", basePath.c_str(), frameNr, suffix.c_str());
00157         }
00158     }
00159 
00160 }; // class
00161 
00162 }
00163 }
00164 
00165 #endif

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