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

FrameRegionTable.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Table_FrameRegionTable_h
00002 #define Impala_Core_Table_FrameRegionTable_h
00003 
00004 #include "Util/DatabaseReadString.h"
00005 #include "Core/Table/TableTem.h"
00006 #include "Core/Table/Read.h"
00007 //#include "Core/VideoSet/Segmentation.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace Tracking
00014 {
00015 
00016 class FrameRegion
00017 {
00018 public:
00019     FrameRegion(int videoId, int frame, int left, int top, int right, int bottom) :
00020         mRect(left, top, right, bottom)
00021     {
00022         mVideoId = videoId;
00023         mFrame = frame;
00024     }
00025 
00026     int GetFrameNumber()
00027     {
00028         return mFrame;
00029     }
00030 
00031     Geometry::Rectangle GetRectangle()
00032     {
00033         return mRect;
00034     }
00035 
00036     int mVideoId;
00037     int mFrame;
00038     Geometry::Rectangle mRect;
00039 };
00040 
00041 
00042 typedef int VideoId;
00043 
00044 typedef Table::TableTem<Column::ColumnTem<VideoId>,
00045                         Column::ColumnTem<int>,
00046                         Column::ColumnTem<int>,
00047                         Column::ColumnTem<int>,
00048                         Column::ColumnTem<int>,
00049                         Column::ColumnTem<int> >
00050         FrameRegionTableBaseType;
00051 
00052 
00055 class FrameRegionTable : public FrameRegionTableBaseType
00056 {
00057 public:
00058 
00059     typedef Column::ColumnTem<int> ColumnInt;
00060 
00061     FrameRegionTable() :
00062         FrameRegionTableBaseType(ColumnInt(0), ColumnInt(0), ColumnInt(0), ColumnInt(0), ColumnInt(0), ColumnInt(0))
00063     {
00064         SetColName(1, "videoid");
00065         SetColName(2, "frame number");
00066         SetColName(3, "x");
00067         SetColName(4, "y");
00068         SetColName(5, "w");
00069         SetColName(6, "h");
00070 
00071     }
00072 
00073     FrameRegion GetRegion(int i)
00074     {
00075         return FrameRegion(Get1(i), Get2(i), Get3(i), Get4(i), Get5(i), Get6(i));
00076     }
00077 
00078     void Add(Geometry::Rectangle r)
00079     {
00080         // assume video id and framenum are same as last entry.
00081         int vid=0, frame=0;
00082         if(mLast != 0)
00083         {
00084             vid = Get1(mLast - 1);
00085             frame = Get2(mLast - 1) + 1;
00086         }
00087         FrameRegionTableBaseType::Add(vid, frame, r.mLeft, r.mTop, r.mRight, r.mBottom);
00088     }
00089 
00090     void Add(FrameRegion fr)
00091     {
00092         FrameRegionTableBaseType::Add(fr.mVideoId, fr.mFrame, fr.mRect.mLeft, fr.mRect.mTop, fr.mRect.mRight, fr.mRect.mBottom);
00093     }
00094 
00095     void WriteTo(std::ostream& os)
00096     {
00097         // does not write vid id, this is the file format for PhD student use, not in a 'system'
00098         int i;
00099         for(i=0 ; i<mLast ; ++i)
00100         {
00101             os << Get2(i) << " "
00102                << Get3(i) << " " << Get4(i) << " "
00103                << Get5(i) << " " << Get6(i) << "\n";
00104         }
00105     }
00106 
00107     void ReadFrom(std::istream& is)
00108     {
00109         // does not read vid id, this is the file format for PhD student use, not in a 'system'
00110         while(!is.eof())
00111         {
00112             int frame = -1;
00113             int left, top, right, bottom;
00114             is >> frame >> left >> top >> right >> bottom;
00115             if(frame != -1)
00116             FrameRegionTableBaseType::Add(0, frame, left, top, right, bottom);
00117         }
00118     }
00119 };
00120 
00121 } // namespace Tracking
00122 } // namespace Core
00123 } // namespace Impala
00124 
00125 #endif

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