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<std::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
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 != std::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 String filename = vs->GetDatabase()->GetFilePath(".", "quidlookup.tab", true, false);
00099 Write(mTable, filename, vs->GetDatabase(), true);
00100 delete mTable;
00101 }
00102
00103 private:
00104
00105 Reporter* mReporter;
00106 QuidLookupTable* mTable;
00107 Keyframes* mKeyframes;
00108 Segmentation* mSegmentation;
00109
00110 ILOG_VAR_DEC;
00111 };
00112
00113 ILOG_VAR_INIT(MakeQuidLookup, Core.VideoSet);
00114
00115 }
00116 }
00117 }
00118
00119 #endif