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

int Impala::Application::VidSet::mainVidSet ( int  argc,
char *  argv[] 
)

Definition at line 241 of file mainVidSet.cpp.

References Impala::Core::VideoSet::InterestPointProc::AddCmdOptions(), Impala::Core::VideoSet::Walker::AddKeyframeMaskAnnoFile(), Impala::Core::VideoSet::Walker::AddListener(), Impala::CmdOptions::AddOption(), Impala::Core::VideoSet::Walker::AddRkfMask(), Impala::Core::VideoSet::Walker::DoWalk(), Impala::Core::VideoSet::Walker::DoWalkBookmarks(), Impala::Core::VideoSet::Walker::DoWalkKeyframes(), Impala::Core::VideoSet::Walker::DoWalkQuids(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Dump(), Impala::FileNameExt(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetBool(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetInt(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::TaskTable::GetNumberFiles(), Impala::Core::VideoSet::TaskTable::GetStartFile(), Impala::Core::VideoSet::TaskTable::GetStartFrame(), Impala::CmdOptions::GetString(), GetVideoTask(), ILOG_DEBUG, ILOG_ERROR, ILOG_ERROR_COUNT, ILOG_INFO, ILOG_VAR, ILOG_WARN, Impala::CmdOptions::Initialise(), Impala::Core::VideoSet::WalkerConfig::InitOptions(), Impala::Core::VideoSet::Walker::LoadBookmarks(), Impala::Core::VideoSet::Walker::LoadKeyframes(), Impala::Core::VideoSet::Walker::LoadQuids(), Impala::Core::VideoSet::Walker::LoadSegmentation(), Impala::Core::VideoSet::MakeVideoSet(), MakeVideoTaskTable(), Impala::Core::Database::RawDataSet::NrFiles(), Impala::Core::VideoSet::Walker::NrListeners(), Impala::CmdOptions::ParseArgs(), Impala::Core::Vector::ReduceSum(), Impala::Core::VideoSet::WalkerConfig::RetrieveOptions(), Impala::Core::Table::Table::Size(), and Impala::Core::VideoSet::Walker::TotalNrFramesInBookmarks().

Referenced by main().

00242 {
00243     Link::Mpi::Init(&argc, &argv);
00244 
00245     CmdOptions& options = CmdOptions::GetInstance();
00246     options.Initialise(true, false, true);
00247     options.AddOption(0, "report", "perNr", "0");
00248     options.AddOption(0, "startFile", "idx", "0");
00249     options.AddOption(0, "numberFiles", "nr", "-1");
00250     options.AddOption(0, "segmentation", "", "0");
00251     options.AddOption(0, "keyframes", "", "0");
00252     options.AddOption(0, "rkfMask", "", "0");
00253     options.AddOption(0, "keyframeMask", "file", "");
00254     options.AddOption(0, "keyframeMaskAnno", "file", "");
00255     options.AddOption(0, "quidWalk", "file", "");
00256     options.AddOption(0, "startTask", "idx", "-1");
00257     options.AddOption(0, "nrTaskWalk", "nr", "1"); // quick hack for process mgt
00258     options.AddOption(0, "taskByVideoSize", "", "0");
00259     options.AddOption(0, "virtualWalkAll", "", "0");
00260     options.AddOption(0, "maskFile", "file", "");
00261     options.AddOption(0, "featureIndexCat", "name", "");
00262     options.AddOption(0, "classifyIndexCat", "name", "");
00263     options.AddOption(0, "precomputed", "[only works for applyconcepts] boolean: if 1 modelfiles must be for precomputed kernel", "0");
00264     options.AddOption(0, "storeKernelData", "[only works for applyconcepts] boolean: if 1 kernel data will be written to disk", "0");
00265     options.AddOption(0, "kernelDataOnly", "[only works for applyconcepts] boolean: if 1 only kernel data will be computed (no model apply)", "0");
00266     options.AddOption(0, "fik", "[only works for applyconcepts] boolean: if 1 modelfiles must be for fast intersection kernel", "0");
00267     options.AddOption(0, "msf-feature", "bool [for lbpeval]", "0");
00268 
00269     WalkerConfig walkerConfig;
00270     walkerConfig.InitOptions(options);
00271 
00272     // initialization of options
00273     Impala::Core::VideoSet::InterestPointProc::AddCmdOptions();
00274 
00275     // Below are ShotSegmenter specific options   
00276     options.AddOption(0, "SSProbThresh", "value", "0.5");
00277     options.AddOption(0, "SSNoMpeg7", "", "0");
00278     options.AddOption(0, "SSNoSim", "", "0");
00279     options.AddOption(0, "SSNoNrkf", "", "0");
00280 
00281     if (! options.ParseArgs(argc, argv, "cmd videoSet|vxs|dbsection/file", 2))
00282     {
00283         Link::Mpi::Finalize();
00284         return 1;
00285     }
00286 
00287     ILOG_VAR(Impala.Application.VidSet.mainVidSet);
00288 
00289     ILOG_INFO("Disk images are " <<
00290               (Link::DiskImage::DiskImageUsed() ? "" : "not ") << "supported");
00291 
00292     String cmd = options.GetArg(0);
00293     String fileName = options.GetArg(1);
00294 
00295     VideoSet* videoSet = MakeVideoSet(fileName);
00296 
00297     walkerConfig.RetrieveOptions(options);
00298     Walker walker(videoSet, walkerConfig);
00299     Reporter* reporter = new Reporter(0);
00300     walker.AddListener(reporter);
00301 
00302     ILOG_INFO("vidset command : " << cmd);
00303 
00304     if (cmd == "computekerneldata")
00305         walker.AddListener(new ComputeKernelData(reporter, options));
00306     if (cmd == "testvideo")
00307         walker.AddListener(new TestVideo(reporter, options));
00308 #ifndef REPOSITORY_TODO
00309     if (cmd == "validatevideoindex")
00310         walker.AddListener(new VideoIndexValidator(reporter, options));
00311 #endif
00312     if (cmd == "checknrframes")
00313         walker.AddListener(new CheckNrFrames(reporter, options));
00314     if (cmd == "shotsegmenter")
00315         walker.AddListener(new ShotSegmenter(reporter, options));
00316     if (cmd == "selectframes")
00317         walker.AddListener(new SelectFrames(reporter, options));
00318     if (cmd == "indexsegmentation")
00319         walker.AddListener(new IndexSegmentation(reporter, options));
00320     if (cmd == "indexannotation")
00321         walker.AddListener(new IndexAnnotation(reporter, options));
00322     if (cmd == "applyconcepts")
00323         walker.AddListener(new ApplyConcepts(reporter, options, videoSet,false));
00324     if (cmd == "applyconceptsindex")
00325         walker.AddListener(new ApplyConcepts(reporter, options, videoSet, true));
00326     if (cmd == "combineconcepts")
00327         walker.AddListener(new CombineConcepts(reporter, options));
00328     if (cmd == "indexconcepts")
00329         walker.AddListener(new IndexConcepts(reporter, options, videoSet));
00330     if (cmd == "exportconcepts")
00331         walker.AddListener(new ExportConcepts(reporter, options));
00332     if (cmd == "importconcepts")
00333         walker.AddListener(new ImportConcepts(reporter, options));
00334     if (cmd == "importaudioconcepts")
00335         walker.AddListener(new ImportAudioConcepts(reporter, options));
00336 
00337     if (cmd == "exportframes")
00338         walker.AddListener(new ExportFrames(reporter, options));
00339     if (cmd == "exportkeyframes")
00340         walker.AddListener(new ExportKeyframes(reporter, options, videoSet));
00341     if (cmd == "exportstills")
00342         walker.AddListener(new ExportStills(reporter, options));
00343     if (cmd == "exportframehashes")
00344         walker.AddListener(new ExportFrameHashes(reporter, options));
00345 
00346     if (cmd == "vistrain")
00347         walker.AddListener(new VisSemTrain(reporter, "vissem", options));
00348     if (cmd == "visgabortrain")
00349         walker.AddListener(new VisSemTrain(reporter, "vissemgabor", options));
00350 
00351     if (cmd == "viseval")
00352     {
00353         Computor* c = new VisSem("vissem", options);
00354         walker.AddListener(new ProtoSimilarityEval(c, reporter, options));
00355     }
00356     if (cmd == "visgaboreval")
00357     {
00358         Computor* c = new VisSem("vissemgabor", options);
00359         walker.AddListener(new ProtoSimilarityEval(c, reporter, options));
00360     }
00361     if (cmd == "lbpeval")
00362         walker.AddListener(new LbpEval(reporter, options));
00363 
00364     if (cmd == "visgaborstat")
00365         walker.AddListener(new VisSemGaborStat(reporter, options));
00366 
00367     if (cmd == "clusterfeatures")
00368     {
00369         if (options.GetNrArg() < 4)
00370             ILOG_ERROR("cluster: missing argument");
00371         String feature = options.GetArg(2);
00372         Computor* c = 0;
00373         if (feature == "weibull")
00374             c = new VisSem("vissem", options);
00375         if (feature == "gabor")
00376             c = new Core::Feature::VisSem("vissemgabor", options);
00377         String clusteror = options.GetArg(3);
00378         walker.AddListener(new ClusterFeatures(c, clusteror, reporter, options));
00379     }
00380 
00381     if (cmd == "extractlab")
00382         walker.AddListener(new LabHistExtractor(reporter, options));
00383     if (cmd == "extractlab3d")
00384         walker.AddListener(new LabHist3dExtractor(reporter, options));
00385     if (cmd == "extractrgb")
00386         walker.AddListener(new RgbHistExtractor(reporter, options));
00387 
00388     if (cmd == "indexfeatures")
00389         walker.AddListener(new IndexFeatures(reporter, options));
00390     if (cmd == "concatfeatures")
00391         walker.AddListener(new ConcatFeatures(reporter, options));
00392     if (cmd == "exportfeatures")
00393         walker.AddListener(new ExportFeatures(reporter, options));
00394     if (cmd == "interestpointproc")
00395         walker.AddListener(new InterestPointProc(reporter, options));
00396     if (cmd == "blackframeproc")
00397         walker.AddListener(new BlackFrameProc(reporter, options));
00398     if (cmd == "makequidlookup")
00399         walker.AddListener(new MakeQuidLookup(reporter, options));
00400 
00401     if ((walker.NrListeners() == 1) && !((cmd == "nop") || (cmd == "tasktable")))
00402     {
00403         ILOG_ERROR("Unknown command : " << cmd);
00404         Link::Mpi::Finalize();
00405         return 1;
00406     }
00407 
00408     walker.AddListener(new Reporter(reporter));
00409     if (FileNameExt(fileName) == "vxs")
00410     {
00411         walker.LoadBookmarks(fileName);
00412         reporter->SetTotalNrFramesInBookmarks(walker.TotalNrFramesInBookmarks());
00413         walker.DoWalkBookmarks();
00414     }
00415     else
00416     {
00417         if (options.GetBool("keyframes"))
00418         {
00419             walker.LoadKeyframes("keyframes");
00420             if (options.GetBool("rkfMask"))
00421                 walker.AddRkfMask();
00422             if (options.GetString("keyframeMaskAnno") != "")
00423                 walker.AddKeyframeMaskAnnoFile(options.GetString("keyframeMaskAnno"));
00424         }
00425         if (options.GetBool("segmentation"))
00426             walker.LoadSegmentation("segmentation");
00427         String quidFile = options.GetString("quidWalk");
00428         if (!quidFile.empty())
00429         {
00430             walker.LoadQuids(quidFile);
00431         }
00432 
00433         TaskTable* taskTable = MakeVideoTaskTable(videoSet, &walker, cmd,
00434                                                   quidFile);
00435         if ((Link::Mpi::MyId() == 0) && (cmd == "tasktable"))
00436         {
00437             taskTable->Dump();
00438             Persistency::TaskTableLocator loc(videoSet->GetLocator(),
00439                                               "tasktable.tab");
00440             Persistency::TaskTableRepository().Add(loc, taskTable);
00441         }
00442         int taskIdx = GetVideoTask();
00443         int nrTaskWalk = options.GetInt("nrTaskWalk");
00444         int numProcs = Link::Mpi::NrProcs();
00445         for (int walk=0 ; walk<nrTaskWalk ; walk++)
00446         {
00447             int t = taskIdx + walk*numProcs;
00448             if (t >= taskTable->Size())
00449             {
00450                 ILOG_WARN("Task index out of range");
00451                 continue;
00452             }
00453             int startFile = taskTable->GetStartFile(t);
00454             int numberFiles = taskTable->GetNumberFiles(t);
00455             if (options.GetBool("virtualWalkAll")
00456                 && (options.GetInt("numberFiles") == -1))
00457             {
00458                 numberFiles = videoSet->NrFiles();
00459             }
00460             int startFrame = taskTable->GetStartFrame(t);
00461             ILOG_INFO("Process " << Link::Mpi::MyId() << " of " <<
00462                       Link::Mpi::NrProcs() << " is doing file " << startFile
00463                       << " till " << startFile + numberFiles << " from frame "
00464                       << startFrame);
00465 
00466             if (!quidFile.empty())
00467             {
00468                 walker.DoWalkQuids(startFile, numberFiles);
00469             }
00470             else if (options.GetBool("keyframes"))
00471             {
00472                 walker.DoWalkKeyframes(startFile, numberFiles);
00473             }
00474             else
00475             {
00476                 walker.DoWalk(startFile, numberFiles, startFrame);
00477             }
00478         }
00479         delete taskTable;
00480     }
00481 
00482     reporter->FinalReport();
00483 
00484     int nrOfErrors = ILOG_ERROR_COUNT;
00485     ILOG_DEBUG("nr of errors collected = " << nrOfErrors);
00486 
00487     nrOfErrors = Link::Mpi::ReduceSum(nrOfErrors);
00488     ILOG_INFO_HEADNODE("Root: total nr error = " << nrOfErrors);
00489     Link::Mpi::Finalize();
00490 
00491     return nrOfErrors;
00492 }

Here is the call graph for this function:


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