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

TableDataSourceTrec.h

Go to the documentation of this file.
00001 #ifndef MediaTable_TableDataSourceTrec_h
00002 #define MediaTable_TableDataSourceTrec_h
00003 
00004 #include "TrecEngine.h"
00005 #include "TableDataSource.h"
00006 
00007 namespace Impala {
00008 namespace Application {
00009 namespace MediaTable {
00010 
00011 class TableDataSourceTrec : public TableDataSource
00012 {
00013 public:
00014     typedef Impala::Core::VideoSet::Keyframes          Keyframes;
00015     typedef Impala::Core::ImageSet::ImageSet           ImageSet;
00016 
00017     TableDataSourceTrec():
00018         TableDataSource()
00019     {
00020         Init();
00021     }
00022 
00023     ~TableDataSourceTrec()
00024     {
00025     }
00026 
00027     /* get individual row characteristics ************************/
00028     virtual String
00029     GetTextDataByID(String column, int row)
00030     {
00031         if (column=="id")
00032             return MakeString(row);
00033         if (column=="name")
00034             return mKeyframes->GetName(row);
00035         if (column=="shotname")
00036                         return mTrecEngine->GetShots()->GetName(mKeyframes->GetShotId(row));
00037         if (column=="type")
00038             return "MPEG1 352x288";
00039         if (column=="keyframes")
00040             return MakeString(mKeyframes->GetNrKeyframesShot(mKeyframes->GetShotId(row)));
00041         return "N/A";
00042     }
00043 
00044     virtual int
00045     GetIntDataByID(String column, int row)
00046     {
00047         if (column=="keyframes")
00048         {
00049             return mKeyframes->GetNrKeyframesShot(mKeyframes->GetShotId(row));
00050         }
00051         return 0;
00052     }
00053 
00054     virtual double
00055     GetNormalizedDataByID(String column, int row)
00056     {
00057         if (column == "isrkf")
00058         {
00059             if (mKeyframes->IsRKF(row))
00060                 return 1.0;
00061             return 0.0;
00062         }
00063         return mTrecEngine->GetTableSimilarityScore(mColmap[column], row);
00064     }
00065 
00066     virtual double
00067     GetDoubleDataByID(String column, int row)
00068     {
00069         return GetNormalizedDataByID(column, row);
00070     }
00071 
00072     virtual Array2dVec3UInt8*
00073     GetImageDataByID(String column, int row)
00074     {
00075         ImageSet *set = mTrecEngine->GetKeyframeImageSet();
00076         if (set)
00077             return set->GetImage(row);
00078         return 0;
00079     }
00080 
00081     virtual Array2dVec3UInt8*
00082     GetVideoDataByID(String column, int row)
00083     {
00084         return mTrecEngine->GetNextStill(row);
00085     }
00086         
00087         virtual int GetTotalRows()
00088         {
00089                 return mKeyframes->GetNrKeyframes();
00090         }
00091 
00092 private:
00093 
00094     void Init()
00095     {
00096         mTrecEngine = new IDash::TrecEngine();
00097         mKeyframes  = mTrecEngine->GetKeyframes();
00098 
00099         if (!mKeyframes)
00100             ILOG_ERROR("Set does not have keyframes.");
00101 
00102         ILOG_DEBUG("Trec engine loaded, displaying all keyframes: " <<
00103                    GetTotalRows());
00104 
00105         AddStaticColumn("shotname", TYPE_TEXT, 90);
00106 
00107         //AddStaticColumn("rank", TYPE_TEXT, 50);
00108         AddStaticColumn("image", TYPE_IMAGE, 120);
00109         //AddStaticColumn("name", TYPE_TEXT, 120);
00110         //AddStaticColumn("type", TYPE_TEXT, 100);
00111         //AddStaticColumn("isrkf", TYPE_NORMALIZEDVALUE, 20, 1);
00112         //AddStaticColumn("keyframes", TYPE_TEXT, 30);
00113 
00114         int max = 22;
00115         for (int i=0; i<mTrecEngine->GetNrTables(); i++)
00116         {
00117             AddColumn(mTrecEngine->GetTableName(i),TYPE_NORMALIZEDVALUE,20,4);
00118             mColmap[mTrecEngine->GetTableName(i)] = i;
00119             if (i > max)
00120                 break;
00121         }
00122     }
00123 
00124     IDash::TrecEngine*          mTrecEngine;
00125     std::map<String, int>       mColmap;
00126     Keyframes*                  mKeyframes;
00127 
00128     ILOG_VAR_DEC;
00129 };
00130 
00131 ILOG_VAR_INIT(TableDataSourceTrec, Application.MediaTable);
00132 
00133 } // namespace MediaTable
00134 } // namespace Application
00135 } // namespace Impala
00136 
00137 #endif // TableDataSourceTrec_h

Generated on Fri Mar 19 09:30:35 2010 for ImpalaSrc by  doxygen 1.5.1