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

MakeQuidLookup.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_MakeQuidLookup_h
00002 #define Impala_Core_VideoSet_MakeQuidLookup_h
00003 
00004 #include "Core/VideoSet/Reporter.h"
00005 #include "Core/Table/Write.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace VideoSet
00012 {
00013 
00014 class MakeQuidLookup : public Listener
00015 {
00016     typedef Column::ColumnTem<Quid> ColumnQuid;
00017     typedef Column::ColumnTem<String> ColumnString;
00018     typedef Table::TableTem<ColumnQuid,
00019                             ColumnString,
00020                             ColumnString,
00021                             ColumnQuid >
00022             QuidLookupTableBaseType;
00023 
00024     class QuidLookupTable : public QuidLookupTableBaseType
00025     {
00026     public:
00027         QuidLookupTable() :
00028             QuidLookupTableBaseType(ColumnQuid(0), ColumnString(0), 
00029                                     ColumnString(0), ColumnQuid(0))
00030         {
00031             SetInfo("QuidLookupTable");
00032             SetColName(1, "quid");
00033             SetColName(2, "string");
00034             SetColName(3, "friendlystring");
00035             SetColName(4, "shotquid");
00036         }
00037     };
00038 
00039 public:
00040 
00041     MakeQuidLookup(Reporter* reporter, CmdOptions& options)
00042     {
00043         mReporter = reporter;
00044         mTable = 0;
00045         mKeyframes = 0;
00046         mSegmentation = 0;
00047     }
00048 
00049     virtual
00050     ~MakeQuidLookup()
00051     {
00052     }
00053 
00054     virtual void
00055     HandleNewWalk(VideoSet* vs)
00056     {
00057         // I don't know what the right way is to construct the Keyframes instance...
00058         mTable = new QuidLookupTable();
00059         mKeyframes = new Keyframes(vs, "keyframes");
00060         mSegmentation = new Segmentation(vs, "segmentation");
00061     }
00062 
00063     virtual void
00064     HandleNewFrame(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00065     {
00066         String videoName = src->GetName();
00067         String::size_type p = videoName.rfind("/");
00068         if (p != String::npos)
00069             videoName = videoName.substr(p+1, videoName.size());
00070 
00071         String imName = FileNameCtor(videoName, "frame", src->FrameNr(), "");
00072         imName = StringReplaceAll(imName, ".", "_");
00073         
00074         Quid quid = vs->GetQuidFrame(fileId, src->FrameNr());
00075 
00076         String friendlyName = "";
00077         if(mKeyframes)
00078         {
00079             int shotId = mKeyframes->GetFrameId(quid);
00080             if(shotId != -1)
00081             {
00082                 friendlyName = mKeyframes->GetName(shotId);
00083             }
00084         }
00085 
00086         Quid shotQuid = 0;
00087         if(mSegmentation)
00088         {
00089             shotQuid = mSegmentation->GetQuidShot(fileId, src->FrameNr());
00090         }
00091 
00092         mTable->Add(quid, imName, friendlyName, shotQuid);
00093     }
00094 
00095     virtual void
00096     HandleDoneWalk(VideoSet* vs)
00097     {
00098         typedef Persistency::RepositoryInFileSystem FS;
00099         typedef Persistency::File File;
00100         File file = FS::GetInstance().GetFile(vs->GetLocator(), "",
00101                                               "quidlookup.tab", true, false);
00102         Write(mTable, file);
00103         delete mTable;
00104     }
00105 
00106 private:
00107 
00108     Reporter*        mReporter;
00109     QuidLookupTable* mTable;
00110     Keyframes*       mKeyframes;
00111     Segmentation*    mSegmentation;
00112 
00113     ILOG_VAR_DEC;
00114 };
00115 
00116 ILOG_VAR_INIT(MakeQuidLookup, Core.VideoSet);
00117 
00118 } // namespace ImageSet
00119 } // namespace Core
00120 } // namespace Impala
00121 
00122 #endif

Generated on Thu Jan 13 09:04:31 2011 for ImpalaSrc by  doxygen 1.5.1