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

void Impala::Application::Util::DoJudgeConcepts (  ) 

Definition at line 1367 of file mainUtil.cpp.

References Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Add(), Impala::Util::DatabaseReadStrings(), Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Get(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::VideoSet::Keyframes::GetFrameId(), Impala::CmdOptions::GetInstance(), Impala::Core::VideoSet::Segmentation::GetName(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetShotId(), Impala::Core::VideoSet::Keyframes::GetShotId(), Impala::Core::Trec::SearchJudge::HasTopic(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_VAR, Impala::Core::Trec::SearchJudge::Judge(), Impala::Core::Table::SimilarityTableSet::MakeFromFile(), Impala::Core::VideoSet::MakeVideoSet(), Impala::QUID_CLASS_FRAME, Impala::QUID_CLASS_SHOT, Impala::QuidClass(), and Impala::Core::Trec::SearchJudge::Stats().

Referenced by mainUtil().

01368 {
01369 #ifndef REPOSITORY_TODO
01370     typedef Core::VideoSet::VideoSet VideoSet;
01371     typedef Core::VideoSet::Segmentation Segmentation;
01372     typedef Core::VideoSet::Keyframes Keyframes;
01373     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
01374     typedef Core::Table::SimilarityTableSet::RankTableType RankTableType;
01375 
01376     ILOG_VAR(Impala.Application.Util.DoJudgeConcepts);
01377     CmdOptions& options = CmdOptions::GetInstance();
01378     if (options.GetNrArg() < 5)
01379     {
01380         ILOG_ERROR("Need at least 5 arguments");
01381         return;
01382     }
01383     String vidSetName = options.GetArg(1);
01384     String namesPath = options.GetArg(2);
01385     String mappingName = options.GetArg(3);
01386     String judgeFile = options.GetArg(4);
01387 
01388     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName);
01389     SegmentationLocator sLoc(vidSetName, "segmentation", options);
01390     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
01391     KeyframesLocator kLoc(vidSetName, "keyframes", options);
01392     Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet);
01393     Impala::Util::Database* db = vidSet->GetDatabase();
01394     SimilarityTableSet* simSet =
01395         Core::Table::SimilarityTableSet::MakeFromFile(namesPath, db);
01396 
01397     std::vector<String> lines;
01398     Impala::Util::SimpleMap<String, String> conceptMapping;
01399     Impala::Util::DatabaseReadStrings(lines, mappingName, db);
01400     for (int i=0 ; i<lines.size() ; i++)
01401     {
01402         Impala::Util::StringParser p(lines[i]);
01403         String topic = p.GetString(' ');
01404         String concept = p.GetString(' ', false);
01405         std::cout << topic << " = " << concept << std::endl;
01406         conceptMapping.Add(concept, topic);
01407     }
01408     Core::Trec::SearchJudge judge(judgeFile);
01409     judge.Stats();
01410 
01411     Real64 miap = 0;
01412     int nrMiap = 0;
01413     std::cout << namesPath << ", size = " << simSet->TableSize() << std::endl;
01414     for (int c=0 ; c<simSet->NrTables() ; c++)
01415     {
01416         String concept = simSet->GetName(c);
01417         ILOG_DEBUG("Doing concept " << concept);
01418         std::vector<String> res;
01419         RankTableType* rTable = simSet->GetRankTable(c);
01420         for (int i=0 ; i<rTable->Size() ; i++)
01421         {
01422             Quid quid = rTable->Get1(i);
01423             int shot = -1;
01424             if (QuidClass(quid) == QUID_CLASS_FRAME) // assume it is a keyframe
01425             {
01426                 int keyfr = keyframes->GetFrameId(quid);
01427                 if (keyfr != -1)
01428                     shot = keyframes->GetShotId(keyfr);
01429             }
01430             if (QuidClass(quid) == QUID_CLASS_SHOT)
01431             {
01432                 shot = segmentation->GetShotId(quid);
01433             }
01434             if (shot == -1)
01435             {
01436                 ILOG_ERROR("Unable to find shot for " << QuidObj(quid));
01437                 continue;
01438             }
01439             String name = segmentation->GetName(shot);
01440             if (std::find(res.begin(), res.end(), name) == res.end())
01441                 res.push_back(name);
01442             if (res.size() >= 2000)
01443                 break;
01444         }
01445         String topic;
01446         if (!conceptMapping.Get(concept, topic))
01447         {
01448             ILOG_ERROR("No topic for " << concept);
01449             continue;
01450         }
01451         if (!judge.HasTopic(topic))
01452         {
01453             ILOG_INFO("No judge for " << topic << " = " << concept);
01454             continue;
01455         }
01456         Real64 infAP = judge.Judge(topic, res);
01457         std::cout << concept << " " << infAP << std::endl;
01458         miap += infAP;
01459         nrMiap++;
01460     }
01461     std::cout << "miap = " << miap / nrMiap << std::endl << std::endl;
01462     delete simSet;
01463     delete vidSet;
01464 #endif
01465 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:52:14 2010 for ImpalaSrc by  doxygen 1.5.1