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

TableDataSourceTrec.h

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

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