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

IndexFeatures.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_ImageSet_IndexFeatures_h
00002 #define Impala_Core_ImageSet_IndexFeatures_h
00003 
00004 #include "Persistency/FeatureTableRepository.h"
00005 #include "Core/Feature/FeatureTable.h"
00006 #include "Core/ImageSet/Reporter.h"
00007 #include "Core/Table/Append.h"
00008 #include "Core/Table/Write.h"
00009 #include "Core/Feature/DumpFeatureTableHistogram.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace ImageSet
00016 {
00017 
00018 
00019 class IndexFeatures : public Listener
00020 {
00021 public:
00022     typedef Feature::FeatureTable FeatureTable;
00023 
00024     IndexFeatures(Reporter* reporter, CmdOptions& options)
00025     {
00026         mReporter = reporter;
00027         if (Link::Mpi::NrProcs() == 8) // quick hack for sift
00028         {
00029             String feat = options.GetArg(2);
00030             int nr = Link::Mpi::MyId();
00031             String sub = (nr == 0) ? "" : "_sub_" + MakeString(nr);
00032             mDef = Feature::FeatureDefinition(feat + sub);            
00033             ILOG_INFO_NODE("indexing feature " << mDef.AsString());
00034         }
00035         else
00036         {
00037             mDef = Feature::FeatureDefinition(options.GetArg(2));
00038         }
00039         mTable = 0;
00040     }
00041 
00042     virtual void
00043     HandleDoneDir(ImageSet* is, int dirId)
00044     {
00045 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00046         String fName = is->GetFilePathFeatureData(mDef, dirId, false, -1, 
00047                                                   false, false);
00048         if (fName.empty())
00049         {
00050             return;
00051         }
00052         FeatureTable tmp(mDef);
00053         Table::Read(&tmp, fName, is->GetDatabase());
00054         if (mTable == 0)
00055         {
00056             mTable = new FeatureTable(mDef, 12000, tmp.GetFeatureVectorLength());
00057         }
00058         Table::Append(mTable, &tmp);
00059 #else // REPOSITORY_USED
00060         Persistency::FeatureLocator loc(is->GetLocator(), false, false, "",
00061                                         mDef.AsString(),
00062                                         is->GetContainerDir(dirId));
00063         FeatureTable* tmp = Persistency::FeatureTableRepository().Get(loc);
00064         if (mTable == 0)
00065         {
00066             mTable = new FeatureTable(mDef, 12000,
00067                                       tmp->GetFeatureVectorLength());
00068         }
00069         Table::Append(mTable, tmp);
00070         delete tmp;
00071 #endif // REPOSITORY_USED
00072     }
00073 
00074     virtual void
00075     HandleDoneWalk(ImageSet* is)
00076     {
00077 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00078         String fName = is->GetFilePathFeatureIndex(mDef, "", true, false);
00079         if (!fName.empty())
00080             Table::Write(mTable, fName, is->GetDatabase(), true);
00081 #else // REPOSITORY_USED
00082         Persistency::FeatureLocator loc(is->GetLocator(), false, true, "",
00083                                         mDef.AsString(), "");
00084         Persistency::FeatureTableRepository().Add(loc, mTable);
00085 #endif // REPOSITORY_USED
00086     }
00087 
00088 private:
00089 
00090     Reporter*                  mReporter;
00091     Feature::FeatureDefinition mDef;
00092     Feature::FeatureTable*     mTable;
00093 
00094     ILOG_VAR_DEC;
00095 };
00096 
00097 ILOG_VAR_INIT(IndexFeatures, Impala.Core.ImageSet);
00098 
00099 } // namespace ImageSet
00100 } // namespace Core
00101 } // namespace Impala
00102 
00103 #endif

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