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

ImportConcepts.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_ImportConcepts_h
00002 #define Impala_Core_VideoSet_ImportConcepts_h
00003 
00004 #include "Persistency/SimilarityTableSetRepository.h"
00005 #include "Persistency/Mpeg7DocRepository.h"
00006 #include "Core/VideoSet/Reporter.h"
00007 #include "Core/VideoSet/Segmentation.h"
00008 #include "Core/VideoSet/Keyframes.h"
00009 #include "Core/VideoSet/Mpeg7Doc.h"
00010 
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace VideoSet
00016 {
00017 
00018 
00019 class ImportConcepts : public Listener
00020 {
00021 public:
00022     typedef Table::SimilarityTableSet SimilarityTableSet;
00023     typedef Table::SimilarityTableSet::SimTableType SimTableType;
00024     typedef Persistency::SimilarityTableSetLocator SimilarityTableSetLocator;
00025     typedef Persistency::SimilarityTableSetRepository SimilarityTableSetRepository;
00026 
00027     ImportConcepts(Reporter* reporter, CmdOptions& options)
00028     {
00029         if (options.GetNrArg() < 5)
00030         {
00031             ILOG_ERROR("Missing argument");
00032             return;
00033         }
00034         mConceptSet = options.GetArg(2);
00035         mModel = options.GetArg(3);
00036         mFeature = options.GetArg(4);
00037         mSimSet = 0;
00038     }
00039 
00040     virtual void
00041     HandleNewWalk(VideoSet* vs)
00042     {
00043         Persistency::KeywordListLocator loc(vs->GetLocator(), mConceptSet);
00044         Table::KeywordList names =
00045             *(Persistency::KeywordListRepository().Get(loc));
00046         mSimSet = new SimilarityTableSet(names, 100);
00047     }
00048 
00049     virtual void
00050     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00051     {
00052         String vidName = vs->GetFile(fileId);
00053         int frameRateNum = (src) ? src->FrameRateNum() : 0;
00054         int frameRateDen = (src) ? src->FrameRateDen() : 0;
00055         for (int c=0 ; c<mSimSet->NrTables() ; c++)
00056         {
00057             String concept = mSimSet->GetName(c);
00058             SimTableType* table = mSimSet->GetSimTable(c);            
00059             String container = mConceptSet + "/" + vs->GetContainerFile(fileId);
00060             typedef Persistency::Mpeg7DocLocator MP7Loc;
00061             MP7Loc loc(vs->GetLocator(), MP7Loc::MPEG7_CONCEPT, container,
00062                        concept + ".xml");
00063             if (!Persistency::Mpeg7DocRepository().Exists(loc))
00064                 continue;
00065 
00066             Mpeg7Doc* mp7 = Persistency::Mpeg7DocRepository().Get(loc);
00067             for (int s=0 ; s<mp7->NrShots() ; s++)
00068             {
00069                 double sim = mp7->Confidence(s);
00070                 table->Add(sim);
00071             }
00072             if (c == 0)
00073             {
00074                 Table::QuidTable* qTable = mSimSet->GetQuidTable();
00075                 for (int s=0 ; s<mp7->NrShots() ; s++)
00076                 {
00077                     Quid quid = vs->GetQuidFrame(fileId, mp7->StartFrame(s));
00078                     qTable->Add(quid);
00079                 }
00080             }
00081             delete mp7;
00082         }
00083     }
00084 
00085     virtual void
00086     HandleDoneWalk(VideoSet* vs)
00087     {
00088         mSimSet->ComputeRanks(true);
00089         SimilarityTableSetLocator loc(vs->GetLocator(), true, "", mConceptSet,
00090                                       mModel, mFeature, "");
00091         SimilarityTableSetRepository().Add(loc, mSimSet);
00092         delete mSimSet;
00093     }
00094 
00095 private:
00096 
00097     String              mConceptSet;
00098     String              mModel;
00099     String              mFeature;
00100     SimilarityTableSet* mSimSet;
00101 
00102     ILOG_VAR_DEC;
00103 
00104 };
00105 
00106 ILOG_VAR_INIT(ImportConcepts, Impala.Core.VideoSet);
00107 
00108 } // namespace VideoSet
00109 } // namespace Core
00110 } // namespace Impala
00111 
00112 #endif

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