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

TableShots.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Table_TableShots_h
00002 #define Impala_Core_Table_TableShots_h
00003 
00004 #include "Basis/NativeTypes.h"
00005 #include "Core/Table/TableTem.h"
00006 #include "Core/Geometry/FileReadVxRectangle.h"
00007 #include "Core/Geometry/FileWriteVxRectangle.h"
00008 #include "Core/VideoSet/Segmentation.h"
00009 #include "Core/VideoSet/Keyframes.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace VideoSet
00016 {
00017 
00018 
00019 typedef Table::TableTem<Column::ColumnTem<Int32>,
00020                         Column::ColumnTem<Int32>,
00021                         Column::ColumnTem<std::string>,
00022                         Column::ColumnTem<Geometry::Rectangle> > TableShotsBaseType;
00023 
00026 class TableShots : public TableShotsBaseType
00027 {
00028 public:
00029 
00030     TableShots() : TableShotsBaseType(0)
00031     {
00032         SetColName(1, "shotId");
00033         SetColName(2, "keyframeId");
00034         SetColName(3, "anno");
00035         SetColName(4, "rect");
00036     }
00037 
00038     void
00039     ReadVxsFile(std::string fileName, Keyframes* keyframes)
00040     {
00041         std::vector<Geometry::VxRectangle> vrList;
00042         Geometry::FileReadVxRectangle(std::back_inserter(vrList), fileName);
00043         for (int i=0 ; i<vrList.size() ; i++)
00044         {
00045             Geometry::VxRectangle vr = vrList[i];
00046             int keyfr = keyframes->GetFrameId(vr.mExtra);
00047             int shot = keyframes->GetShotId(keyfr);
00048             Add(shot, keyfr, vr.mAnno, vr.mRect);
00049         }
00050     }
00051 
00052     // conceptName is used only when bookmark does not have its own annotation
00053     void
00054     WriteVxsFile(std::string fileName, std::string conceptName,
00055                  Segmentation* shots, Keyframes* keyframes)
00056     {
00057         std::vector<Geometry::VxRectangle> vrList;
00058         for (int i=0 ; i<Size() ; i++)
00059         {
00060             int shot = Get1(i);
00061             Geometry::VxRectangle vr;
00062             vr.mStartFrame = shots->GetStart(shot);
00063             vr.mEndFrame = shots->GetEnd(shot);
00064             vr.mAnno = Get3(i);
00065             if (vr.mAnno == std::string(""))
00066                 vr.mAnno = conceptName;
00067             vr.mRect = Get4(i);
00068             int vid = shots->GetVideoId(shot);
00069             vr.mVideoName = shots->GetVideoSet()->GetFile(vid);
00070             vr.mSection = shots->GetVideoSet()->GetSection(vid);
00071             vr.mDir = shots->GetVideoSet()->GetDir(vid);
00072             vr.mExtra = keyframes->GetName(Get2(i));
00073             vrList.push_back(vr);
00074         }
00075         Geometry::FileWriteVxRectangle(fileName, vrList.begin(), vrList.end());
00076     }
00077 
00078 };
00079 
00080 } // namespace VideoSet
00081 } // namespace Core
00082 } // namespace Impala
00083 
00084 #endif

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