00001 #ifndef Impala_Core_ImageSet_IndexConcepts_h
00002 #define Impala_Core_ImageSet_IndexConcepts_h
00003
00004 #include "Persistency/SimilarityTableSetRepository.h"
00005 #include "Core/ImageSet/Reporter.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace ImageSet
00012 {
00013
00014
00015 class IndexConcepts : public Listener
00016 {
00017 public:
00018 typedef Feature::FeatureDefinition FeatureDefinition;
00019 typedef Table::SimilarityTableSet SimilarityTableSet;
00020 typedef Persistency::SimilarityTableSetLocator SimilarityTableSetLocator;
00021 typedef Persistency::SimilarityTableSetRepository SimilarityTableSetRepository;
00022
00023 IndexConcepts(Reporter* reporter, CmdOptions& options, ImageSet* is)
00024 {
00025 if (options.GetNrArg() < 5)
00026 {
00027 ILOG_ERROR("Missing argument");
00028 return;
00029 }
00030 mLoc = SimilarityTableSetLocator
00031 (is->GetLocator(), false, "", options.GetArg(2), options.GetArg(3),
00032 options.GetArg(4), "");
00033 mSimSet = 0;
00034 }
00035
00036 virtual void
00037 HandleNewWalk(ImageSet* is, String walkType)
00038 {
00039 mLoc.SetWalkType(walkType);
00040 }
00041
00042 virtual void
00043 HandleDoneDir(ImageSet* is, int dirId)
00044 {
00045 mLoc.SetContainer(is->GetContainer(dirId));
00046 SimilarityTableSet* simSet = SimilarityTableSetRepository().Get(mLoc);
00047 if (mSimSet == 0)
00048 {
00049 std::vector<String> names = simSet->GetNames();
00050 mSimSet = new SimilarityTableSet(names, 1000000);
00051 }
00052 mSimSet->Append(simSet);
00053 delete simSet;
00054 }
00055
00056 virtual void
00057 HandleDoneWalk(ImageSet* is)
00058 {
00059 mSimSet->ComputeRanks(true);
00060 mLoc.SetInIndex(true);
00061 SimilarityTableSetRepository().Add(mLoc, mSimSet);
00062 delete mSimSet;
00063 }
00064
00065 private:
00066
00067 SimilarityTableSetLocator mLoc;
00068 SimilarityTableSet* mSimSet;
00069
00070 ILOG_VAR_DEC;
00071
00072 };
00073
00074 ILOG_VAR_INIT(IndexConcepts, Impala.Core.ImageSet);
00075
00076 }
00077 }
00078 }
00079
00080 #endif