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

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

Definition at line 1185 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::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetNrShots(), Impala::Core::VideoSet::Segmentation::GetQuidShot(), Impala::Core::VideoSet::Segmentation::GetShotId(), ILOG_ERROR, ILOG_VAR, Impala::Core::Table::SimilarityTableSet::MakeFromFile(), and Impala::Core::VideoSet::MakeVideoSet().

Referenced by mainUtil().

01186 {
01187 #ifndef REPOSITORY_TODO
01188     typedef Core::VideoSet::VideoSet VideoSet;
01189     typedef Core::VideoSet::Segmentation Segmentation;
01190     typedef Core::Table::SimilarityTableSet SimilarityTableSet;
01191     typedef Core::Table::SimilarityTableSet::SimTableType SimTableType;
01192 
01193     ILOG_VAR(Impala.Application.Util.DoMapConcepts2Shots);
01194     CmdOptions& options = CmdOptions::GetInstance();
01195     if (options.GetNrArg() < 5)
01196     {
01197         ILOG_ERROR("Need more parameters");
01198         return;
01199     }
01200     String vidSetName = options.GetArg(1);
01201     String conceptSet = options.GetArg(2);
01202     String model = options.GetArg(3);
01203     String feature = options.GetArg(4);
01204     String aggregationMode = "max";
01205     if (options.GetNrArg() >= 6)
01206     {
01207         aggregationMode = options.GetArg(5);
01208     }
01209 
01210     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName);
01211     SegmentationLocator sLoc(vidSetName, "segmentation", options);
01212     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
01213     SimilarityTableSet* simSet =
01214         Core::Table::SimilarityTableSet::MakeFromFile(vidSet, conceptSet,
01215                                                       model, feature);
01216 
01217     Core::Table::QuidTable* frameQuids = simSet->GetQuidTable();
01218     int nrShots = segmentation->GetNrShots();
01219     SimilarityTableSet* res = new SimilarityTableSet(simSet->GetNames(), nrShots);
01220     Core::Table::QuidTable* shotQuids = res->GetQuidTable();
01221 //    for (int i=0 ; i<nrShots ; i++)
01222 //    {
01223 //        Quid q = segmentation->GetQuidShot(i);
01224 //        shotQuids->Add(q);
01225 //    }
01226     for (int t=0 ; t<simSet->NrTables() ; t++)
01227     {
01228         SimTableType* frameSimTable = simSet->GetSimTable(t);
01229         SimTableType* shotSimTable = res->GetSimTable(t);
01230         int lastShot = -1;
01231         Real64 lastSim = 0;
01232         int lastCount = 0;
01233         for (int i=0 ; i<frameSimTable->Size() ; i++)
01234         {
01235             Quid frameQ = frameQuids->Get1(i);
01236             Real64 frameSim = frameSimTable->Get1(i);
01237             int shot = segmentation->GetShotId(frameQ);
01238             if (shot != lastShot)
01239             {
01240                 if (lastShot != -1)
01241                 {
01242                     Quid check = segmentation->GetQuidShot(lastShot);
01243                     int rank = shotSimTable->Size();
01244                     if (shotQuids->Size() <= rank)
01245                         shotQuids->Add(check);
01246                     if (check != shotQuids->Get1(rank))
01247                     {
01248                         ILOG_ERROR("Quids do not match");
01249                     }
01250                     if(aggregationMode == "avg")
01251                     {
01252                         lastSim = lastSim / lastCount;
01253                     }
01254                     shotSimTable->Add(lastSim);
01255                 }
01256                 lastSim = frameSim;
01257                 lastShot = shot;
01258                 lastCount = 1;
01259             }
01260             else
01261             {
01262                 lastCount++;
01263                 if(aggregationMode == "max")
01264                 {
01265                     if (frameSim > lastSim)
01266                         lastSim = frameSim;
01267                 }
01268                 else if(aggregationMode == "avg")
01269                 {
01270                     lastSim += frameSim;
01271                 }
01272             }
01273         }
01274         if (lastShot != -1)
01275         {
01276             Quid check = segmentation->GetQuidShot(lastShot);
01277             int rank = shotSimTable->Size();
01278             if (shotQuids->Size() <= rank)
01279                 shotQuids->Add(check);
01280             if (check != shotQuids->Get1(rank))
01281             {
01282                 ILOG_ERROR("Quids do not match");
01283             }
01284             if(aggregationMode == "avg")
01285             {
01286                 lastSim = lastSim / lastCount;
01287             }
01288             shotSimTable->Add(lastSim);
01289         }
01290     }
01291 
01292     res->ComputeRanks(true);
01293     res->Save(vidSet, conceptSet, model, "shot" + feature, true);
01294     delete res;
01295     delete simSet;
01296     delete vidSet;
01297 #endif
01298 }

Here is the call graph for this function:


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