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

ExportConcepts.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_ExportConcepts_h
00002 #define Impala_Core_VideoSet_ExportConcepts_h
00003 
00004 #include "Core/Table/SimilarityTableSet.h"
00005 #include "Core/VideoSet/Reporter.h"
00006 #include "Core/VideoSet/Segmentation.h"
00007 #include "Core/VideoSet/Mpeg7DocWrite.h"
00008 
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace VideoSet
00014 {
00015 
00016 
00017 class ExportConcepts : public Listener
00018 {
00019 public:
00020     typedef Feature::FeatureDefinition FeatureDefinition;
00021     typedef Table::SimilarityTableSet SimilarityTableSet;
00022 
00023     ExportConcepts(Reporter* reporter, CmdOptions& options)
00024     {
00025         mReporter = reporter;
00026         if (options.GetNrArg() < 5)
00027         {
00028             ILOG_ERROR("Missing argument");
00029             return;
00030         }
00031         mFractions = atol(options.GetArg(2));
00032         if ((mFractions != 25) && (mFractions != 30000))
00033             ILOG_WARN("Never tried fractions = " << mFractions);
00034         mConceptFileName = options.GetArg(3);
00035         mModel = options.GetArg(4);
00036         if (options.GetNrArg() > 5)
00037             mFeatureDef = FeatureDefinition(options.GetArg(5));
00038         mSegmentation = 0;
00039     }
00040 
00041     virtual void
00042     HandleNewWalk(VideoSet* vs, String walkType)
00043     {
00044         mWalkType = walkType;
00045     }
00046 
00047     virtual void
00048     HandleNewWalk(VideoSet* vs, Segmentation* segmentation)
00049     {
00050         mSegmentation = segmentation;
00051     }
00052 
00053     virtual void
00054     HandleDoneFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00055     {
00056         if ((mSegmentation == 0))
00057         {
00058             ILOG_ERROR("Need segmentation");
00059             return;
00060         }
00061         String subDir = (mFeatureDef.Empty()) ? "" : mFeatureDef.AsString();
00062         SimilarityTableSet* simSet =
00063             SimilarityTableSet::MakeFromFile(vs, mWalkType, mConceptFileName,
00064                                              mModel, subDir, fileId);
00065 
00066         for (int c=0 ; c<simSet->NrTables() ; c++)
00067         {
00068             String concept = simSet->GetName(c);
00069             ILOG_INFO("doing concept " << concept);
00070             ILOG_NDC_PUSH(concept);
00071             SimilarityTableSet::SimTableType* table = simSet->GetSimTable(c);
00072             String fileName = vs->GetFile(fileId);
00073             ILOG_DEBUG("doing file " << fileName);
00074             String id = fileName;
00075             int nrFrames = mSegmentation->GetNrFramesVideo(fileId);
00076             Mpeg7Doc mp7(id, fileName, nrFrames, mFractions, false,
00077                          mConceptFileName, concept);
00078             mp7.SetAnnoIsConcept();
00079             for (int i=0 ; i<table->Size() ; i++)
00080             {
00081                 Quid quid = simSet->GetQuidTable()->Get1(i);
00082                 if (QuidClass(quid) != QUID_CLASS_FRAME)
00083                     ILOG_ERROR("Quid is not a frame");
00084                 int frameNr = QuidId(quid);
00085                 String name = "frame_" + MakeString(frameNr);
00086                 double sim = table->Get1(i);
00087                 mp7.AddAnnotation(concept, name, frameNr, frameNr, 1, sim);
00088             }
00089             Core::VideoSet::Mpeg7DocWrite(&mp7, vs, fileId);
00090             ILOG_NDC_POP;
00091         }
00092         delete simSet;
00093     }
00094 
00095 private:
00096 
00097     Reporter*           mReporter;
00098     int                 mFractions;
00099     String              mConceptFileName;
00100     String              mModel;
00101     FeatureDefinition   mFeatureDef;
00102     Segmentation*       mSegmentation;
00103     String              mWalkType;
00104 
00105     ILOG_VAR_DEC;
00106 
00107 };
00108 
00109 ILOG_VAR_INIT(ExportConcepts, Impala.Core.VideoSet);
00110 
00111 } // namespace VideoSet
00112 } // namespace Core
00113 } // namespace Impala
00114 
00115 #endif

Generated on Fri Mar 19 09:31:29 2010 for ImpalaSrc by  doxygen 1.5.1