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

FeatureTableResult.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Feature_FeatureTableResult_h
00002 #define Impala_Core_Feature_FeatureTableResult_h
00003 
00004 #include <vector>
00005 #include "Core/Feature/FeatureTable.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Feature
00012 {
00013 
00014 
00015 // basically a wrapper around the results of calling InterestPointFeature
00016 // on multiple images, e.g. multiple images and multiple FeatureTables.
00017 class FeatureTableResult
00018 {
00019 public:
00020 
00021     FeatureTableResult()
00022         : mDefinition("uninitialized")
00023     {
00024     }
00025 
00026     ~FeatureTableResult()
00027     {
00028         Delete();
00029     }
00030 
00031     void
00032     Delete()
00033     {
00034         for (int i=0 ; i<mTables.size() ; i++)
00035             if(mTables[i])
00036             {
00037                 delete mTables[i];
00038                 mTables[i] = 0;
00039             }
00040         mTables.clear();
00041     }
00042 
00043     int
00044     Size()
00045     {
00046         return mTables.size();
00047     }
00048 
00049     // Checks whether all tables have the same Size.
00050     // If so, returns that size, otherwise returns -1
00051     int
00052     GetTableSize()
00053     {
00054         int size = -1;
00055         for (int i=0 ; i<Size() ; i++)
00056         {
00057             if(!mTables[i]) return -1;
00058             if (size == -1)
00059                 size = mTables[i]->Size();
00060             else if (size != mTables[i]->Size())
00061                 return -1;
00062         }
00063         return size;
00064     }
00065 
00066     FeatureDefinition
00067     GetFeatureDefinition(int i) const
00068     {
00069         if(!mTables[i])
00070         {
00071             ILOG_ERROR("Error: table "<< i << " is not allocated");
00072             return FeatureDefinition("");
00073         }
00074         return mTables[i]->GetFeatureDefinition();
00075     }
00076 
00077     void
00078     SetFeatureDefinition(FeatureDefinition def)
00079     {
00080         mDefinition = def;
00081     }
00082     
00083     void
00084     SetInfo(String info)
00085     {
00086         mTableInfoString = info;
00087         for(int i = 0; i < mTables.size(); i++)
00088         {
00089             if(mTables[i])
00090                 mTables[i]->SetInfo(info);
00091         }
00092     }
00093 
00094     FeatureTable*
00095     GetTable(int i) const
00096     {
00097         return mTables[i];
00098     }
00099 
00100     // return table with given name
00101     void
00102     AddVector(Quid quid, int index, Vector::VectorTem<Real64>& vector)
00103     {
00104         if(mTables.size() <= index)
00105         {
00106             for(int i = mTables.size(); i <= index; i++)
00107             {
00108                 mTables.push_back(0);
00109             }
00110         }
00111         if(!mTables[index])
00112         {
00113             // first vector: allocate the table
00114             Feature::FeatureDefinition tempDef(mDefinition.AsString());
00115             if(index != 0)
00116                 tempDef.AddParameter("sub", MakeString(index));
00117             Feature::FeatureTable* t = new Feature::FeatureTable(
00118                                           tempDef.AsString(), 500,
00119                                           vector.Size());
00120             t->SetInfo(mTableInfoString);
00121             mTables[index] = t;
00122         }
00123 
00124         mTables[index]->Add(quid, vector);
00125         return;
00126     }
00127 
00128 private:
00129 
00130     std::vector<FeatureTable*> mTables;
00131     FeatureDefinition mDefinition;
00132     String mTableInfoString;
00133 
00134     ILOG_VAR_DEC;
00135 };
00136 
00137 ILOG_VAR_INIT(FeatureTableResult, Impala.Core.Feature);
00138 
00139 } // namespace Feature
00140 } // namespace Core
00141 } // namespace Impala
00142 
00143 #endif

Generated on Thu Jan 13 09:04:24 2011 for ImpalaSrc by  doxygen 1.5.1