00001 #ifndef Impala_Core_ImageSet_IndexConcepts_h
00002 #define Impala_Core_ImageSet_IndexConcepts_h
00003
00004 #include "Core/Table/SimilarityTableSet.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
00021 IndexConcepts(Reporter* reporter, CmdOptions& options)
00022 {
00023 mReporter = reporter;
00024 if (options.GetNrArg() < 5)
00025 {
00026 ILOG_ERROR("Missing argument");
00027 return;
00028 }
00029 mConceptFileName = options.GetArg(2);
00030 mModel = options.GetArg(3);
00031 mFeatureDef = FeatureDefinition(options.GetArg(4));
00032 mSimSet = 0;
00033 }
00034
00035 virtual void
00036 HandleNewWalk(ImageSet* is, String walkType)
00037 {
00038 mWalkType = walkType;
00039 }
00040
00041 virtual void
00042 HandleDoneDir(ImageSet* is, int dirId)
00043 {
00044 SimilarityTableSet* simSet = SimilarityTableSet::MakeFromFile
00045 (is, mWalkType, mConceptFileName, mModel, mFeatureDef.AsString(), dirId);
00046
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 mSimSet->Save(is, mConceptFileName, mModel, mFeatureDef.AsString(),
00061 true);
00062 delete mSimSet;
00063 }
00064
00065 private:
00066
00067 Reporter* mReporter;
00068 String mConceptFileName;
00069 String mModel;
00070 FeatureDefinition mFeatureDef;
00071 SimilarityTableSet* mSimSet;
00072 String mWalkType;
00073
00074 ILOG_VAR_DEC;
00075
00076 };
00077
00078 ILOG_VAR_INIT(IndexConcepts, Impala.Core.ImageSet);
00079
00080 }
00081 }
00082 }
00083
00084 #endif