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

void Impala::Application::Util::DoMapConcepts2Shots (  ) 

Definition at line 1544 of file mainUtil.cpp.

References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetInstance(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetNrShots(), Impala::Core::VideoSet::Segmentation::GetQuidShot(), Impala::Core::VideoSet::Segmentation::GetShotId(), ILOG_ERROR, ILOG_VAR, and Impala::Core::VideoSet::MakeVideoSet().

Referenced by mainUtil().

01545 {
01546     typedef Core::VideoSet::VideoSet VideoSet;
01547     typedef Core::VideoSet::Segmentation Segmentation;
01548     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
01549     typedef Core::Table::SimilarityTableSet::SimTableType SimTableType;
01550 
01551     ILOG_VAR(Impala.Application.Util.DoMapConcepts2Shots);
01552     CmdOptions& options = CmdOptions::GetInstance();
01553     if (options.GetNrArg() < 5)
01554     {
01555         ILOG_ERROR("Need more parameters");
01556         return;
01557     }
01558     String vidSetName = options.GetArg(1);
01559     String conceptSet = options.GetArg(2);
01560     String model = options.GetArg(3);
01561     String feature = options.GetArg(4);
01562     String aggregationMode = "max";
01563     if (options.GetNrArg() >= 6)
01564     {
01565         aggregationMode = options.GetArg(5);
01566     }
01567 
01568     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName);
01569     SegmentationLocator sLoc(vidSetName, "segmentation", options);
01570     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
01571     SimilarityTableSetLocator simLoc(vidSet->GetLocator(), true, "",
01572                                      conceptSet, model, feature, "");
01573     SimilarityTableSet* simSet = SimilarityTableSetRepository().Get(simLoc);
01574  
01575     Core::Table::QuidTable* frameQuids = simSet->GetQuidTable();
01576     int nrShots = segmentation->GetNrShots();
01577     SimilarityTableSet* res = new SimilarityTableSet(simSet->GetNames(), nrShots);
01578     Core::Table::QuidTable* shotQuids = res->GetQuidTable();
01579     for (int t=0 ; t<simSet->NrTables() ; t++)
01580     {
01581         SimTableType* frameSimTable = simSet->GetSimTable(t);
01582         SimTableType* shotSimTable = res->GetSimTable(t);
01583         int lastShot = -1;
01584         Real64 lastSim = 0;
01585         int lastCount = 0;
01586         for (int i=0 ; i<frameSimTable->Size() ; i++)
01587         {
01588             Quid frameQ = frameQuids->Get1(i);
01589             Real64 frameSim = frameSimTable->Get1(i);
01590             int shot = segmentation->GetShotId(frameQ);
01591             if (shot != lastShot)
01592             {
01593                 if (lastShot != -1)
01594                 {
01595                     Quid check = segmentation->GetQuidShot(lastShot);
01596                     int rank = shotSimTable->Size();
01597                     if (shotQuids->Size() <= rank)
01598                         shotQuids->Add(check);
01599                     if (check != shotQuids->Get1(rank))
01600                     {
01601                         ILOG_ERROR("Quids do not match");
01602                     }
01603                     if (aggregationMode == "avg")
01604                     {
01605                         lastSim = lastSim / lastCount;
01606                     }
01607                     shotSimTable->Add(lastSim);
01608                 }
01609                 lastSim = frameSim;
01610                 lastShot = shot;
01611                 lastCount = 1;
01612             }
01613             else
01614             {
01615                 lastCount++;
01616                 if (aggregationMode == "max")
01617                 {
01618                     if (frameSim > lastSim)
01619                         lastSim = frameSim;
01620                 }
01621                 else if (aggregationMode == "avg")
01622                 {
01623                     lastSim += frameSim;
01624                 }
01625             }
01626         }
01627         if (lastShot != -1)
01628         {
01629             Quid check = segmentation->GetQuidShot(lastShot);
01630             int rank = shotSimTable->Size();
01631             if (shotQuids->Size() <= rank)
01632                 shotQuids->Add(check);
01633             if (check != shotQuids->Get1(rank))
01634             {
01635                 ILOG_ERROR("Quids do not match");
01636             }
01637             if (aggregationMode == "avg")
01638             {
01639                 lastSim = lastSim / lastCount;
01640             }
01641             shotSimTable->Add(lastSim);
01642         }
01643     }
01644 
01645     res->ComputeRanks(true);
01646     simLoc.SetFeature("shot" + feature);
01647     SimilarityTableSetRepository().Add(simLoc, res);
01648     delete res;
01649     delete simSet;
01650     delete vidSet;
01651 }

Here is the call graph for this function:


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