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

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

Definition at line 1802 of file mainUtil.cpp.

References Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Add(), Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Get(), Impala::CmdOptions::GetArg(), Impala::Core::VideoSet::Keyframes::GetFrameId(), Impala::CmdOptions::GetInstance(), Impala::Core::Database::RawDataSet::GetLocator(), 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::VideoSet::MakeVideoSet(), Impala::QUID_CLASS_FRAME, Impala::QUID_CLASS_SHOT, Impala::QuidClass(), Impala::Persistency::File::ReadStrings(), Impala::Persistency::RepositoryGetFile(), and Impala::Core::Trec::SearchJudge::Stats().

Referenced by mainUtil().

01803 {
01804     typedef Core::VideoSet::VideoSet VideoSet;
01805     typedef Core::VideoSet::Segmentation Segmentation;
01806     typedef Core::VideoSet::Keyframes Keyframes;
01807     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
01808     typedef Core::Table::SimilarityTableSet::RankTableType RankTableType;
01809 
01810     ILOG_VAR(Impala.Application.Util.DoJudgeConcepts);
01811     CmdOptions& options = CmdOptions::GetInstance();
01812     if (options.GetNrArg() < 7)
01813     {
01814         ILOG_ERROR("Need at least 7 arguments");
01815         return;
01816     }
01817     String vidSetName = options.GetArg(1);
01818     String conceptSet = options.GetArg(2);
01819     String model = options.GetArg(3);
01820     String feature = options.GetArg(4);
01821     String mappingName = options.GetArg(5);
01822     String judgeFile = options.GetArg(6);
01823 
01824     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName);
01825     SegmentationLocator sLoc(vidSetName, "segmentation", options);
01826     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
01827     KeyframesLocator kLoc(vidSetName, "keyframes", options);
01828     Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet);
01829     SimilarityTableSetLocator simLoc(vidSet->GetLocator(), true, "",
01830                                      conceptSet, model, feature, "");
01831     SimilarityTableSet* simSet = SimilarityTableSetRepository().Get(simLoc);
01832 
01833     std::vector<String> lines;
01834     Impala::Util::SimpleMap<String, String> conceptMapping;
01835     Persistency::File file = RepositoryGetFile(mappingName, false, false);
01836     file.ReadStrings(lines);
01837     for (int i=0 ; i<lines.size() ; i++)
01838     {
01839         Impala::Util::StringParser p(lines[i]);
01840         String topic = p.GetString(' ');
01841         String concept = p.GetString(' ', false);
01842         std::cout << topic << " = " << concept << std::endl;
01843         conceptMapping.Add(concept, topic);
01844     }
01845     Core::Trec::SearchJudge judge(judgeFile);
01846     judge.Stats();
01847 
01848     Real64 miap = 0;
01849     int nrMiap = 0;
01850     std::cout << simLoc << ", size = " << simSet->TableSize() << std::endl;
01851     for (int c=0 ; c<simSet->NrTables() ; c++)
01852     {
01853         String concept = simSet->GetName(c);
01854         ILOG_DEBUG("Doing concept " << concept);
01855         std::vector<String> res;
01856         RankTableType* rTable = simSet->GetRankTable(c);
01857         for (int i=0 ; i<rTable->Size() ; i++)
01858         {
01859             Quid quid = rTable->Get1(i);
01860             int shot = -1;
01861             if (QuidClass(quid) == QUID_CLASS_FRAME) // assume it is a keyframe
01862             {
01863                 int keyfr = keyframes->GetFrameId(quid);
01864                 if (keyfr != -1)
01865                     shot = keyframes->GetShotId(keyfr);
01866             }
01867             if (QuidClass(quid) == QUID_CLASS_SHOT)
01868             {
01869                 shot = segmentation->GetShotId(quid);
01870             }
01871             if (shot == -1)
01872             {
01873                 ILOG_ERROR("Unable to find shot for " << QuidObj(quid));
01874                 continue;
01875             }
01876             String name = segmentation->GetName(shot);
01877             if (std::find(res.begin(), res.end(), name) == res.end())
01878                 res.push_back(name);
01879             if (res.size() >= 2000)
01880                 break;
01881         }
01882         String topic;
01883         if (!conceptMapping.Get(concept, topic))
01884         {
01885             ILOG_ERROR("No topic for " << concept);
01886             continue;
01887         }
01888         if (!judge.HasTopic(topic))
01889         {
01890             ILOG_INFO("No judge for " << topic << " = " << concept);
01891             continue;
01892         }
01893         Real64 infAP = judge.Judge(topic, res);
01894         std::cout << concept << " " << infAP << std::endl;
01895         miap += infAP;
01896         nrMiap++;
01897     }
01898     std::cout << "miap = " << miap / nrMiap << std::endl << std::endl;
01899     delete simSet;
01900     delete vidSet;
01901 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:16:31 2011 for ImpalaSrc by  doxygen 1.5.1