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

Stills.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_Stills_h
00002 #define Impala_Core_VideoSet_Stills_h
00003 
00004 #include "Core/Table/MakeGroupIndex.h"
00005 #include "Core/VideoSet/VideoSet.h"
00006 //#include "Core/ImageSet/ImageSet.h"
00007 #include "Core/Table/TableTem.h"
00008 #include "Core/Table/Read.h"
00009 #include "Core/Table/Write.h"
00010 #include "Core/Table/RemoveRow.h"
00011 #include "Core/Column/Find.h"
00012 
00013 namespace Impala
00014 {
00015 namespace Core
00016 {
00017 namespace VideoSet
00018 {
00019 
00020 
00021 typedef Table::TableTem<Column::ColumnTem<Int32>,
00022                         Column::ColumnTem<Int32>,
00023                         Column::ColumnTem<Int32>,
00024                         Column::ColumnTem<String> > StillsBaseType;
00025 
00026 
00027 class Stills : public StillsBaseType
00028 {
00029     typedef Impala::Core::Table::GroupIndex GroupIndex;
00030 
00031 public:
00032 
00033     Stills(VideoSet* vidSet, String name) : StillsBaseType(0)
00034     {
00035         mVidSet = vidSet;
00036         mName = name;
00037         mVideoGroups = 0;
00038         mShotGroups = 0;
00039         SetColName(1, "videoId");
00040         SetColName(2, "shotId");
00041         SetColName(3, "frameNr");
00042         SetColName(4, "name");
00043 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00044         if (!mName.empty())
00045             Load();
00046 #else // REPOSITORY_USED
00047         if (!mName.empty())
00048             ILOG_ERROR("Load stills via repository");
00049 #endif // REPOSITORY_USED
00050     }
00051 
00052     // inquiry part
00053 
00054     int
00055     GetNrStills()
00056     {
00057         return Size();
00058     }
00059 
00060     int
00061     GetVideoId(int stillId)
00062     {
00063         return Get1(stillId);
00064     }
00065 
00066     int
00067     GetShotId(int stillId)
00068     {
00069         return Get2(stillId);
00070     }
00071 
00072     String
00073     GetName(int stillId)
00074     {
00075         return Get4(stillId);
00076     }
00077 
00078     int
00079     GetFrameNr(int stillId)
00080     {
00081         return Get3(stillId);
00082     }
00083 
00084     int
00085     GetFrameId(String name)
00086     {
00087         int rank = Find(GetColumn4(), name, 0, Size());
00088         if (rank == Size())
00089             return -1;
00090         return rank;
00091     }
00092 
00093     // frameNr's are not unique, so "segment" start and end are required
00094     int
00095     GetFrameId(int frameNr, int idxStart, int idxEnd)
00096     {
00097         int rank = Find(GetColumn3(), frameNr, idxStart, idxEnd);
00098         if (rank == idxEnd)
00099             return -1;
00100         return rank;
00101     }
00102 
00103     VideoSet*
00104     GetVideoSet()
00105     {
00106         return mVidSet;
00107     }
00108 
00109     // video and shot groups
00110 
00111     void
00112     UpdateGroups()
00113     {
00114         if (mVideoGroups == 0)
00115         {
00116             mVideoGroups = new GroupIndex(0);
00117             mVideoGroups->SetColName(1, "firstStillId");
00118             mVideoGroups->SetColName(2, "nrStills");
00119         }
00120         MakeGroupIndex(mVideoGroups, GetColumn1(), 0, Size());
00121         if (mShotGroups == 0)
00122         {
00123             mShotGroups = new GroupIndex(0);
00124             mShotGroups->SetColName(1, "firstStillId");
00125             mShotGroups->SetColName(2, "nrStills");
00126         }
00127         // todo?: statement below fails in case a video has only 1 shot
00128         MakeGroupIndex(mShotGroups, GetColumn2(), 0, Size());
00129     }
00130 
00131     int
00132     GetNrVideos()
00133     {
00134         return mVideoGroups->Size();
00135     }
00136 
00137     int
00138     GetFirstStillVideo(int videoId)
00139     {
00140         return mVideoGroups->Get1(videoId);
00141     }
00142 
00143     int
00144     GetNrStillsVideo(int videoId)
00145     {
00146         return mVideoGroups->Get2(videoId);
00147     }
00148 
00149     int
00150     GetFrameIdVideo(int videoId, int frameNr)
00151     {
00152         int start = GetFirstStillVideo(videoId);
00153         int nr = GetNrStillsVideo(videoId);
00154         return GetFrameId(frameNr, start, start+nr);
00155     }
00156 
00157     int
00158     GetNrShots()
00159     {
00160         return mShotGroups->Size();
00161     }
00162 
00163     int
00164     GetFirstStillShot(int shotId)
00165     {
00166         return mShotGroups->Get1(shotId);
00167     }
00168 
00169     int
00170     GetNrStillsShot(int shotId)
00171     {
00172         return mShotGroups->Get2(shotId);
00173     }
00174 
00175 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00176     // I/O part
00177 
00178     void
00179     Load()
00180     {
00181         String fName = mVidSet->GetFilePathVideoIndex("", mName + ".tab",
00182                                                       false, false);
00183         Read(this, fName, mVidSet->GetDatabase());
00184         UpdateGroups();
00185     }
00186 
00187     void
00188     Save(String name, bool binary)
00189     {
00190         if (!name.empty())
00191             mName = name;
00192         String fName = mVidSet->GetFilePathVideoIndex("", mName + ".tab",
00193                                                       true, false);
00194         Write(this, fName, mVidSet->GetDatabase(), binary);
00195     }
00196 #endif // REPOSITORY_USED
00197 
00198     void
00199     DumpGroups()
00200     {
00201         mVideoGroups->Dump();
00202         mShotGroups->Dump();
00203     }
00204 
00205 private:
00206 
00207     VideoSet*   mVidSet;
00208     String      mName;
00209     GroupIndex* mVideoGroups;
00210     GroupIndex* mShotGroups;
00211 
00212     ILOG_VAR_DEC;
00213 };
00214 
00215 ILOG_VAR_INIT(Stills, Impala.Core.VideoSet);
00216 
00217 } // namespace VideoSet
00218 } // namespace Core
00219 } // namespace Impala
00220 
00221 #endif

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